git.iko.soy/typeable/nixpkgs
on master help sign in
xtreemfs: add nixos module
commitd31cc0d19ae058b15095296d435a722d6afd87fa authorMatej Cotman <cotman.matej@gmail.com> dateSun 13 Sep 2015, 14:49 (11 years ago) parent346c744
3 files changed+484
nixos/modules/misc/ids.nix+2 nixos/modules/module-list.nix+1 nixos/modules/services/network-filesystems/xtreemfs.nix+481
nixos/modules/misc/ids.nix+2
@@ -233,6 +233,7 @@
233233 dnschain = 209;
234234 #lxd = 210; # unused
235235 kibana = 211;
236+ xtreemfs = 212;
236237
237238 # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!
238239
@@ -444,6 +445,7 @@
444445 #dnschain = 209; #unused
445446 lxd = 210; # unused
446447 #kibana = 211;
448+ xtreemfs = 212;
447449
448450 # When adding a gid, make sure it doesn't match an existing
449451 # uid. Users and groups with the same name should have equal
nixos/modules/module-list.nix+1
@@ -257,6 +257,7 @@
257257 ./services/network-filesystems/diod.nix
258258 ./services/network-filesystems/u9fs.nix
259259 ./services/network-filesystems/yandex-disk.nix
260+ ./services/network-filesystems/xtreemfs.nix
260261 ./services/networking/aiccu.nix
261262 ./services/networking/amuled.nix
262263 ./services/networking/asterisk.nix
nixos/modules/services/network-filesystems/xtreemfs.nixnew file+481
@@ -0,0 +1,481 @@
1+{ config, lib, pkgs, ... }:
2+
3+with lib;
4+
5+let
6+
7+ cfg = config.services.xtreemfs;
8+
9+ xtreemfs = pkgs.xtreemfs;
10+
11+ home = cfg.homeDir;
12+
13+ startupScript = class: configPath: pkgs.writeScript "xtreemfs-osd.sh" ''
14+ #! ${pkgs.stdenv.shell}
15+ JAVA_HOME="${pkgs.jdk}"
16+ JAVADIR="${xtreemfs}/share/java"
17+ JAVA_CALL="$JAVA_HOME/bin/java -ea -cp $JAVADIR/XtreemFS.jar:$JAVADIR/BabuDB.jar:$JAVADIR/Flease.jar:$JAVADIR/protobuf-java-2.5.0.jar:$JAVADIR/Foundation.jar:$JAVADIR/jdmkrt.jar:$JAVADIR/jdmktk.jar:$JAVADIR/commons-codec-1.3.jar"
18+ $JAVA_CALL ${class} ${configPath}
19+ '';
20+
21+ dirReplicationConfig = pkgs.writeText "xtreemfs-dir-replication-plugin.properties" ''
22+ babudb.repl.backupDir = ${home}/server-repl-dir
23+ plugin.jar = ${xtreemfs}/share/java/BabuDB_replication_plugin.jar
24+ babudb.repl.dependency.0 = ${xtreemfs}/share/java/Flease.jar
25+
26+ ${cfg.dir.replication.extraConfig}
27+ '';
28+
29+ dirConfig = pkgs.writeText "xtreemfs-dir-config.properties" ''
30+ uuid = ${cfg.dir.uuid}
31+ listen.port = ${toString cfg.dir.port}
32+ ${optionalString (cfg.dir.address != "") "listen.address = ${cfg.dir.address}"}
33+ http_port = ${toString cfg.dir.httpPort}
34+ babudb.baseDir = ${home}/dir/database
35+ babudb.logDir = ${home}/dir/db-log
36+ babudb.sync = ${if cfg.dir.replication.enable then "FDATASYNC" else cfg.dir.syncMode}
37+
38+ ${optionalString cfg.dir.replication.enable "babudb.plugin.0 = ${dirReplicationConfig}"}
39+
40+ ${cfg.dir.extraConfig}
41+ '';
42+
43+ mrcReplicationConfig = pkgs.writeText "xtreemfs-mrc-replication-plugin.properties" ''
44+ babudb.repl.backupDir = ${home}/server-repl-mrc
45+ plugin.jar = ${xtreemfs}/share/java/BabuDB_replication_plugin.jar
46+ babudb.repl.dependency.0 = ${xtreemfs}/share/java/Flease.jar
47+
48+ ${cfg.mrc.replication.extraConfig}
49+ '';
50+
51+ mrcConfig = pkgs.writeText "xtreemfs-mrc-config.properties" ''
52+ uuid = ${cfg.mrc.uuid}
53+ listen.port = ${toString cfg.mrc.port}
54+ ${optionalString (cfg.mrc.address != "") "listen.address = ${cfg.mrc.address}"}
55+ http_port = ${toString cfg.mrc.httpPort}
56+ babudb.baseDir = ${home}/mrc/database
57+ babudb.logDir = ${home}/mrc/db-log
58+ babudb.sync = ${if cfg.mrc.replication.enable then "FDATASYNC" else cfg.mrc.syncMode}
59+
60+ ${optionalString cfg.mrc.replication.enable "babudb.plugin.0 = ${mrcReplicationConfig}"}
61+
62+ ${cfg.mrc.extraConfig}
63+ '';
64+
65+ osdConfig = pkgs.writeText "xtreemfs-osd-config.properties" ''
66+ uuid = ${cfg.osd.uuid}
67+ listen.port = ${toString cfg.osd.port}
68+ ${optionalString (cfg.osd.address != "") "listen.address = ${cfg.osd.address}"}
69+ http_port = ${toString cfg.osd.httpPort}
70+ object_dir = ${home}/osd/
71+
72+ ${cfg.osd.extraConfig}
73+ '';
74+
75+in
76+
77+{
78+
79+ ###### interface
80+
81+ options = {
82+
83+ services.xtreemfs = {
84+
85+ enable = mkOption {
86+ default = false;
87+ description = ''
88+ Whether to enable XtreemFS.
89+ '';
90+ };
91+
92+ homeDir = mkOption {
93+ default = "/var/lib/xtreemfs";
94+ description = ''
95+ XtreemFS home dir for the xtreemfs user.
96+ '';
97+ };
98+
99+ dir = {
100+ enable = mkOption {
101+ default = true;
102+ description = ''
103+ Whether to enable XtreemFS DIR service.
104+ '';
105+ };
106+ uuid = mkOption {
107+ example = "eacb6bab-f444-4ebf-a06a-3f72d7465e40";
108+ description = ''
109+ Must be set to a unique identifier, preferably a UUID according to
110+ RFC 4122. UUIDs can be generated with `uuidgen` command, found in
111+ the `utillinux` package.
112+ '';
113+ };
114+ port = mkOption {
115+ default = 32638;
116+ description = ''
117+ The port to listen on for incoming connections (TCP).
118+ '';
119+ };
120+ address = mkOption {
121+ example = "127.0.0.1";
122+ default = "";
123+ description = ''
124+ If specified, it defines the interface to listen on. If not
125+ specified, the service will listen on all interfaces (any).
126+ '';
127+ };
128+ httpPort = mkOption {
129+ default = 30638;
130+ description = ''
131+ Specifies the listen port for the HTTP service that returns the
132+ status page.
133+ '';
134+ };
135+ syncMode = mkOption {
136+ default = "FSYNC";
137+ example = "FDATASYNC";
138+ description = ''
139+ The sync mode influences how operations are committed to the disk
140+ log before the operation is acknowledged to the caller.
141+
142+ -ASYNC mode the writes to the disk log are buffered in memory by the operating system. This is the fastest mode but will lead to data loss in case of a crash, kernel panic or power failure.
143+ -SYNC_WRITE_METADATA opens the file with O_SYNC, the system will not buffer any writes. The operation will be acknowledged when data has been safely written to disk. This mode is slow but offers maximum data safety. However, BabuDB cannot influence the disk drive caches, this depends on the OS and hard disk model.
144+ -SYNC_WRITE similar to SYNC_WRITE_METADATA but opens file with O_DSYNC which means that only the data is commit to disk. This can lead to some data loss depending on the implementation of the underlying file system. Linux does not implement this mode.
145+ -FDATASYNC is similar to SYNC_WRITE but opens the file in asynchronous mode and calls fdatasync() after writing the data to disk.
146+ -FSYNC is similar to SYNC_WRITE_METADATA but opens the file in asynchronous mode and calls fsync() after writing the data to disk.
147+
148+ For best throughput use ASYNC, for maximum data safety use FSYNC.
149+
150+ (If xtreemfs.dir.replication.enable is true then FDATASYNC is forced)
151+ '';
152+ };
153+ extraConfig = mkOption {
154+ default = "";
155+ example = ''
156+ # specify whether SSL is required
157+ ssl.enabled = true
158+ ssl.service_creds.pw = passphrase
159+ ssl.service_creds.container = pkcs12
160+ ssl.service_creds = /etc/xos/xtreemfs/truststore/certs/dir.p12
161+ ssl.trusted_certs = /etc/xos/xtreemfs/truststore/certs/trusted.jks
162+ ssl.trusted_certs.pw = jks_passphrase
163+ ssl.trusted_certs.container = jks
164+ '';
165+ description = ''
166+ Configuration of XtreemFS DIR service.
167+ WARNING: configuration is saved as plaintext inside nix store.
168+ For more options: http://www.xtreemfs.org/xtfs-guide-1.5.1/index.html
169+ '';
170+ };
171+ replication = {
172+ enable = mkOption {
173+ default = false;
174+ description = ''
175+ Whether to enable XtreemFS DIR replication plugin.
176+ '';
177+ };
178+ extraConfig = mkOption {
179+ example = ''
180+ # participants of the replication including this replica
181+ babudb.repl.participant.0 = 192.168.0.10
182+ babudb.repl.participant.0.port = 35676
183+ babudb.repl.participant.1 = 192.168.0.11
184+ babudb.repl.participant.1.port = 35676
185+ babudb.repl.participant.2 = 192.168.0.12
186+ babudb.repl.participant.2.port = 35676
187+
188+ # number of servers that at least have to be up to date
189+ # To have a fault-tolerant system, this value has to be set to the
190+ # majority of nodes i.e., if you have three replicas, set this to 2
191+ # Please note that a setup with two nodes provides no fault-tolerance.
192+ babudb.repl.sync.n = 2
193+
194+ # specify whether SSL is required
195+ babudb.ssl.enabled = true
196+
197+ babudb.ssl.protocol = tlsv12
198+
199+ # server credentials for SSL handshakes
200+ babudb.ssl.service_creds = /etc/xos/xtreemfs/truststore/certs/osd.p12
201+ babudb.ssl.service_creds.pw = passphrase
202+ babudb.ssl.service_creds.container = pkcs12
203+
204+ # trusted certificates for SSL handshakes
205+ babudb.ssl.trusted_certs = /etc/xos/xtreemfs/truststore/certs/trusted.jks
206+ babudb.ssl.trusted_certs.pw = jks_passphrase
207+ babudb.ssl.trusted_certs.container = jks
208+
209+ babudb.ssl.authenticationWithoutEncryption = false
210+ '';
211+ description = ''
212+ Configuration of XtreemFS DIR replication plugin.
213+ WARNING: configuration is saved as plaintext inside nix store.
214+ For more options: http://www.xtreemfs.org/xtfs-guide-1.5.1/index.html
215+ '';
216+ };
217+ };
218+ };
219+
220+ mrc = {
221+ enable = mkOption {
222+ default = true;
223+ description = ''
224+ Whether to enable XtreemFS MRC service.
225+ '';
226+ };
227+ uuid = mkOption {
228+ example = "eacb6bab-f444-4ebf-a06a-3f72d7465e41";
229+ description = ''
230+ Must be set to a unique identifier, preferably a UUID according to
231+ RFC 4122. UUIDs can be generated with `uuidgen` command, found in
232+ the `utillinux` package.
233+ '';
234+ };
235+ port = mkOption {
236+ default = 32636;
237+ description = ''
238+ The port to listen on for incoming connections (TCP).
239+ '';
240+ };
241+ address = mkOption {
242+ example = "127.0.0.1";
243+ default = "";
244+ description = ''
245+ If specified, it defines the interface to listen on. If not
246+ specified, the service will listen on all interfaces (any).
247+ '';
248+ };
249+ httpPort = mkOption {
250+ default = 30636;
251+ description = ''
252+ Specifies the listen port for the HTTP service that returns the
253+ status page.
254+ '';
255+ };
256+ syncMode = mkOption {
257+ default = "FSYNC";
258+ example = "FDATASYNC";
259+ description = ''
260+ The sync mode influences how operations are committed to the disk
261+ log before the operation is acknowledged to the caller.
262+
263+ -ASYNC mode the writes to the disk log are buffered in memory by the operating system. This is the fastest mode but will lead to data loss in case of a crash, kernel panic or power failure.
264+ -SYNC_WRITE_METADATA opens the file with O_SYNC, the system will not buffer any writes. The operation will be acknowledged when data has been safely written to disk. This mode is slow but offers maximum data safety. However, BabuDB cannot influence the disk drive caches, this depends on the OS and hard disk model.
265+ -SYNC_WRITE similar to SYNC_WRITE_METADATA but opens file with O_DSYNC which means that only the data is commit to disk. This can lead to some data loss depending on the implementation of the underlying file system. Linux does not implement this mode.
266+ -FDATASYNC is similar to SYNC_WRITE but opens the file in asynchronous mode and calls fdatasync() after writing the data to disk.
267+ -FSYNC is similar to SYNC_WRITE_METADATA but opens the file in asynchronous mode and calls fsync() after writing the data to disk.
268+
269+ For best throughput use ASYNC, for maximum data safety use FSYNC.
270+
271+ (If xtreemfs.mrc.replication.enable is true then FDATASYNC is forced)
272+ '';
273+ };
274+ extraConfig = mkOption {
275+ example = ''
276+ osd_check_interval = 300
277+ no_atime = true
278+ local_clock_renewal = 0
279+ remote_time_sync = 30000
280+ authentication_provider = org.xtreemfs.common.auth.NullAuthProvider
281+
282+ # shared secret between the MRC and all OSDs
283+ capability_secret = iNG8UuQJrJ6XVDTe
284+
285+ dir_service.host = 192.168.0.10
286+ dir_service.port = 32638
287+
288+ # if replication is enabled
289+ dir_service.1.host = 192.168.0.11
290+ dir_service.1.port = 32638
291+ dir_service.2.host = 192.168.0.12
292+ dir_service.2.port = 32638
293+
294+ # specify whether SSL is required
295+ ssl.enabled = true
296+ ssl.protocol = tlsv12
297+ ssl.service_creds.pw = passphrase
298+ ssl.service_creds.container = pkcs12
299+ ssl.service_creds = /etc/xos/xtreemfs/truststore/certs/mrc.p12
300+ ssl.trusted_certs = /etc/xos/xtreemfs/truststore/certs/trusted.jks
301+ ssl.trusted_certs.pw = jks_passphrase
302+ ssl.trusted_certs.container = jks
303+ '';
304+ description = ''
305+ Configuration of XtreemFS MRC service.
306+ WARNING: configuration is saved as plaintext inside nix store.
307+ For more options: http://www.xtreemfs.org/xtfs-guide-1.5.1/index.html
308+ '';
309+ };
310+ replication = {
311+ enable = mkOption {
312+ default = false;
313+ description = ''
314+ Whether to enable XtreemFS MRC replication plugin.
315+ '';
316+ };
317+ extraConfig = mkOption {
318+ example = ''
319+ # participants of the replication including this replica
320+ babudb.repl.participant.0 = 192.168.0.10
321+ babudb.repl.participant.0.port = 35678
322+ babudb.repl.participant.1 = 192.168.0.11
323+ babudb.repl.participant.1.port = 35678
324+ babudb.repl.participant.2 = 192.168.0.12
325+ babudb.repl.participant.2.port = 35678
326+
327+ # number of servers that at least have to be up to date
328+ # To have a fault-tolerant system, this value has to be set to the
329+ # majority of nodes i.e., if you have three replicas, set this to 2
330+ # Please note that a setup with two nodes provides no fault-tolerance.
331+ babudb.repl.sync.n = 2
332+
333+ # specify whether SSL is required
334+ babudb.ssl.enabled = true
335+
336+ babudb.ssl.protocol = tlsv12
337+
338+ # server credentials for SSL handshakes
339+ babudb.ssl.service_creds = /etc/xos/xtreemfs/truststore/certs/osd.p12
340+ babudb.ssl.service_creds.pw = passphrase
341+ babudb.ssl.service_creds.container = pkcs12
342+
343+ # trusted certificates for SSL handshakes
344+ babudb.ssl.trusted_certs = /etc/xos/xtreemfs/truststore/certs/trusted.jks
345+ babudb.ssl.trusted_certs.pw = jks_passphrase
346+ babudb.ssl.trusted_certs.container = jks
347+
348+ babudb.ssl.authenticationWithoutEncryption = false
349+ '';
350+ description = ''
351+ Configuration of XtreemFS MRC replication plugin.
352+ WARNING: configuration is saved as plaintext inside nix store.
353+ For more options: http://www.xtreemfs.org/xtfs-guide-1.5.1/index.html
354+ '';
355+ };
356+ };
357+ };
358+
359+ osd = {
360+ enable = mkOption {
361+ default = true;
362+ description = ''
363+ Whether to enable XtreemFS OSD service.
364+ '';
365+ };
366+ uuid = mkOption {
367+ example = "eacb6bab-f444-4ebf-a06a-3f72d7465e42";
368+ description = ''
369+ Must be set to a unique identifier, preferably a UUID according to
370+ RFC 4122. UUIDs can be generated with `uuidgen` command, found in
371+ the `utillinux` package.
372+ '';
373+ };
374+ port = mkOption {
375+ default = 32640;
376+ description = ''
377+ The port to listen on for incoming connections (TCP and UDP).
378+ '';
379+ };
380+ address = mkOption {
381+ example = "127.0.0.1";
382+ default = "";
383+ description = ''
384+ If specified, it defines the interface to listen on. If not
385+ specified, the service will listen on all interfaces (any).
386+ '';
387+ };
388+ httpPort = mkOption {
389+ default = 30640;
390+ description = ''
391+ Specifies the listen port for the HTTP service that returns the
392+ status page.
393+ '';
394+ };
395+ extraConfig = mkOption {
396+ example = ''
397+ local_clock_renewal = 0
398+ remote_time_sync = 30000
399+ report_free_space = true
400+ capability_secret = iNG8UuQJrJ6XVDTe
401+
402+ dir_service.host = 192.168.0.10
403+ dir_service.port = 32638
404+
405+ # if replication is used
406+ dir_service.1.host = 192.168.0.11
407+ dir_service.1.port = 32638
408+ dir_service.2.host = 192.168.0.12
409+ dir_service.2.port = 32638
410+
411+ # specify whether SSL is required
412+ ssl.enabled = true
413+ ssl.service_creds.pw = passphrase
414+ ssl.service_creds.container = pkcs12
415+ ssl.service_creds = /etc/xos/xtreemfs/truststore/certs/osd.p12
416+ ssl.trusted_certs = /etc/xos/xtreemfs/truststore/certs/trusted.jks
417+ ssl.trusted_certs.pw = jks_passphrase
418+ ssl.trusted_certs.container = jks
419+ '';
420+ description = ''
421+ Configuration of XtreemFS OSD service.
422+ WARNING: configuration is saved as plaintext inside nix store.
423+ For more options: http://www.xtreemfs.org/xtfs-guide-1.5.1/index.html
424+ '';
425+ };
426+ };
427+ };
428+
429+ };
430+
431+
432+ ###### implementation
433+
434+ config = lib.mkIf cfg.enable {
435+
436+ environment.systemPackages = [ xtreemfs ];
437+
438+ users.extraUsers.xtreemfs =
439+ { uid = config.ids.uids.xtreemfs;
440+ description = "XtreemFS user";
441+ createHome = true;
442+ home = home;
443+ };
444+
445+ users.extraGroups.xtreemfs =
446+ { gid = config.ids.gids.xtreemfs;
447+ };
448+
449+ systemd.services.xtreemfs-dir = mkIf cfg.dir.enable {
450+ description = "XtreemFS-DIR Server";
451+ after = [ "network.target" ];
452+ wantedBy = [ "multi-user.target" ];
453+ serviceConfig = {
454+ User = "xtreemfs";
455+ ExecStart = "${startupScript "org.xtreemfs.dir.DIR" dirConfig}";
456+ };
457+ };
458+
459+ systemd.services.xtreemfs-mrc = mkIf cfg.mrc.enable {
460+ description = "XtreemFS-MRC Server";
461+ after = [ "network.target" ];
462+ wantedBy = [ "multi-user.target" ];
463+ serviceConfig = {
464+ User = "xtreemfs";
465+ ExecStart = "${startupScript "org.xtreemfs.mrc.MRC" mrcConfig}";
466+ };
467+ };
468+
469+ systemd.services.xtreemfs-osd = mkIf cfg.osd.enable {
470+ description = "XtreemFS-OSD Server";
471+ after = [ "network.target" ];
472+ wantedBy = [ "multi-user.target" ];
473+ serviceConfig = {
474+ User = "xtreemfs";
475+ ExecStart = "${startupScript "org.xtreemfs.osd.OSD" osdConfig}";
476+ };
477+ };
478+
479+ };
480+
481+}