fix(netconf/dgn-hardware): Some models are extension cards
This commit is contained in:
parent
fbfb22d777
commit
9024590a34
1 changed files with 30 additions and 14 deletions
|
@ -3,7 +3,7 @@
|
|||
let
|
||||
inherit (lib) genList mkOption listToAttrs;
|
||||
|
||||
inherit (lib.types) enum;
|
||||
inherit (lib.types) enum listOf;
|
||||
|
||||
range = prefix: genList (port: "${prefix}${builtins.toString port}");
|
||||
mkInterfaces =
|
||||
|
@ -17,6 +17,24 @@ let
|
|||
}) interfaces
|
||||
);
|
||||
|
||||
mkAllInterfaces = builtins.foldl' (
|
||||
interfaces: model:
|
||||
interfaces
|
||||
// (
|
||||
let
|
||||
ports = import ./. + "${model}.nix" range;
|
||||
in
|
||||
(mkInterfaces {
|
||||
supportPoE = true;
|
||||
interfaces = ports.poe;
|
||||
})
|
||||
// (mkInterfaces {
|
||||
supportPoE = false;
|
||||
interfaces = ports.regular;
|
||||
})
|
||||
)
|
||||
) { };
|
||||
|
||||
cfg = config.dgn-hardware;
|
||||
in
|
||||
|
||||
|
@ -27,26 +45,24 @@ in
|
|||
"EX2300-48P"
|
||||
"EX4100-F-48P"
|
||||
"EX4400-24X"
|
||||
"EX4400-EM-4Y"
|
||||
];
|
||||
description = ''
|
||||
The exact model of the switch to configure.
|
||||
'';
|
||||
};
|
||||
|
||||
extensions = mkOption {
|
||||
type = listOf (enum [
|
||||
"EX4400-EM-4Y"
|
||||
]);
|
||||
default = [ ];
|
||||
description = ''
|
||||
List of hardware extensions included in the switch.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
netconf.mandatoryInterfaces =
|
||||
let
|
||||
ports = import ./. + "${cfg.model}.nix" range;
|
||||
in
|
||||
(mkInterfaces {
|
||||
supportPoE = true;
|
||||
interfaces = ports.poe;
|
||||
})
|
||||
// (mkInterfaces {
|
||||
supportPoE = false;
|
||||
interfaces = ports.regular;
|
||||
});
|
||||
netconf.mandatoryInterfaces = mkAllInterfaces ([ cfg.model ] ++ cfg.extensions);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue