Commit f77c867f authored by Leigh B Stoller's avatar Leigh B Stoller

Fix up the convertPortsFromStrings function call; list arguments

should be the last argument, not the first. Confusing at best, broken
at worse.

Passing unconverted port string to RecordVLanModification; fixed.

If doMakeVlan(), if source and target are the same, do not delete the
ports from the source.
parent 0b35ebe0
......@@ -3061,7 +3061,8 @@ sub doMakeVlan($$@) {
}
if (!$errors) {
if (defined($source_vlan) && $source_vlan->KeepInSync()) {
if (defined($source_vlan) && !$source_vlan->SameVlan($target_vlan) &&
$source_vlan->KeepInSync()) {
# Yank the ports out of the old vlan.
foreach my $port (@ports) {
if ($source_vlan->DelPort($port)) {
......@@ -3071,7 +3072,7 @@ sub doMakeVlan($$@) {
}
VLan->RecordVLanModification($source_vlan->id(), undef, \@ports);
}
if (defined($target_vlan) && $target_vlan->KeepInSync()) {
if ($target_vlan->KeepInSync()) {
# This updates the port list, so always call it.
VLan->RecordVlanInsertion($target_vlan->id(), $stack->{STACKID});
}
......
......@@ -48,6 +48,7 @@ use Lan;
use strict;
use SNMP;
use Port;
use Carp qw(cluck);
my $TBOPS = libtestbed::TB_OPSEMAIL;
......@@ -147,10 +148,10 @@ sub convertPortFromString($;$)
return undef;
}
sub convertPortsFromStrings(@;$)
sub convertPortsFromStrings($@)
{
my (@strs, $dev) = @_;
my ($dev, @strs) = @_;
return grep(defined($_), map(convertPortFromString($_, $dev), @strs));
}
......
......@@ -461,7 +461,7 @@ if ($opt{B}) {
tbdie "No port given in status string";
}
if ($args{port}) {
push @ports, convertPortsFromStrings($args{port}, $optdev);
push @ports, convertPortsFromStrings($optdev, $args{port});
}
}
}
......@@ -638,7 +638,7 @@ if ($opt{y}) {
#
# Convert ports into the correct format
if (@ports) {
@ports = convertPortsFromStrings(@ports, $optdev);
@ports = convertPortsFromStrings($optdev, @ports);
if (scalar(@optports) != scalar(@ports)) {
die "Bad format for ports: ".join(" ", @optports)."\n";
}
......@@ -3097,7 +3097,8 @@ sub doMakeVlan($$@) {
}
if (!$errors) {
if (defined($source_vlan) && $source_vlan->KeepInSync()) {
if (defined($source_vlan) && !$source_vlan->SameVlan($target_vlan) &&
$source_vlan->KeepInSync()) {
# Yank the ports out of the old vlan.
foreach my $port (@ports) {
if ($source_vlan->DelPort($port)) {
......@@ -3106,7 +3107,7 @@ sub doMakeVlan($$@) {
}
}
my @tports = map {$_->toIfaceString()} @ports;
VLan->RecordVLanModification($source_vlan->id(), undef, \@ports);
VLan->RecordVLanModification($source_vlan->id(), undef, \@tports);
}
if (defined($target_vlan) && $target_vlan->KeepInSync()) {
# This updates the port list, so always call it.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment