poe support

This commit is contained in:
catvayor 2024-08-31 18:54:15 +02:00
parent 35682d1fc6
commit 64915f75de
Signed by: lbailly
GPG key ID: CE3E645251AC63F3
2 changed files with 41 additions and 0 deletions

View file

@ -10,6 +10,7 @@ with lib;
./protocols.nix ./protocols.nix
./interfaces.nix ./interfaces.nix
./vlans.nix ./vlans.nix
./poe.nix
]; ];
options = { options = {
netconf.xmls.configuration = mkOption { netconf.xmls.configuration = mkOption {
@ -31,6 +32,7 @@ with lib;
${config.netconf.xmls.interfaces} ${config.netconf.xmls.interfaces}
${config.netconf.xmls.protocols} ${config.netconf.xmls.protocols}
${config.netconf.xmls.vlans} ${config.netconf.xmls.vlans}
${config.netconf.xmls.poe}
</configuration> </configuration>
''; '';
} }

39
junos/poe.nix Normal file
View file

@ -0,0 +1,39 @@
{ lib, config, ... }:
with lib;
let
interface-module =
{ name, config, ... }:
{
options = {
enable = mkEnableOption "The PoE for interface ${name}.";
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 = { };
};
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>
'';
}