Emulate ENTITY-MIB Physical Table methods using S5-CHASSIS-MIB for older devices.

This commit is contained in:
Eric Miller
2007-04-14 20:54:57 +00:00
parent be37a24fc9
commit 67081eed26
3 changed files with 602 additions and 12 deletions

View File

@@ -367,6 +367,86 @@ sub slot_offset {
return 0; return 0;
} }
# Devices do not support ENTITY-MIB use proprietary methods.
sub e_index {
my $stack = shift;
my $partial = shift;
return $stack->ns_e_index($partial);
}
sub e_class {
my $stack = shift;
my $partial = shift;
return $stack->ns_e_class($partial);
}
sub e_descr {
my $stack = shift;
my $partial = shift;
return $stack->ns_e_descr($partial);
}
sub e_fwver {
my $stack = shift;
my $partial = shift;
return $stack->ns_e_fwver($partial);
}
sub e_hwver {
my $stack = shift;
my $partial = shift;
return $stack->ns_e_hwver($partial);
}
sub e_parent {
my $stack = shift;
my $partial = shift;
return $stack->ns_e_parent($partial);
}
sub e_pos {
my $stack = shift;
my $partial = shift;
return $stack->ns_e_pos($partial);
}
sub e_serial {
my $stack = shift;
my $partial = shift;
return $stack->ns_e_serial($partial);
}
sub e_swver {
my $stack = shift;
my $partial = shift;
return $stack->ns_e_swver($partial);
}
sub e_type {
my $stack = shift;
my $partial = shift;
return $stack->ns_e_type($partial);
}
sub e_vendor {
my $stack = shift;
my $partial = shift;
return $stack->ns_e_vendor($partial);
}
1; 1;
__END__ __END__
@@ -558,6 +638,60 @@ to the Interface index.
=back =back
=head2 Pseudo ENTITY-MIB Information
These devices do not support ENTITY-MIB. These methods emulate Physical Table
methods using S5-CHASSIS-MIB. See L<SNMP::Info::NortelStack/"TABLE METHODS">
for details.
=over
=item $bayhub->e_index()
Returns ns_e_index().
=item $bayhub->e_class()
Returns ns_e_class().
=item $bayhub->e_descr()
Returns ns_e_descr().
=item $bayhub->e_fwver()
Returns ns_e_fwver().
=item $bayhub->e_hwver()
Returns ns_e_hwver().
=item $bayhub->e_parent()
Returns ns_e_parent().
=item $bayhub->e_pos()
Returns ns_e_pos().
=item $bayhub->e_serial()
Returns ns_e_serial().
=item $bayhub->e_swver()
Returns ns_e_swver().
=item $bayhub->e_type()
Returns ns_e_type().
=item $bayhub->e_vendor()
Returns ns_e_vendor().
=back
=head2 Table Methods imported from SNMP::Info::Layer2 =head2 Table Methods imported from SNMP::Info::Layer2
See L<SNMP::Info::Layer2/"TABLE METHODS"> for details. See L<SNMP::Info::Layer2/"TABLE METHODS"> for details.

View File

@@ -352,6 +352,86 @@ sub c_platform {
return \%c_platform; return \%c_platform;
} }
# Newer devices support ENTITY-MIB, use if available otherwise use proprietary
# methods.
sub e_index {
my $stack = shift;
my $partial = shift;
return $stack->SUPER::e_index($partial) || $stack->ns_e_index($partial);
}
sub e_class {
my $stack = shift;
my $partial = shift;
return $stack->SUPER::e_class($partial) || $stack->ns_e_class($partial);
}
sub e_descr {
my $stack = shift;
my $partial = shift;
return $stack->SUPER::e_descr($partial) || $stack->ns_e_descr($partial);
}
sub e_fwver {
my $stack = shift;
my $partial = shift;
return $stack->SUPER::e_fwver($partial) || $stack->ns_e_fwver($partial);
}
sub e_hwver {
my $stack = shift;
my $partial = shift;
return $stack->SUPER::e_hwver($partial) || $stack->ns_e_hwver($partial);
}
sub e_parent {
my $stack = shift;
my $partial = shift;
return $stack->SUPER::e_parent($partial) || $stack->ns_e_parent($partial);
}
sub e_pos {
my $stack = shift;
my $partial = shift;
return $stack->SUPER::e_pos($partial) || $stack->ns_e_pos($partial);
}
sub e_serial {
my $stack = shift;
my $partial = shift;
return $stack->SUPER::e_serial($partial) || $stack->ns_e_serial($partial);
}
sub e_swver {
my $stack = shift;
my $partial = shift;
return $stack->SUPER::e_swver($partial) || $stack->ns_e_swver($partial);
}
sub e_type {
my $stack = shift;
my $partial = shift;
return $stack->SUPER::e_type($partial) || $stack->ns_e_type($partial);
}
sub e_vendor {
my $stack = shift;
my $partial = shift;
return $stack->SUPER::e_vendor($partial) || $stack->ns_e_vendor($partial);
}
1; 1;
__END__ __END__
@@ -529,6 +609,68 @@ Crosses ifName with ifAlias and returns the human set port name if exists.
=back =back
=head2 ENTITY-MIB Information
For older devices which do not support ENTITY-MIB, these methods emulate
Physical Table methods using S5-CHASSIS-MIB. See
L<SNMP::Info::NortelStack/"TABLE METHODS"> for details on ns_e_* methods.
=over
=item $baystack->e_index()
If the device doesn't support B<entPhysicalIndex>, this will try ns_e_index().
=item $baystack->e_class()
If the device doesn't support B<entPhysicalClass>, this will try ns_e_class().
=item $baystack->e_descr()
If the device doesn't support B<entPhysicalDescr>, this will try ns_e_descr().
=item $baystack->e_fwver()
If the device doesn't support B<entPhysicalFirmwareRev>, this will try
ns_e_fwver().
=item $baystack->e_hwver()
If the device doesn't support B<entPhysicalHardwareRev>, this will try
ns_e_hwver().
=item $baystack->e_parent()
If the device doesn't support B<entPhysicalContainedIn>, this will try
ns_e_parent().
=item $baystack->e_pos()
If the device doesn't support B<entPhysicalParentRelPos>, this will try
ns_e_pos().
=item $baystack->e_serial()
If the device doesn't support B<entPhysicalSerialNum>, this will try
ns_e_serial().
=item $baystack->e_swver()
If the device doesn't support B<entPhysicalSoftwareRev>, this will try
ns_e_swver().
=item $baystack->e_type()
If the device doesn't support B<entPhysicalVendorType>, this will try
ns_e_type().
=item $baystack->e_vendor()
If the device doesn't support B<entPhysicalMfgName>, this will try
ns_e_vendor().
=back
=head2 Topology information =head2 Topology information
Based upon the software version devices may support SynOptics Network Based upon the software version devices may support SynOptics Network

View File

@@ -44,6 +44,7 @@ use vars qw/$VERSION $DEBUG %FUNCS %GLOBALS %MIBS %MUNGE $INIT/;
# S5-ROOT-MIB and S5-TCS-MIB required by the MIBs below # S5-ROOT-MIB and S5-TCS-MIB required by the MIBs below
'S5-AGENT-MIB' => 's5AgMyGrpIndx', 'S5-AGENT-MIB' => 's5AgMyGrpIndx',
'S5-CHASSIS-MIB' => 's5ChasType', 'S5-CHASSIS-MIB' => 's5ChasType',
'S5-REG-MIB' => 's5ChasTypeVal',
); );
%GLOBALS = ( %GLOBALS = (
@@ -68,7 +69,7 @@ use vars qw/$VERSION $DEBUG %FUNCS %GLOBALS %MIBS %MUNGE $INIT/;
'i_cfg_host' => 's5AgMyIfLdSvrAddr', 'i_cfg_host' => 's5AgMyIfLdSvrAddr',
# From S5-CHASSIS-MIB::s5ChasComTable # From S5-CHASSIS-MIB::s5ChasComTable
'ns_com_grp_idx' => 's5ChasComGrpIndx', 'ns_com_grp_idx' => 's5ChasComGrpIndx',
'ns_com_ns_com_idx'=> 's5ChasComIndx', 'ns_com_idx' => 's5ChasComIndx',
'ns_com_sub_idx' => 's5ChasComSubIndx', 'ns_com_sub_idx' => 's5ChasComSubIndx',
'ns_com_type' => 's5ChasComType', 'ns_com_type' => 's5ChasComType',
'ns_com_descr' => 's5ChasComDescr', 'ns_com_descr' => 's5ChasComDescr',
@@ -76,7 +77,7 @@ use vars qw/$VERSION $DEBUG %FUNCS %GLOBALS %MIBS %MUNGE $INIT/;
'ns_com_serial' => 's5ChasComSerNum', 'ns_com_serial' => 's5ChasComSerNum',
# From S5-CHASSIS-MIB::s5ChasStoreTable # From S5-CHASSIS-MIB::s5ChasStoreTable
'ns_store_grp_idx' => 's5ChasStoreGrpIndx', 'ns_store_grp_idx' => 's5ChasStoreGrpIndx',
'ns_store_ns_com_idx' => 's5ChasStoreComIndx', 'ns_store_com_idx' => 's5ChasStoreComIndx',
'ns_store_sub_idx' => 's5ChasStoreSubIndx', 'ns_store_sub_idx' => 's5ChasStoreSubIndx',
'ns_store_idx' => 's5ChasStoreIndx', 'ns_store_idx' => 's5ChasStoreIndx',
'ns_store_type' => 's5ChasStoreType', 'ns_store_type' => 's5ChasStoreType',
@@ -85,7 +86,8 @@ use vars qw/$VERSION $DEBUG %FUNCS %GLOBALS %MIBS %MUNGE $INIT/;
); );
%MUNGE = ( %MUNGE = (
'ns_com_type' => \&munge_ns_com_type,
'ns_store_type' => \&munge_ns_store_type,
); );
sub os_ver { sub os_ver {
@@ -128,6 +130,243 @@ sub serial {
return undef; return undef;
} }
# Psuedo ENTITY-MIB methods for older switches with don't support ENTITY-MIB
sub ns_e_index {
my $stack = shift;
my $partial = shift;
my $ns_e_idx = $stack->ns_com_sub_idx($partial) || {};
my %ns_e_index;
foreach my $iid (keys %$ns_e_idx){
# Format into consistent integer format so that numeric sorting works
my $index = join('',map { sprintf "%02d",$_ } split /\./, $iid);
$ns_e_index{$iid} = $index;
}
return \%ns_e_index;
}
sub ns_e_class {
my $stack = shift;
my $partial = shift;
my $ns_e_idx = $stack->ns_com_grp_idx($partial) || {};
my $classes = $stack->s5ChasGrpDescr();
my %ns_e_class;
foreach my $iid (keys %$ns_e_idx){
my $grp = $ns_e_idx->{$iid};
next unless defined $grp;
my $class = $classes->{$grp};
next unless defined $class;
$class =~ s/\s*Group[\0\s]*//;
$ns_e_class{$iid} = $class;
}
return \%ns_e_class;
}
sub ns_e_descr {
my $stack = shift;
my $partial = shift;
my $ns_e_descr = $stack->ns_com_descr($partial) || {};
my %ns_e_descr;
foreach my $iid (keys %$ns_e_descr){
my $descr = $ns_e_descr->{$iid};
next unless defined $descr;
$ns_e_descr{$iid} = $descr;
}
return \%ns_e_descr;
}
sub ns_e_hwver {
my $stack = shift;
my $partial = shift;
my $ns_e_ver = $stack->ns_com_ver($partial) || {};
my %ns_e_hwver;
foreach my $iid (keys %$ns_e_ver){
my $ver = $ns_e_ver->{$iid};
next unless defined $ver;
$ns_e_hwver{$iid} = $ver;
}
return \%ns_e_hwver;
}
sub ns_e_vendor {
my $stack = shift;
my $partial = shift;
my $ns_e_idx = $stack->ns_com_sub_idx($partial) || {};
my %ns_e_vendor;
foreach my $iid (keys %$ns_e_idx){
my $vendor = 'nortel';
$ns_e_vendor{$iid} = $vendor;
}
return \%ns_e_vendor;
}
sub ns_e_serial {
my $stack = shift;
my $partial = shift;
my $ns_e_serial = $stack->ns_com_serial($partial) || {};
my %ns_e_serial;
foreach my $iid (keys %$ns_e_serial){
my $serial = $ns_e_serial->{$iid};
next unless defined $serial;
$ns_e_serial{$iid} = $serial;
}
return \%ns_e_serial;
}
sub ns_e_pos {
my $stack = shift;
my $partial = shift;
my $ns_e_pos = $stack->ns_com_sub_idx($partial) || {};
my %ns_e_pos;
foreach my $iid (keys %$ns_e_pos){
my $pos = $ns_e_pos->{$iid};
next unless defined $pos;
$ns_e_pos{$iid} = $pos;
}
return \%ns_e_pos;
}
sub ns_e_type {
my $stack = shift;
my $partial = shift;
my $ns_e_type = $stack->ns_com_type($partial) || {};
my %ns_e_type;
foreach my $iid (keys %$ns_e_type){
my $type = $ns_e_type->{$iid};
next unless defined $type;
$ns_e_type{$iid} = $type;
}
return \%ns_e_type;
}
sub ns_e_fwver {
my $stack = shift;
my $partial = shift;
my $ns_e_ver = $stack->ns_store_ver($partial) || {};
my $ns_e_type = $stack->ns_store_type($partial) || {};
my %ns_e_fwver;
foreach my $iid (keys %$ns_e_type){
my $type = $ns_e_type->{$iid};
next unless defined $type;
next unless $type =~ /(rom|boot|fw)/i;
my $ver = $ns_e_ver->{$iid};
next unless defined $ver;
$iid =~ s/\.\d+$//;
$ns_e_fwver{$iid} = $ver;
}
return \%ns_e_fwver;
}
sub ns_e_swver {
my $stack = shift;
my $partial = shift;
my $ns_e_ver = $stack->ns_store_ver($partial) || {};
my $ns_e_type = $stack->ns_store_type($partial) || {};
my %ns_e_swver;
foreach my $iid (keys %$ns_e_type){
my $type = $ns_e_type->{$iid};
next unless defined $type;
next unless $type =~ /(flash)/i;
my $ver = $ns_e_ver->{$iid};
next unless defined $ver;
$iid =~ s/\.\d+$//;
$ns_e_swver{$iid} = $ver;
}
return \%ns_e_swver;
}
sub ns_e_parent {
my $stack = shift;
my $partial = shift;
my $ns_e_idx = $stack->ns_com_grp_idx($partial) || {};
# Check to see if we are dealing with a stack "virtual chassis"
my $v_test = $stack->s5ChasComRelPos('8.1.0');
my $virtual = $v_test->{'8.1.0'};
my %ns_e_parent;
foreach my $iid (keys %$ns_e_idx){
my $grp_idx = $ns_e_idx->{$iid};
next unless defined $grp_idx;
if ($grp_idx != 3) {
if ($virtual != 0) {
$ns_e_parent{$iid} = '0';
}
# In a traditional chassis everything except submodules
# are a child of the chassis
else {
$ns_e_parent{$iid} = '080100';
}
}
if ($grp_idx == 3) {
if ($iid =~ /0$/) {
if ($virtual != 0) {
$ns_e_parent{$iid} = '0';
}
else {
$ns_e_parent{$iid} = '080100';
}
}
else {
my $parent = $iid;
$parent =~ s/\.\d+$/\.00/;
$parent = join('',map { sprintf "%02d",$_ } split /\./, $parent);
$ns_e_parent{$iid} = $parent;
}
}
next;
}
return \%ns_e_parent;
}
sub munge_ns_com_type {
my $oid = shift;
my $name = &SNMP::translateObj($oid);
return $name if defined($name);
return $oid;
}
sub munge_ns_store_type {
my $oid = shift;
my $name = &SNMP::translateObj($oid);
return $name if defined($name);
return $oid;
}
1; 1;
__END__ __END__
@@ -144,13 +383,13 @@ Eric Miller
# Let SNMP::Info determine the correct subclass for you. # Let SNMP::Info determine the correct subclass for you.
my $stack = new SNMP::Info( my $stack = new SNMP::Info(
AutoSpecify => 1, AutoSpecify => 1,
Debug => 1, Debug => 1,
# These arguments are passed directly on to SNMP::Session # These arguments are passed directly on to SNMP::Session
DestHost => 'myswitch', DestHost => 'myswitch',
Community => 'public', Community => 'public',
Version => 2 Version => 2
) )
or die "Can't connect to DestHost.\n"; or die "Can't connect to DestHost.\n";
my $class = $stack->class(); my $class = $stack->class();
@@ -309,7 +548,7 @@ group which contains this component.
(B<s5ChasComGrpIndx>) (B<s5ChasComGrpIndx>)
=item $stack->ns_com_ns_com_idx() =item $stack->ns_com_idx()
Returns reference to hash. Key: Table entry, Value: Index of the component in Returns reference to hash. Key: Table entry, Value: Index of the component in
the group. For modules in the 'board' group, this is the slot number. the group. For modules in the 'board' group, this is the slot number.
@@ -360,7 +599,7 @@ group.
(B<s5ChasStoreGrpIndx>) (B<s5ChasStoreGrpIndx>)
=item $stack->ns_store_ns_com_idx() =item $stack->ns_store_idx()
Returns reference to hash. Key: Table entry, Value: Index of the group. Returns reference to hash. Key: Table entry, Value: Index of the group.
@@ -396,4 +635,79 @@ Returns reference to hash. Key: Table entry, Value: Version
(B<s5ChasStoreCntntVer>) (B<s5ChasStoreCntntVer>)
=back
=head2 Psuedo ENTITY-MIB information
These methods emulate ENTITY-MIB Physical Table methods using S5-CHASSIS-MIB.
=over
=item $stack->ns_e_index()
Returns reference to hash. Key: IID, Value: Integer, Indicies are combined
into a six digit integer, each index is two digits padded with leading zero if
required.
=item $stack->ns_e_class()
Returns reference to hash. Key: IID, Value: General hardware type
(B<s5ChasGrpDescr>).
Group is stripped from the string. Values may be Supervisory Module,
Backplane, Board, Power Supply, Sensor, Fan, Clock, Unit.
=item $stack->ns_e_descr()
Returns reference to hash. Key: IID, Value: Human friendly name
(B<s5ChasComDescr>)
=item $stack->ns_e_hwver()
Returns reference to hash. Key: IID, Value: Hardware version
(B<s5ChasComVer>)
=item $stack->ns_e_vendor()
Returns reference to hash. Key: IID, Value: nortel
=item $stack->ns_e_serial()
Returns reference to hash. Key: IID, Value: Serial number
(B<s5ChasComSerNum>)
=item $stack->ns_e_pos()
Returns reference to hash. Key: IID, Value: The relative position among all
entities sharing the same parent.
(B<s5ChasComSubIndx>)
=item $stack->ns_e_type()
Returns reference to hash. Key: IID, Value: Type of component/sub-component
as defined under B<s5ChasComTypeVal> in S5-REG-MIB.
=item $stack->ns_e_fwver()
Returns reference to hash. Key: IID, Value: Firmware revision.
Value of B<s5ChasStoreCntntVer> for entries with rom, boot, or fw in
B<s5ChasStoreType>.
=item $stack->ns_e_fwver()
Returns reference to hash. Key: IID, Value: Software revision.
Value of B<s5ChasStoreCntntVer> for entries with "flash" in B<s5ChasStoreType>.
=item $stack->ns_e_parent()
Returns reference to hash. Key: IID, Value: The value of ns_e_index() for the
entity which 'contains' this entity. A value of zero indicates this entity
is not contained in any other entity.
=cut =cut