From 29820ff808c7b52cbe4e38424f3b5ef6a3b21d84 Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Fri, 7 Jul 2017 18:31:13 -0400 Subject: [PATCH 1/3] Support hybrid mode for different access vlan other than 1 --- xCAT-server/share/xcat/scripts/configMellanox | 41 ++++++++++++++----- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/xCAT-server/share/xcat/scripts/configMellanox b/xCAT-server/share/xcat/scripts/configMellanox index 43dc783b7..36d313996 100755 --- a/xCAT-server/share/xcat/scripts/configMellanox +++ b/xCAT-server/share/xcat/scripts/configMellanox @@ -43,7 +43,8 @@ if ( 'ip' => \$::IP, 'name' => \$::NAME, 'snmp' => \$::SNMP, - 'vlan=s' => \$::VLAN, + 'accessvlan=s' => \$::PVID, + 'allowvlan=s' => \$::VID, 'port=s' => \$::PORT, 'mode=s' => \$::MODE, 'all' => \$::ALL, @@ -120,7 +121,7 @@ if (($::CONFIG) || ($::ALL)) { run_rspconfig(); } -if ($::VLAN) { +if ( ($::PVID) || ($::VID) ) { config_vlan(); } @@ -363,6 +364,9 @@ sub config_vlan { exit(1); } + my $access_vlan = $::PVID; + my $allowed_vlan = $::VID; + # will default to trunk mode if ($::MODE) { $mode = $::MODE; @@ -372,11 +376,18 @@ sub config_vlan { &usage; exit(1); } + if ($mode =~ /hybrid/) + { + if (!$access_vlan) { + print "NOTE: Hybrid mode will change access vlan back to 1\n"; + print "please provide access vlan if other than 1\n"; + $access_vlan = 1; + } + } } else { $mode = "access"; } - $vlan = $::VLAN; foreach my $switch (@nodes) { my $devicetype; @@ -394,10 +405,7 @@ sub config_vlan { next; } - print "Tagging VLAN=$vlan for $switch port $port_input\n"; - - # create vlan - my $vlan_cmd = `xdsh $switch --devicetype $devicetype "enable;configure terminal;vlan $vlan;exit;exit" `; + print "Tagging access vlan to $access_vlan and allowed vlan to $allowed_vlan with $mode mode for $switch port $port_input\n"; my $cmd_prefix = "xdsh $switch --devicetype $devicetype"; foreach my $port (@ports) { @@ -405,12 +413,23 @@ sub config_vlan { # Build up the commands for easier readability $cmd = $cmd . "enable\;"; $cmd = $cmd . "configure terminal\;"; + if ($access_vlan){ + $cmd = $cmd . "vlan $access_vlan\;"; + $cmd = $cmd . "exit\;"; + } + if ($allowed_vlan){ + $cmd = $cmd . "vlan $allowed_vlan\;"; + $cmd = $cmd . "exit\;"; + } $cmd = $cmd . "interface ethernet 1/$port\;"; $cmd = $cmd . "switchport mode $mode\;"; if ($mode =~ /access/) { - $cmd = $cmd . "switchport access vlan $vlan\;"; + $cmd = $cmd . "switchport access vlan $access_vlan\;"; + } elsif ($mode =~ /hybrid/) { + $cmd = $cmd . "switchport $mode allowed-vlan $allowed_vlan\;"; + $cmd = $cmd . "switchport access vlan $access_vlan\;"; } else { - $cmd = $cmd . "switchport $mode allowed-vlan $vlan\;"; + $cmd = $cmd . "switchport $mode allowed-vlan $allowed_vlan\;"; } $cmd = $cmd . "exit\;exit\;exit\;"; my $final_cmd = $cmd_prefix . " \"" . $cmd . "\""; @@ -445,10 +464,10 @@ sub usage configMellanox --switches switchnames --config To configure VLAN on a specified port (Mellanox Ethernet switch ONLY): - configMellanox --switches switchnames --port port --vlan vlan --mode mode + configMellanox --switches switchnames --port port --accessvlan vlan1 --allowvlan vlan2 --mode mode The following mode are supported for switchport: - * access Only untagged ingress Ethernet packets are allowed + * access Only untagged ingress Ethernet packets are allowed * trunk Only tagged ingress Ethernet packets are allowed * hybrid Both tagged and untagged ingress Ethernet packets are allowed * access-dcb Only untagged ingress Ethernet packets are allowed. Egress packets will be priority tagged From f52c9cf041018bcd117fda552850ab024bf81db2 Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Thu, 13 Jul 2017 13:48:31 -0400 Subject: [PATCH 2/3] change vlan to VLAN --- xCAT-server/share/xcat/scripts/configMellanox | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/xCAT-server/share/xcat/scripts/configMellanox b/xCAT-server/share/xcat/scripts/configMellanox index 36d313996..2b7b0f224 100755 --- a/xCAT-server/share/xcat/scripts/configMellanox +++ b/xCAT-server/share/xcat/scripts/configMellanox @@ -379,8 +379,9 @@ sub config_vlan { if ($mode =~ /hybrid/) { if (!$access_vlan) { - print "NOTE: Hybrid mode will change access vlan back to 1\n"; - print "please provide access vlan if other than 1\n"; + print "NOTE: Hybrid mode will change access VLAN back to 1\n"; + print "If other than 1, run the command again with access VLAN number: \n" + print " configMellanox --switches switchnames --port port --accessvlan vlan1 --allowvlan vlan2 --mode mode\n"; $access_vlan = 1; } } @@ -405,7 +406,7 @@ sub config_vlan { next; } - print "Tagging access vlan to $access_vlan and allowed vlan to $allowed_vlan with $mode mode for $switch port $port_input\n"; + print "Tagging access VLAN to $access_vlan and allowed VLAN to $allowed_vlan with $mode mode for $switch port $port_input\n"; my $cmd_prefix = "xdsh $switch --devicetype $devicetype"; foreach my $port (@ports) { From 749d3d54a36d8626a39a855951d145365ad81ebe Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Thu, 13 Jul 2017 14:19:15 -0400 Subject: [PATCH 3/3] syntax error --- xCAT-server/share/xcat/scripts/configMellanox | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/scripts/configMellanox b/xCAT-server/share/xcat/scripts/configMellanox index 2b7b0f224..b92dd57d0 100755 --- a/xCAT-server/share/xcat/scripts/configMellanox +++ b/xCAT-server/share/xcat/scripts/configMellanox @@ -380,7 +380,7 @@ sub config_vlan { { if (!$access_vlan) { print "NOTE: Hybrid mode will change access VLAN back to 1\n"; - print "If other than 1, run the command again with access VLAN number: \n" + print "If other than 1, run the command again with access VLAN number: \n"; print " configMellanox --switches switchnames --port port --accessvlan vlan1 --allowvlan vlan2 --mode mode\n"; $access_vlan = 1; }