Commit 947f73f4 authored by Robert Ricci's avatar Robert Ricci

Two fixes:

Make sure experiments actually exist, for morons like me that enter 'eid pid'
instead of 'pid eid'

When using '-t', don't try to create VLANs if they already exist, just
put ports in it (this can be used, for example, to repair damage to switch
state or fix up after manually monkeying with VLANs)
parent 8286c6df
......@@ -249,6 +249,12 @@ debug("Ports: " . join(",",@ports) . "\n");
# to modify that experiment
#
if ($pid && $eid) {
#
# First, make sure the experiment exists
#
if (!ExpState($pid,$eid)) {
die "There is no experiment $eid in project $pid\n";
}
if (!TBExptAccessCheck($UID,$pid,$eid,TB_EXPT_MODIFY)) {
die "You do not have permission to modify experiment $pid/$eid\n";
}
......@@ -547,15 +553,20 @@ sub doVlansFromTables(@) {
my ($stack) = @stacks;
foreach my $vlan (@vlans) {
if (!$stack->createVlan($vlan)) {
warn "ERROR: Failed to create VLAN with id $vlan\n";
#
# Don't try to put ports in a VLAN if it couldn't be created
#
$errors++;
} else {
my @ports = getVlanPorts($vlan);
my @ports = getVlanPorts($vlan);
if ($stack->vlanExists($vlan)) {
print " VLAN $vlan already exists\n";
$errors += $stack->setPortVlan($vlan,@ports);
} else {
if (!$stack->createVlan($vlan)) {
warn "ERROR: Failed to create VLAN with id $vlan\n";
#
# Don't try to put ports in a VLAN if it couldn't be created
#
$errors++;
} else {
$errors += $stack->setPortVlan($vlan,@ports);
}
}
}
......
......@@ -107,9 +107,9 @@ sub new($$#@) {
#
if (!$self->{LEADER}) {
# XXX: For simplicity, we assume for now that the leader is a Cisco
use snmpit_cisco;
$self->{LEADER} = new snmpit_cisco($self->{STACKID});
}
use snmpit_cisco;
$self->{LEADER} = new snmpit_cisco($self->{STACKID});
}
bless($self,$class);
......
......@@ -171,6 +171,15 @@ sub getExperimentVlans ($$) {
return @vlans;
}
#
# Returns an array of all ports used by a given experiment
#
sub getExperimentPorts ($$) {
my ($pid, $eid) = @_;
return getVlanPorts(getExperimentVlans($pid,$eid));
}
#
# Usage: getDeviceNames(@ports)
#
......
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