67 lines
1.5 KiB
Nix
67 lines
1.5 KiB
Nix
{
|
|
name,
|
|
lib,
|
|
config,
|
|
...
|
|
}:
|
|
with lib;
|
|
let
|
|
mandatory.options = {
|
|
supportPoE = mkOption {
|
|
type = types.bool;
|
|
example = true;
|
|
description = ''
|
|
Wether this interface supports PoE.
|
|
'';
|
|
};
|
|
};
|
|
in
|
|
{
|
|
imports = [
|
|
./protocols.nix
|
|
./interfaces.nix
|
|
./vlans.nix
|
|
./poe.nix
|
|
];
|
|
options = {
|
|
netconf.xmls.configuration = mkOption {
|
|
type = types.str;
|
|
readOnly = true;
|
|
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).
|
|
'';
|
|
};
|
|
};
|
|
config.interfaces =
|
|
let
|
|
mkIntf = _: _: { };
|
|
in
|
|
mapAttrs mkIntf config.netconf.mandatoryInterfaces;
|
|
config.netconf.xmls.configuration = ''
|
|
<configuration>
|
|
${config.netconf.xmls.interfaces}
|
|
${config.netconf.xmls.protocols}
|
|
${config.netconf.xmls.vlans}
|
|
${config.netconf.xmls.poe}
|
|
</configuration>
|
|
'';
|
|
}
|