Netconf-Module/junos/poe.nix

47 lines
911 B
Nix
Raw Permalink Normal View History

2024-12-13 16:03:36 +01:00
{ lib, config, xml, ... }:
2024-08-31 18:54:15 +02:00
let
2024-12-13 14:37:43 +01:00
inherit (lib)
mkOption
mkEnableOption
mapAttrsToList
2024-12-13 16:03:36 +01:00
mkIf
mkMerge
2024-12-13 14:37:43 +01:00
;
inherit (lib.types)
attrsOf
submodule
;
2024-08-31 18:54:15 +02:00
interface-module =
{ name, config, ... }:
{
options = {
2024-09-03 23:04:30 +02:00
enable = mkEnableOption "the PoE for this interface";
2024-08-31 18:54:15 +02:00
xml = mkOption {
2024-12-13 16:03:36 +01:00
type = xml.type;
2024-08-31 18:54:15 +02:00
visible = false;
readOnly = true;
};
};
2024-12-13 16:03:36 +01:00
config.xml = mkMerge [
{ inherit name; }
(mkIf (!config.enable) { disable = { }; })
];
2024-08-31 18:54:15 +02:00
};
in
{
options = {
poe.interfaces = mkOption {
2024-12-13 14:37:43 +01:00
type = attrsOf (submodule interface-module);
2024-08-31 18:54:15 +02:00
default = { };
2024-09-03 23:04:30 +02:00
description = ''
PoE configuration of interfaces.
'';
2024-08-31 18:54:15 +02:00
};
};
2024-12-13 16:03:36 +01:00
config.netconf.xml.poe = {
"@operation" = "replace";
interface = mapAttrsToList (_: intf: intf.xml) config.poe.interfaces;
};
2024-08-31 18:54:15 +02:00
}