Commit 9b3437be authored by Robert Ricci's avatar Robert Ricci
Browse files

Added error checking for failure to create switch objects. This will now give a

more helpful error than complaining about calling methods on an undefined
variable.

Also fixed some logic in snmpit_intel_stack that was causing it to report
failure when it had, in fact, succeeded (this was purely cosmetic.)
parent e38a6e95
......@@ -308,7 +308,15 @@ foreach my $stack_id (keys %stacks) {
# 'default' case
die "Unknown stack type $stack_type for stack $stack_id\n";
}
push @stacks, $stack;
#
# Check for error in object creation and bail
#
if (!$stack) {
die "Unable to connect to one or more switches, exiting\n";
} else {
push @stacks, $stack;
}
}
######################################################################
......
......@@ -68,6 +68,17 @@ sub new($$#@) {
use snmpit_intel;
$self->{LEADER} = new snmpit_intel($stack_id,$self->{DEBUG});
#
# Check for failed object creation
#
if (!$self->{LEADER}) {
#
# The snmpit_intel object has already printed an error message,
# so we'll just return an error
#
return undef;
}
bless($self,$class);
return $self;
}
......@@ -150,7 +161,7 @@ sub removeVlan($$) {
$errors += $self->{LEADER}->removePortsFromVlan($vlan_id);
my $ok = $self->{LEADER}->removeVlan($vlan_id);
return ($ok && ($errors == 0));
return $ok;
}
sub portControl ($$@) {
......
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