feat(rstp): made an option

This commit is contained in:
catvayor 2024-12-02 15:45:56 +01:00
parent 2a16d196f7
commit 8345a8ee12
Signed by: lbailly
GPG key ID: CE3E645251AC63F3
2 changed files with 9 additions and 5 deletions

View file

@ -2,7 +2,7 @@
with lib;
let
intf-mod =
{ name, config, ... }:
{ config, ... }:
{
options = {
enable = mkEnableOption "this interface" // {
@ -15,6 +15,10 @@ let
default = config.ethernet-switching.interface-mode != null;
defaultText = ''config.ethernet-switching.interface-mode != null'';
};
rstp = mkEnableOption "RSTP on this interface" // {
default = config.ethernet-switching.enable;
defaultText = ''config.ethernet-switching.enable'';
};
interface-mode = mkOption {
type = types.nullOr (
types.enum [
@ -69,7 +73,6 @@ let
};
cfg = config.dgn-interfaces;
intf-list = config.netconf.mandatoryInterfaces;
in
{
options.dgn-interfaces = mkOption {
@ -88,12 +91,12 @@ in
inherit (intf) enable;
unit."0".family = {
inherit (intf) inet inet6;
ethernet-switching = mkIf intf.ethernet-switching.enable intf.ethernet-switching;
ethernet-switching = mkIf intf.ethernet-switching.enable (removeAttrs intf.ethernet-switching [ "rstp" ]);
};
}) cfg;
poe.interfaces = filterAttrs (
name: _: config.netconf.mandatoryInterfaces.${name}.supportPoE or false
) (mapAttrs (_: intf: { enable = intf.poe; }) cfg);
protocols.rstp = attrNames (filterAttrs (_: intf: intf.ethernet-switching.enable) cfg);
protocols.rstp = attrNames (filterAttrs (_: intf: intf.ethernet-switching.rstp) cfg);
};
}

View file

@ -75,7 +75,8 @@ in
# uplink oob
"ge-0/0/46".ethernet-switching = {
interface-mode = "access";
vlans = [ 500 ];
vlans = [ 222 ];
rstp = false;
};
# ilo
"ge-0/0/47".ethernet-switching = {