diff --git a/nix/pkgs/switches/3com-4200G.nix b/nix/pkgs/switches/3com-4200G.nix index 0171653..b132c07 100644 --- a/nix/pkgs/switches/3com-4200G.nix +++ b/nix/pkgs/switches/3com-4200G.nix @@ -54,23 +54,27 @@ with lib; builtins.split "/" netConfig.subnet4 ) 2; netmask = self.lib.netmasks.${prefixLength}; - in '' - send "vlan ${vlan}\r" - expect -- "-vlan${vlan}]" - send "name ${net}\r" - expect -- "-vlan${vlan}]" - ${optionalString (net == "mgmt") '' - # Actually only used for mgmt_vlan, switches are not routers - send "interface Vlan-interface ${vlan}\r" - expect "]" - ${optionalString (hosts4 ? ${hostName}) '' - send "ip address ${hostAddr4} ${netmask}\r" + in + if netConfig.vlan != null + then '' + send "vlan ${vlan}\r" + expect -- "-vlan${vlan}]" + send "name ${net}\r" + expect -- "-vlan${vlan}]" + ${optionalString (net == "mgmt") '' + # Actually only used for mgmt_vlan, switches are not routers + send "interface Vlan-interface ${vlan}\r" expect "]" + ${optionalString (hosts4 ? ${hostName}) '' + send "ip address ${hostAddr4} ${netmask}\r" + expect "]" + ''} ''} - ''} - send "quit\r" - expect "${hostName}]" - '') (sortNetsByVlan (builtins.attrNames config.site.net)) + send "quit\r" + expect "${hostName}]" + '' + else "" + ) (sortNetsByVlan (builtins.attrNames config.site.net)) } ${concatMapStrings (name: diff --git a/nix/pkgs/switches/HP-procurve-2824.nix b/nix/pkgs/switches/HP-procurve-2824.nix index 16235d2..97c0121 100644 --- a/nix/pkgs/switches/HP-procurve-2824.nix +++ b/nix/pkgs/switches/HP-procurve-2824.nix @@ -37,7 +37,7 @@ with lib; send "logging facility local6\r" expect "(config)# " - # todo ntp + # TODO ntp # timesync sntp # ip timep manual {#ntp#} interval 10 @@ -51,38 +51,42 @@ with lib; builtins.split "/" netConfig.subnet4 ) 2; netmask = self.lib.netmasks.${prefixLength}; - in '' - send "vlan ${vlan}\r" - expect "(vlan-${vlan})#" - - send "name ${net}\r" - expect "(vlan-${vlan})#" - - send "jumbo\r" - expect "(vlan-${vlan})#" - - ${optionalString (hosts4 ? ${hostName}) '' - # Actually only used for mgmt_vlan, switches are not routers - send "ip address ${hostAddr4} ${netmask}\r" - expect "(vlan-${vlan})#" - ''} - - send "exit\r" - expect "(config)# " - - ${if net == "mgmt" + in + if netConfig.vlan != null then '' - send "management-vlan ${vlan}\r" + send "vlan ${vlan}\r" + expect "(vlan-${vlan})#" + + send "name ${net}\r" + expect "(vlan-${vlan})#" + + send "jumbo\r" + expect "(vlan-${vlan})#" + + ${optionalString (hosts4 ? ${hostName}) '' + # Actually only used for mgmt_vlan, switches are not routers + send "ip address ${hostAddr4} ${netmask}\r" + expect "(vlan-${vlan})#" + ''} + + send "exit\r" expect "(config)# " - '' else '' - # If not mgmt, reset all VLAN mappings - send "no vlan ${vlan} tagged all\r" - expect "(config)# " - send "no vlan ${vlan} untagged all\r" - expect "(config)# " - ''} - '') (sortNetsByVlan (builtins.attrNames config.site.net)) - } + + ${if net == "mgmt" + then '' + send "management-vlan ${vlan}\r" + expect "(config)# " + '' else '' + # If not mgmt, reset all VLAN mappings + send "no vlan ${vlan} tagged all\r" + expect "(config)# " + send "no vlan ${vlan} untagged all\r" + expect "(config)# " + ''} + '' + else "" + ) (sortNetsByVlan (builtins.attrNames config.site.net)) + } ${concatMapStrings (name: let diff --git a/nix/pkgs/switches/TL-SG3210.nix b/nix/pkgs/switches/TL-SG3210.nix index 2c53b10..a76a90d 100644 --- a/nix/pkgs/switches/TL-SG3210.nix +++ b/nix/pkgs/switches/TL-SG3210.nix @@ -60,26 +60,29 @@ with lib; builtins.split "/" netConfig.subnet4 ) 2; netmask = self.lib.netmasks.${prefixLength}; - in '' - ${optionalString (net != "mgmt") '' - send "vlan ${vlan}\r" - expect "(config-vlan)#" - send "name \"${net}\"\r" - expect "(config-vlan)#" + in + if netConfig.vlan != null + then '' + ${optionalString (net != "mgmt") '' + send "vlan ${vlan}\r" + expect "(config-vlan)#" + send "name \"${net}\"\r" + expect "(config-vlan)#" + send "exit\r" + expect "(config)#" + ''} + + send "interface vlan ${vlan}\r" + expect "(config-if)#" + ${optionalString (hosts4 ? ${hostName}) '' + # Actually only used for mgmt_vlan, switches are not routers + send "ip address ${hostAddr4} ${netmask}\r" + expect "(config-if)#" + ''} send "exit\r" expect "(config)#" - ''} - - send "interface vlan ${vlan}\r" - expect "(config-if)#" - ${optionalString (hosts4 ? ${hostName}) '' - # Actually only used for mgmt_vlan, switches are not routers - send "ip address ${hostAddr4} ${netmask}\r" - expect "(config-if)#" - ''} - send "exit\r" - expect "(config)#" - '' + '' + else "" ) (sortNetsByVlan (builtins.attrNames config.site.net))} ${concatMapStrings (name: diff --git a/nix/pkgs/switches/linksys-srw2048.nix b/nix/pkgs/switches/linksys-srw2048.nix index 7cf0b0d..daff0b2 100644 --- a/nix/pkgs/switches/linksys-srw2048.nix +++ b/nix/pkgs/switches/linksys-srw2048.nix @@ -33,21 +33,35 @@ with lib; send "vlan database\r" expect "(config-vlan)# " - ${concatMapStrings (net: '' - send "vlan ${toString config.site.net.${net}.vlan}\r" - expect "(config-vlan)#" - '') (sortNetsByVlan (builtins.attrNames config.site.net))} + ${concatMapStrings (net: + let + netConfig = config.site.net.${net}; + in + if netConfig.vlan != null + then '' + send "vlan ${toString netConfig.vlan}\r" + expect "(config-vlan)#" + '' + else "" + ) (sortNetsByVlan (builtins.attrNames config.site.net))} send "exit\r" expect "(config)#" - ${concatMapStrings (net: '' - send "interface vlan ${toString config.site.net.${net}.vlan}\r" - expect "(config-if)#" - send "name ${net}\r" - expect "(config-if)#" - send "exit\r" - expect "(config)#" - '') (sortNetsByVlan (builtins.attrNames config.site.net))} + ${concatMapStrings (net: + let + netConfig = config.site.net.${net}; + in + if netConfig.vlan != null + then '' + send "interface vlan ${toString config.site.net.${net}.vlan}\r" + expect "(config-if)#" + send "name ${net}\r" + expect "(config-if)#" + send "exit\r" + expect "(config)#" + '' + else "" + ) (sortNetsByVlan (builtins.attrNames config.site.net))} ${concatMapStrings (name: let