···
1
+
{ config, lib, pkgs, ...} :
6
+
cfg = config.services.orangefs.server;
8
+
aliases = mapAttrsToList (alias: url: alias) cfg.servers;
10
+
# Maximum handle number is 2^63
11
+
maxHandle = 9223372036854775806;
13
+
# One range of handles for each meta/data instance
14
+
handleStep = maxHandle / (length aliases) / 2;
16
+
fileSystems = mapAttrsToList (name: fs: ''
19
+
ID ${toString fs.id}
20
+
RootHandle ${toString fs.rootHandle}
25
+
${concatStringsSep "\n" (
28
+
begin = i * handleStep + 3;
29
+
end = begin + handleStep - 1;
30
+
in "Range ${alias} ${toString begin}-${toString end}") aliases
35
+
${concatStringsSep "\n" (
38
+
begin = i * handleStep + 3 + (length aliases) * handleStep;
39
+
end = begin + handleStep - 1;
40
+
in "Range ${alias} ${toString begin}-${toString end}") aliases
45
+
TroveSyncMeta ${if fs.troveSyncMeta then "yes" else "no"}
46
+
TroveSyncData ${if fs.troveSyncData then "yes" else "no"}
47
+
${fs.extraStorageHints}
51
+
'') cfg.fileSystems;
55
+
LogType ${cfg.logType}
56
+
DataStorageSpace ${cfg.dataStorageSpace}
57
+
MetaDataStorageSpace ${cfg.metadataStorageSpace}
59
+
BMIModules ${concatStringsSep "," cfg.BMIModules}
60
+
${cfg.extraDefaults}
66
+
${concatStringsSep "\n" (mapAttrsToList (alias: url: "Alias ${alias} ${url}") cfg.servers)}
69
+
${concatStringsSep "\n" fileSystems}
76
+
services.orangefs.server = {
77
+
enable = mkEnableOption "OrangeFS server";
79
+
logType = mkOption {
80
+
type = with types; enum [ "file" "syslog" ];
82
+
description = "Destination for log messages.";
85
+
dataStorageSpace = mkOption {
88
+
example = "/data/storage";
89
+
description = "Directory for data storage.";
92
+
metadataStorageSpace = mkOption {
95
+
example = "/data/meta";
96
+
description = "Directory for meta data storage.";
99
+
BMIModules = mkOption {
100
+
type = with types; listOf str;
101
+
default = [ "bmi_tcp" ];
102
+
example = [ "bmi_tcp" "bmi_ib"];
103
+
description = "List of BMI modules to load.";
106
+
extraDefaults = mkOption {
107
+
type = types.lines;
109
+
description = "Extra config for <literal><Defaults></literal> section.";
112
+
extraConfig = mkOption {
113
+
type = types.lines;
115
+
description = "Extra config for the global section.";
118
+
servers = mkOption {
119
+
type = with types; attrsOf types.str;
123
+
node1="tcp://node1:3334";
124
+
node2="tcp://node2:3334";
127
+
description = "URLs for storage server including port. The attribute names define the server alias.";
130
+
fileSystems = mkOption {
132
+
These options will create the <literal><FileSystem></literal> sections of config file.
134
+
default = { orangefs = {}; };
135
+
defaultText = literalExample "{ orangefs = {}; }";
136
+
example = literalExample ''
147
+
type = with types; attrsOf (submodule ({ ... } : {
152
+
description = "File system ID (must be unique within configuration).";
155
+
rootHandle = mkOption {
158
+
description = "File system root ID.";
161
+
extraConfig = mkOption {
162
+
type = types.lines;
164
+
description = "Extra config for <literal><FileSystem></literal> section.";
167
+
troveSyncMeta = mkOption {
170
+
description = "Sync meta data.";
173
+
troveSyncData = mkOption {
176
+
description = "Sync data.";
179
+
extraStorageHints = mkOption {
180
+
type = types.lines;
182
+
description = "Extra config for <literal><StorageHints></literal> section.";
190
+
###### implementation
192
+
config = mkIf cfg.enable {
193
+
environment.systemPackages = [ pkgs.orangefs ];
195
+
# orangefs daemon will run as user
196
+
users.users.orangefs.isSystemUser = true;
197
+
users.groups.orangefs = {};
199
+
# To format the file system the config file is needed.
200
+
environment.etc."orangefs/server.conf" = {
203
+
group = "orangefs";
206
+
systemd.services.orangefs-server = {
207
+
wantedBy = [ "multi-user.target" ];
208
+
requires = [ "network-online.target" ];
209
+
after = [ "network-online.target" ];
212
+
# Run as "simple" in forground mode.
213
+
# This is more reliable
215
+
${pkgs.orangefs}/bin/pvfs2-server -d \
216
+
/etc/orangefs/server.conf
218
+
TimeoutStopSec = "120";
220
+
Group = "orangefs";