Fix errors with serial number on Nexus and make Nexus.pm code style more consistent (#269)
This commit is contained in:
@@ -82,34 +82,28 @@ sub os_ver {
|
|||||||
|
|
||||||
sub _get_snmpid_chassis {
|
sub _get_snmpid_chassis {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
my $funcname = (caller(0))[3]; # Name of this sub, including package, used for debug logging
|
||||||
|
|
||||||
my $snmpid_chassis;
|
my $snmpid_chassis;
|
||||||
my $position;
|
my $position;
|
||||||
|
|
||||||
my $entity_entry = $self->e_class;
|
my $entity_entry = $self->e_class;
|
||||||
for ( keys %$entity_entry ) {
|
for ( keys %$entity_entry ) {
|
||||||
# filter by class, chassis is 3
|
# filter by class (chassis is 3, but with proper MIBs loaded we should get the translated textual value)
|
||||||
if ( $entity_entry->{$_} == 3 ) {
|
if ( ($entity_entry->{$_} eq 'chassis') or ($entity_entry->{$_} eq '3') ) {
|
||||||
print " SNMP::Info::Layer3::Nexus::_get_snmpid_chassis() - ",
|
printf("%s - chassis with id %s found, position %s\n", $funcname, $_, $self->snmpinfo->e_pos->{$_}) if $self->debug();
|
||||||
"chassis with id $_ found, position ",
|
|
||||||
$self->snmpinfo->e_pos->{$_}
|
|
||||||
if $self->debug();
|
|
||||||
|
|
||||||
# and if it's the topmost one
|
# and if it's the topmost one
|
||||||
if ( !defined $position
|
if ( !defined $position || $self->e_pos->{$_} < $position ) {
|
||||||
|| $self->e_pos->{$_} < $position ) {
|
|
||||||
$snmpid_chassis = $_;
|
$snmpid_chassis = $_;
|
||||||
$position = $self->e_pos->{$_};
|
$position = $self->e_pos->{$_};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( defined $snmpid_chassis && defined $position ) {
|
if ( defined $snmpid_chassis && defined $position ) {
|
||||||
print " SNMP::Info::Layer3::Nexus::_get_snmpid_chassis() - ",
|
printf(" %s - chassis with id %s, position %s selected\n", $funcname, $snmpid_chassis, $position);
|
||||||
"chassis with id $snmpid_chassis, position $position selected";
|
} else {
|
||||||
}
|
printf(" %s - no chassis found\n", $funcname);
|
||||||
else {
|
|
||||||
print " SNMP::Info::Layer3::Nexus::_get_snmpid_chassis() - ",
|
|
||||||
"no chassis found";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $snmpid_chassis;
|
return $snmpid_chassis;
|
||||||
@@ -117,12 +111,8 @@ sub _get_snmpid_chassis {
|
|||||||
|
|
||||||
sub serial {
|
sub serial {
|
||||||
my $nexus = shift;
|
my $nexus = shift;
|
||||||
|
|
||||||
my $snmpid_chassis = $nexus->_get_snmpid_chassis;
|
my $snmpid_chassis = $nexus->_get_snmpid_chassis;
|
||||||
|
return $nexus->e_serial($snmpid_chassis)->{$snmpid_chassis} if defined $snmpid_chassis;
|
||||||
return $nexus->e_serial($snmpid_chassis)->{$snmpid_chassis}
|
|
||||||
if defined $snmpid_chassis;
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,9 +123,7 @@ sub model {
|
|||||||
my $id = $nexus->id();
|
my $id = $nexus->id();
|
||||||
|
|
||||||
unless ( defined $id ) {
|
unless ( defined $id ) {
|
||||||
print
|
print " SNMP::Info::Layer3::Nexus::model() - Device does not support sysObjectID\n" if $nexus->debug();
|
||||||
" SNMP::Info::Layer3::Nexus::model() - Device does not support sysObjectID\n"
|
|
||||||
if $nexus->debug();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user