making it work
strange behaviors to explore, and deployement shell script todo
This commit is contained in:
parent
e7d1abfae3
commit
be2534386a
2 changed files with 23 additions and 7 deletions
|
@ -35,7 +35,7 @@ let module_inst = {
|
|||
vlans = {
|
||||
"users".ids = [ { begin = 3045; end = 4094; } ];
|
||||
"admin" = {
|
||||
ids = [ 3000 ];
|
||||
ids = 3000;
|
||||
management = "10.0.0.2/22";
|
||||
};
|
||||
"uplink-cri".ids = [ 223 ];
|
||||
|
|
|
@ -10,7 +10,9 @@ in with lib; {
|
|||
};
|
||||
vlan_type.options = {
|
||||
ids = mkOption {
|
||||
type = types.listOf (types.either types.ints.unsigned (types.submodule range_type));
|
||||
type = types.either
|
||||
types.ints.unsigned
|
||||
(types.listOf (types.either types.ints.unsigned (types.submodule range_type)));
|
||||
default = [ ];
|
||||
};
|
||||
management = mkOption {
|
||||
|
@ -65,7 +67,7 @@ in with lib; {
|
|||
mgmt_fam = if !builtins.isNull cfg.interfaces.${name}.management then ''
|
||||
<inet>
|
||||
<address>
|
||||
${cfg.interfaces.${name}.management}
|
||||
<name>${cfg.interfaces.${name}.management}</name>
|
||||
</address>
|
||||
</inet>'' else "";
|
||||
members = map (vlan: "<members>${builtins.toString vlan}</members>") cfg.interfaces.${name}.vlans;
|
||||
|
@ -73,6 +75,7 @@ in with lib; {
|
|||
<ethernet-switching>
|
||||
<interface-mode>${cfg.interfaces.${name}.interface-mode}</interface-mode>
|
||||
<vlan>${builtins.concatStringsSep "" members}</vlan>
|
||||
<storm-control><profile-name>default</profile-name></storm-control>
|
||||
</ethernet-switching>'';
|
||||
in ''
|
||||
<interface>
|
||||
|
@ -85,8 +88,14 @@ in with lib; {
|
|||
${eth_switch}
|
||||
</family>
|
||||
</unit>
|
||||
</interface>'';
|
||||
</interface>
|
||||
'';
|
||||
interface_xmls = map intf_xmlGen interfaces;
|
||||
rstp_gen = name:
|
||||
if cfg.interfaces.${name}.enable && !builtins.isNull cfg.interfaces.${name}.interface-mode then
|
||||
"<interface><name>${name}</name></interface>"
|
||||
else "";
|
||||
rstps = map rstp_gen interfaces;
|
||||
vlan_trust_table = let
|
||||
vlan_map = inter: vlan:
|
||||
if builtins.isString vlan && cfg.interfaces.${inter}.enable then
|
||||
|
@ -109,7 +118,9 @@ in with lib; {
|
|||
"${builtins.toString id.begin}-${builtins.toString id.end}";
|
||||
in ''<vlan-id-list>${list}</vlan-id-list>'';
|
||||
vlan_map = vlan: let
|
||||
ids = map id_map cfg.vlans.${vlan}.ids;
|
||||
ids = if !builtins.isList cfg.vlans.${vlan}.ids then
|
||||
[ "<vlan-id>${builtins.toString cfg.vlans.${vlan}.ids}</vlan-id>" ]
|
||||
else map id_map cfg.vlans.${vlan}.ids;
|
||||
mgmt_flag = if !builtins.isNull cfg.vlans.${vlan}.management
|
||||
then "<l3-interface>irb.0</l3-interface>" else "";
|
||||
in ''
|
||||
|
@ -137,11 +148,16 @@ in with lib; {
|
|||
''
|
||||
else "";
|
||||
in [ ''
|
||||
<interfaces>
|
||||
<interfaces operation="replace">
|
||||
${builtins.concatStringsSep "\n" interface_xmls}
|
||||
${irb_intf}
|
||||
</interfaces>
|
||||
<vlans>
|
||||
<protocols>
|
||||
<rstp operation="replace">
|
||||
${builtins.concatStringsSep "\n" rstps}
|
||||
</rstp>
|
||||
</protocols>
|
||||
<vlans operation="replace">
|
||||
${builtins.concatStringsSep "\n" vlans}
|
||||
</vlans>'' vlan_trust_table
|
||||
];
|
||||
|
|
Loading…
Reference in a new issue