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

Allow -X option to operate on a specific vlan in the experiment.

parent 3f7b2fd6
...@@ -44,7 +44,7 @@ sub doListPorts($); ...@@ -44,7 +44,7 @@ sub doListPorts($);
sub doPortStatus($@); sub doPortStatus($@);
sub doGetStats($); sub doGetStats($);
sub doVlansFromTables($$@); sub doVlansFromTables($$@);
sub syncVlansFromTables($$); sub syncVlansFromTables($$@);
sub doSyncVlansWithDB($); sub doSyncVlansWithDB($);
sub doReset($@); sub doReset($@);
sub doMakeVlan($$@); sub doMakeVlan($$@);
...@@ -860,14 +860,14 @@ COMMAND: foreach my $command (@commands) { ...@@ -860,14 +860,14 @@ COMMAND: foreach my $command (@commands) {
(/synctables/) && do { (/synctables/) && do {
# We operate on all stacks on which we think VLANs do, or should, # We operate on all stacks on which we think VLANs do, or should,
# exist. # exist.
my @newvlans = getExperimentVlans($pid,$eid,@optvlanids); @vlans = getExperimentVlans($pid,$eid,@optvlanids);
my @oldvlans; my @oldvlans;
VLan->StaleVlanList($experiment,\@oldvlans); VLan->StaleVlanList($experiment,\@oldvlans);
# #
# No old or new vlans, then skip all of this. # No old or new vlans, then skip all of this.
# #
if (! (@newvlans || @oldvlans)) { if (! (@vlans || @oldvlans)) {
print "snmpit: $pid/$eid has no old or new VLANs ... ". print "snmpit: $pid/$eid has no old or new VLANs ... ".
"skipping\n"; "skipping\n";
next COMMAND; next COMMAND;
...@@ -877,7 +877,7 @@ COMMAND: foreach my $command (@commands) { ...@@ -877,7 +877,7 @@ COMMAND: foreach my $command (@commands) {
die("-X and -i cannot be used together\n"); die("-X and -i cannot be used together\n");
} }
else { else {
@devicenames = uniq(mapVlansToSwitches(@newvlans), @devicenames = uniq(mapVlansToSwitches(@vlans),
mapStaleVlansToSwitches(@oldvlans)); mapStaleVlansToSwitches(@oldvlans));
debug("Sync: list from database: " . join(",",@devicenames) . debug("Sync: list from database: " . join(",",@devicenames) .
"\n"); "\n");
...@@ -1169,7 +1169,7 @@ COMMAND: foreach my $command (@commands) { ...@@ -1169,7 +1169,7 @@ COMMAND: foreach my $command (@commands) {
last; last;
}; # /reservetags/ && do }; # /reservetags/ && do
/synctables/ && do { /synctables/ && do {
$exitval += syncVlansFromTables($experiment,\@stacks); $exitval += syncVlansFromTables($experiment,\@stacks,@vlans);
last; last;
}; # /tables/ && do }; # /tables/ && do
/reset/ && do { /reset/ && do {
...@@ -2244,9 +2244,10 @@ sub doReset($@) { ...@@ -2244,9 +2244,10 @@ sub doReset($@) {
# Sync vlans from the DB for a single experiment. This is a swapmod helper # Sync vlans from the DB for a single experiment. This is a swapmod helper
# to avoid churning the switches. # to avoid churning the switches.
# #
sub syncVlansFromTables($$) { sub syncVlansFromTables($$@) {
my $experiment = shift; my $experiment = shift;
my $stacks = shift; my $stacks = shift;
my @vlanids = @_;
my %expvlans = (); my %expvlans = ();
my %curvlans = (); my %curvlans = ();
my %stale = (); my %stale = ();
...@@ -2269,14 +2270,16 @@ sub syncVlansFromTables($$) { ...@@ -2269,14 +2270,16 @@ sub syncVlansFromTables($$) {
VLan->ExperimentVLans($experiment, \@tmp) == 0 or VLan->ExperimentVLans($experiment, \@tmp) == 0 or
die("Could not get current vlans for $experiment\n"); die("Could not get current vlans for $experiment\n");
foreach my $vlan (@tmp) { foreach my $vlan (@tmp) {
$expvlans{$vlan->id()} = $vlan; # Narrow to provided vlanids.
$expvlans{$vlan->id()} = $vlan
if (!@vlanids || grep {$_ == $vlan->id()} @vlanids);
} }
debug("Experiment vlans: " . join(" ", keys(%expvlans)) . "\n");; debug("Experiment vlans: " . join(" ", keys(%expvlans)) . "\n");;
# #
# List of trunks for the above set of vlans. # List of trunks for the above set of vlans.
# #
my %needTrunking = getExperimentTrunks($pid, $eid, @tmp); my %needTrunking = getExperimentTrunks($pid, $eid, values(%expvlans));
debug("Trunk Ports: ".Port->toStrings(keys(%needTrunking))."\n"); debug("Trunk Ports: ".Port->toStrings(keys(%needTrunking))."\n");
# #
...@@ -2286,19 +2289,23 @@ sub syncVlansFromTables($$) { ...@@ -2286,19 +2289,23 @@ sub syncVlansFromTables($$) {
VLan->StaleVlanList($experiment, \@tmp) == 0 or VLan->StaleVlanList($experiment, \@tmp) == 0 or
die("Could not get stale vlans for $experiment\n"); die("Could not get stale vlans for $experiment\n");
foreach my $vlanid (@tmp) { foreach my $vlanid (@tmp) {
$curvlans{$vlanid} = 1; # Narrow to provided vlanids.
next
if (@vlanids && ! grep {$_ == $vlanid} @vlanids);
$curvlans{$vlanid} = 1;
# Not in the new set; must delete. # Not in the new set; must delete.
$stale{$vlanid} = 1 $stale{$vlanid} = 1
if (!exists($expvlans{$vlanid})); if (!exists($expvlans{$vlanid}));
} }
debug("Existing vlans: @tmp\n"); debug("Existing vlans: " . join(" ", keys(%curvlans)) . "\n");
debug("Stale vlans: " . join(" ", keys(%stale)) . "\n"); debug("Stale vlans: " . join(" ", keys(%stale)) . "\n");
# #
# Get a list of interfaces that are currently trunked. # Get a list of interfaces that are currently trunked.
# #
my %currentTrunks = getExperimentCurrentTrunks($pid, $eid, @tmp); my %currentTrunks = getExperimentCurrentTrunks($pid, $eid, keys(%curvlans));
debug("Existing Trunk Ports: ".Port->toStrings(keys(%currentTrunks))."\n"); debug("Existing Trunk Ports: ".Port->toStrings(keys(%currentTrunks))."\n");
# #
......
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