Netconf-Module/junos/default.nix

68 lines
1.5 KiB
Nix
Raw Normal View History

2024-04-30 20:08:07 +02:00
{
name,
lib,
config,
...
}:
with lib;
2024-08-31 22:37:30 +02:00
let
mandatory.options = {
supportPoE = mkOption {
type = types.bool;
2024-09-03 23:04:30 +02:00
example = true;
description = ''
Wether this interface supports PoE.
'';
2024-08-31 22:37:30 +02:00
};
};
in
2024-04-30 20:08:07 +02:00
{
imports = [
./protocols.nix
./interfaces.nix
./vlans.nix
2024-08-31 18:54:15 +02:00
./poe.nix
2024-04-30 20:08:07 +02:00
];
options = {
netconf.xmls.configuration = mkOption {
type = types.str;
readOnly = true;
2024-09-03 23:04:30 +02:00
description = ''
The full configuration to send to a JunOS.
'';
};
netconf.mandatoryInterfaces = mkOption {
type = types.attrsOf (types.submodule mandatory);
example = {
"ge-0/0/0" = {
supportPoE = true;
};
"ge-0/0/1" = {
supportPoE = true;
};
"xe-0/0/0" = {
supportPoE = false;
};
};
description = ''
JunOS require some interfaces to always be configured (even if they are disabled),
which correspond to physical interfaces of the switch. They have to be declared here
with some information about it (only if it supports PoE for now).
'';
2024-04-30 20:08:07 +02:00
};
};
config.interfaces =
let
2024-09-04 09:47:52 +02:00
mkIntf = _: _: { };
2024-04-30 20:08:07 +02:00
in
2024-08-31 22:37:30 +02:00
mapAttrs mkIntf config.netconf.mandatoryInterfaces;
2024-04-30 20:08:07 +02:00
config.netconf.xmls.configuration = ''
2024-05-22 13:33:28 +02:00
<configuration>
${config.netconf.xmls.interfaces}
${config.netconf.xmls.protocols}
${config.netconf.xmls.vlans}
2024-08-31 18:54:15 +02:00
${config.netconf.xmls.poe}
2024-05-22 13:33:28 +02:00
</configuration>
'';
2024-04-30 20:08:07 +02:00
}