2024-04-30 20:08:07 +02:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
...
|
|
|
|
}:
|
2024-08-31 22:37:30 +02:00
|
|
|
let
|
2024-12-13 14:37:43 +01:00
|
|
|
inherit (lib)
|
|
|
|
mkOption
|
|
|
|
mapAttrs
|
|
|
|
;
|
|
|
|
inherit (lib.types)
|
|
|
|
bool
|
|
|
|
str
|
|
|
|
attrsOf
|
|
|
|
submodule
|
|
|
|
;
|
2024-08-31 22:37:30 +02:00
|
|
|
mandatory.options = {
|
|
|
|
supportPoE = mkOption {
|
2024-12-13 14:37:43 +01:00
|
|
|
type = 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-12-08 09:39:51 +01:00
|
|
|
./system.nix
|
2024-04-30 20:08:07 +02:00
|
|
|
];
|
|
|
|
options = {
|
|
|
|
netconf.xmls.configuration = mkOption {
|
2024-12-13 14:37:43 +01:00
|
|
|
type = str;
|
2024-04-30 20:08:07 +02:00
|
|
|
readOnly = true;
|
2024-09-03 23:04:30 +02:00
|
|
|
description = ''
|
|
|
|
The full configuration to send to a JunOS.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
netconf.mandatoryInterfaces = mkOption {
|
2024-12-13 14:37:43 +01:00
|
|
|
type = attrsOf (submodule mandatory);
|
2024-09-03 23:04:30 +02:00
|
|
|
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>
|
2024-12-08 09:39:51 +01:00
|
|
|
${config.netconf.xmls.system}
|
2024-05-22 13:33:28 +02:00
|
|
|
${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
|
|
|
}
|