poe support
This commit is contained in:
parent
35682d1fc6
commit
64915f75de
2 changed files with 41 additions and 0 deletions
|
@ -10,6 +10,7 @@ with lib;
|
|||
./protocols.nix
|
||||
./interfaces.nix
|
||||
./vlans.nix
|
||||
./poe.nix
|
||||
];
|
||||
options = {
|
||||
netconf.xmls.configuration = mkOption {
|
||||
|
@ -31,6 +32,7 @@ with lib;
|
|||
${config.netconf.xmls.interfaces}
|
||||
${config.netconf.xmls.protocols}
|
||||
${config.netconf.xmls.vlans}
|
||||
${config.netconf.xmls.poe}
|
||||
</configuration>
|
||||
'';
|
||||
}
|
||||
|
|
39
junos/poe.nix
Normal file
39
junos/poe.nix
Normal 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>
|
||||
'';
|
||||
}
|
Loading…
Reference in a new issue