Netconf-Module/junos/poe.nix

43 lines
969 B
Nix
Raw Normal View History

2024-08-31 18:54:15 +02:00
{ lib, config, ... }:
with lib;
let
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 {
type = types.str;
visible = false;
readOnly = true;
};
};
config.xml = ''
<interface><name>${name}</name>${optionalString (!config.enable) "<disable/>"}</interface>
'';
};
in
{
options = {
poe.interfaces = mkOption {
type = types.attrsOf (types.submodule interface-module);
default = { };
2024-09-03 23:04:30 +02:00
description = ''
PoE configuration of interfaces.
'';
2024-08-31 18:54:15 +02:00
};
netconf.xmls.poe = mkOption {
type = types.str;
visible = false;
readOnly = true;
};
};
config.netconf.xmls.poe = ''
<poe operation="replace">
${
builtins.concatStringsSep "" (attrsets.mapAttrsToList (_: intf: intf.xml) config.poe.interfaces)
}
</poe>
'';
}