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) { ...@@ -288,13 +288,26 @@ foreach my $devicename (@devicenames) {
# #
my @stacks; my @stacks;
foreach my $stack_id (keys %stacks) { foreach my $stack_id (keys %stacks) {
# my $stack_type = getStackType($stack_id);
# XXX: For now, we assume that the stack is a Cisco stack. We'll need my $stack;
# more database information to be able to distinguish stack types debug("Stack $stack_id has type $stack_type\n");
# SWITCH: for ($stack_type) {
use snmpit_cisco_stack; /cisco/ && do {
my $stack = new snmpit_cisco_stack($stack_id,$debug, require snmpit_cisco_stack;
$stack = new snmpit_cisco_stack($stack_id,$debug,
@{$stacks{$stack_id}}); @{$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; push @stacks, $stack;
} }
...@@ -311,11 +324,11 @@ SWITCH: for ($operation) { ...@@ -311,11 +324,11 @@ SWITCH: for ($operation) {
/listvlans/ && do { /listvlans/ && do {
$exitval = doListVlans(); $exitval = doListVlans();
last; last;
}; # /vlans/ && do }; # /listvlans/ && do
/listports/ && do { /listports/ && do {
$exitval = doListPorts(); $exitval = doListPorts();
last; last;
}; # /ports/ && do }; # /listports/ && do
/getstats/ && do { /getstats/ && do {
$exitval = doGetStats(); $exitval = doGetStats();
last; last;
......
...@@ -10,7 +10,7 @@ use Exporter; ...@@ -10,7 +10,7 @@ use Exporter;
@EXPORT = qw( macport portnum Dev vlanmemb vlanid @EXPORT = qw( macport portnum Dev vlanmemb vlanid
getTestSwitches getVlanPorts getExperimentVlans getDeviceNames getTestSwitches getVlanPorts getExperimentVlans getDeviceNames
getDeviceType getInterfaceSettings mapPortsToDevices getDeviceType getInterfaceSettings mapPortsToDevices
getSwitchStack tbsort ); getSwitchStack getStackType tbsort );
use English; use English;
use libdb; use libdb;
...@@ -308,6 +308,22 @@ sub getSwitchStack($) { ...@@ -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) # 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