Commit ed66c76a authored by Robert Ricci's avatar Robert Ricci

Support for multiple switch stack types. References snmpit_intel_stack, which

does not yet exist (but should soon.)

There is a new database table, switch_stack_types, that goes along with these
code changes, to indicate which module should be used for each switch stack.
parent c72fe078
......@@ -288,13 +288,26 @@ foreach my $devicename (@devicenames) {
#
my @stacks;
foreach my $stack_id (keys %stacks) {
#
# XXX: For now, we assume that the stack is a Cisco stack. We'll need
# more database information to be able to distinguish stack types
#
use snmpit_cisco_stack;
my $stack = new snmpit_cisco_stack($stack_id,$debug,
@{$stacks{$stack_id}});
my $stack_type = getStackType($stack_id);
my $stack;
debug("Stack $stack_id has type $stack_type\n");
SWITCH: for ($stack_type) {
/cisco/ && do {
require snmpit_cisco_stack;
$stack = new snmpit_cisco_stack($stack_id,$debug,
@{$stacks{$stack_id}});
last;
}; # /cisco/
/intel/ && do {
require snmpit_intel_stack;
$stack = new snmpit_cisco_stack($stack_id,$debug,
@{$stacks{$stack_id}});
last;
};
# 'default' case
die "Unknown stack type $stack_type for stack $stack_id\n";
}
push @stacks, $stack;
}
......@@ -311,11 +324,11 @@ SWITCH: for ($operation) {
/listvlans/ && do {
$exitval = doListVlans();
last;
}; # /vlans/ && do
}; # /listvlans/ && do
/listports/ && do {
$exitval = doListPorts();
last;
}; # /ports/ && do
}; # /listports/ && do
/getstats/ && do {
$exitval = doGetStats();
last;
......
......@@ -10,7 +10,7 @@ use Exporter;
@EXPORT = qw( macport portnum Dev vlanmemb vlanid
getTestSwitches getVlanPorts getExperimentVlans getDeviceNames
getDeviceType getInterfaceSettings mapPortsToDevices
getSwitchStack tbsort );
getSwitchStack getStackType tbsort );
use English;
use libdb;
......@@ -308,6 +308,22 @@ sub getSwitchStack($) {
}
}
#
# Returns the type of the given stack_id
#
sub getStackType($) {
my $stack = shift;
my $result = DBQueryFatal("SELECT stack_type FROM switch_stack_types WHERE " .
"stack_id='$stack'");
if (!$result->numrows()) {
print STDERR "No stack found called $stack\n";
return undef;
} else {
my ($stack_type) = ($result->fetchrow());
return $stack_type;
}
}
#
# Used to sort a set of nodes in testbed order (ie. pc2 < pc10)
#
......
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