Commit 5c370813 authored by Robert Ricci's avatar Robert Ricci
Browse files

Hack to get around some strange behavior where some SNMP calls are

lumping the VLAN number in with the OID, leaving the field we expect
to contain the VLAN number blank. I'm not sure why this happens, but
I've seen it before, and I think that simply dealing with it is going
to be more successful than finding the root cause.
parent 25c8af39
......@@ -27,6 +27,7 @@ my $WOL = "$TB/sbin/whol";
use lib "@prefix@/lib";
use libdb;
use libxmlrpc;
use power_ipmi;
use power_rpc27;
use power_sgmote;
use power_mail;
......@@ -319,7 +320,20 @@ foreach my $power_id (keys %outlets) {
# of object
#
my $errors = 0;
if ($type eq "APC") {
if ($type eq "IPMI") {
my $device = new power_ipmi($IP,$verbose);
if (!defined $device) {
warn "Unable to contact controller for $nodestr. Skipping...\n";
next;
} else {
print "Calling device->power($op,@outlets)\n" if $verbose > 1;
if ($device->power($op,@outlets)) {
print "Control of $nodestr failed.\n";
$errors++;
}
}
}
elsif ($type eq "APC") {
my $device = new snmpit_apc($IP,$verbose);
if (!defined $device) {
warn "Unable to contact controller for $nodestr. Skipping...\n";
......
......@@ -381,6 +381,29 @@ sub convertVlanName($) {
return $id;
}
#
# Try to pull a VLAN number out of a long OID string
#
sub parseVlanNumberFromOID($) {
my ($oid) = @_;
# OID must be a dotted string
my (@elts) = split /\./, $oid;
if (scalar(@elts) < 2) {
return undef;
}
# Second-to-last element must be the right text string or numeric ID
if ($elts[$#elts-1] eq "dot1qVlanStaticName" || $elts[$#elts-1] eq "1") {
# Last element must be numeric
if ($elts[$#elts] =~ /\d+/) {
return $elts[$#elts];
} else {
return undef;
}
} else {
return undef;
}
}
sub checkLACP($$) {
my ($self, $port) = @_;
if (my $j = $self->{TRUNKINDEX}{$port})
......@@ -516,6 +539,12 @@ sub findVlans($@) {
foreach my $rowref (@$rows) {
($name,$vlan_number,$vlan_name) = @$rowref;
$self->debug("$id: Got $name $vlan_number $vlan_name\n",2);
# Hack to get around some strange behavior
if ((!defined($vlan_number) || $vlan_number eq "") &&
defined(parseVlanNumberFromOID($name))) {
$vlan_number = parseVlanNumberFromOID($name);
$self->debug("Changed vlan_number to $vlan_number\n",3);
}
$vlan_name = convertVlanName($vlan_name);
#
# We only want the names - we ignore everything else
......@@ -1148,6 +1177,12 @@ sub listVlans($) {
foreach $rowref (@$rows) {
($oid, $vlan_number, $vlan_name) = @$rowref;
$self->debug("Got $oid $vlan_number $vlan_name\n",3);
# Hack to get around some strange behavior
if ((!defined($vlan_number) || $vlan_number eq "") &&
defined(parseVlanNumberFromOID($oid))) {
$vlan_number = parseVlanNumberFromOID($oid);
$self->debug("Changed vlan_number to $vlan_number\n",3);
}
if ($vlan_number eq "1") { next;}
$vlan_name = convertVlanName($vlan_name);
if (!$Names{$vlan_number}) {
......
Supports Markdown
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