fix(netconf/dgn-hardware): Some models are extension cards

This commit is contained in:
Tom Hubrecht 2024-12-09 11:27:10 +01:00
parent fbfb22d777
commit 9024590a34
Signed by: thubrecht
SSH key fingerprint: SHA256:CYNvFo44Ar9qCNnWNnvJVhs0QXO9AZjOLlPeWcSij3Q

View file

@ -3,7 +3,7 @@
let let
inherit (lib) genList mkOption listToAttrs; inherit (lib) genList mkOption listToAttrs;
inherit (lib.types) enum; inherit (lib.types) enum listOf;
range = prefix: genList (port: "${prefix}${builtins.toString port}"); range = prefix: genList (port: "${prefix}${builtins.toString port}");
mkInterfaces = mkInterfaces =
@ -17,6 +17,24 @@ let
}) interfaces }) 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; cfg = config.dgn-hardware;
in in
@ -27,26 +45,24 @@ in
"EX2300-48P" "EX2300-48P"
"EX4100-F-48P" "EX4100-F-48P"
"EX4400-24X" "EX4400-24X"
"EX4400-EM-4Y"
]; ];
description = '' description = ''
The exact model of the switch to configure. 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 = { config = {
netconf.mandatoryInterfaces = netconf.mandatoryInterfaces = mkAllInterfaces ([ cfg.model ] ++ cfg.extensions);
let
ports = import ./. + "${cfg.model}.nix" range;
in
(mkInterfaces {
supportPoE = true;
interfaces = ports.poe;
})
// (mkInterfaces {
supportPoE = false;
interfaces = ports.regular;
});
}; };
} }