static ip mgmt

This commit is contained in:
catvayor 2024-04-04 18:17:36 +02:00
parent c8fd1d84e7
commit 5741324cb7
2 changed files with 11 additions and 5 deletions

View file

@ -29,7 +29,7 @@ let module_inst = {
"me0" = { # mgmt "me0" = { # mgmt
enable = true; enable = true;
management = true; management = "192.168.42.6/24";
}; };
}; };
vlans = { vlans = {

View file

@ -29,8 +29,9 @@ in with lib; {
default = false; default = false;
}; };
management = mkOption { management = mkOption {
type = types.bool; # FIXME : support ipv4 and ipv6, either static or dhcp (with the coffee)
default = false; type = types.nullOr types.str;
default = null;
}; };
}; };
in builtins.listToAttrs (map (name: { inherit name; value = template name; }) interfaces); in builtins.listToAttrs (map (name: { inherit name; value = template name; }) interfaces);
@ -46,7 +47,12 @@ in with lib; {
intf_xmlGen = name: let intf_xmlGen = name: let
disable_flag = if !cfg.interfaces.${name}.enable then "<disable/>" else ""; disable_flag = if !cfg.interfaces.${name}.enable then "<disable/>" else "";
# FIXME : need to enforce address in reality # FIXME : need to enforce address in reality
mgmt_fam = if cfg.interfaces.${name}.management then "<inet><dhcp/></inet>" else ""; mgmt_fam = if !builtins.isNull cfg.interfaces.${name}.management then ''
<inet>
<address>
${cfg.interfaces.${name}.management}
</address>
</inet>'' else "";
members = map (vlan: "<members>${builtins.toString vlan}</members>") cfg.interfaces.${name}.vlans; members = map (vlan: "<members>${builtins.toString vlan}</members>") cfg.interfaces.${name}.vlans;
eth_switch = if builtins.isNull cfg.interfaces.${name}.interface-mode then "" else '' eth_switch = if builtins.isNull cfg.interfaces.${name}.interface-mode then "" else ''
<ethernet-switching> <ethernet-switching>
@ -68,7 +74,7 @@ in with lib; {
interface_xmls = map intf_xmlGen interfaces; interface_xmls = map intf_xmlGen interfaces;
vlan_trust_table = let vlan_trust_table = let
vlan_map = inter: vlan: vlan_map = inter: vlan:
if builtins.isString vlan then if builtins.isString vlan && cfg.interfaces.${inter}.enable then
if cfg.interfaces.${inter}.dhcp_trusted then if cfg.interfaces.${inter}.dhcp_trusted then
{ ${vlan}.trust = inter; } { ${vlan}.trust = inter; }
else else