feat(lib): Init netconf-junos
The code is copied from netconf-module, `with lib;` have been replaced by inherits
This commit is contained in:
parent
1980d3c34e
commit
318f6927c1
6 changed files with 546 additions and 0 deletions
49
lib/netconf-junos/poe.nix
Normal file
49
lib/netconf-junos/poe.nix
Normal file
|
@ -0,0 +1,49 @@
|
|||
{ config, lib, ... }:
|
||||
|
||||
let
|
||||
inherit (lib)
|
||||
mapAttrsToList
|
||||
mkEnableOption
|
||||
mkOption
|
||||
optionalString
|
||||
;
|
||||
|
||||
inherit (lib.types) attrsOf str submodule;
|
||||
|
||||
interface-module =
|
||||
{ name, config, ... }:
|
||||
{
|
||||
options = {
|
||||
enable = mkEnableOption "the PoE for this interface";
|
||||
xml = mkOption {
|
||||
type = str;
|
||||
visible = false;
|
||||
readOnly = true;
|
||||
};
|
||||
};
|
||||
config.xml = ''
|
||||
<interface><name>${name}</name>${optionalString (!config.enable) "<disable/>"}</interface>
|
||||
'';
|
||||
};
|
||||
in
|
||||
{
|
||||
options = {
|
||||
poe.interfaces = mkOption {
|
||||
type = attrsOf (submodule interface-module);
|
||||
default = { };
|
||||
description = ''
|
||||
PoE configuration of interfaces.
|
||||
'';
|
||||
};
|
||||
netconf.xmls.poe = mkOption {
|
||||
type = str;
|
||||
visible = false;
|
||||
readOnly = true;
|
||||
};
|
||||
};
|
||||
config.netconf.xmls.poe = ''
|
||||
<poe operation="replace">
|
||||
${builtins.concatStringsSep "" (mapAttrsToList (_: intf: intf.xml) config.poe.interfaces)}
|
||||
</poe>
|
||||
'';
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue