diff --git a/.gitignore b/.gitignore index 98e6ef67..89c9dd95 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.db +SNMP diff --git a/Info/Aggregate.pm b/Info/Aggregate.pm new file mode 100644 index 00000000..e53f2f86 --- /dev/null +++ b/Info/Aggregate.pm @@ -0,0 +1,130 @@ +# SNMP::Info::Aggregate +# +# Copyright (c) 2014 SNMP::Info Developers +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +package SNMP::Info::Aggregate; + +use strict; +use Exporter; +use SNMP::Info; + +@SNMP::Info::Aggregate::ISA = qw/SNMP::Info Exporter/; +@SNMP::Info::Aggregate::EXPORT_OK = qw/agg_ports_ifstack/; + +use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; + +$VERSION = '3.10'; + +%MIBS = (); # IF-MIB + +%GLOBALS = (); + +%FUNCS = (); + +%MUNGE = (); + +sub agg_ports_ifstack { + my $dev = shift; + my $partial = shift; + + my $ifStack = $dev->ifStackStatus(); + # TODO: if we want to do partial, we need to use inverse status + my $ifType = $dev->ifType(); + + my $ret = {}; + + foreach my $idx ( keys %$ifStack ) { + my ( $higher, $lower ) = split /\./, $idx; + next if ( $higher == 0 or $lower == 0 ); + if ( $ifType->{ $higher } eq 'ieee8023adLag' ) { + $ret->{ $lower } = $higher; + } + } + + return $ret; +} + +1; + +__END__ + +=head1 NAME + +SNMP::Info::Aggregate - SNMP Interface to ifStackTable Aggregated Links + +=head1 AUTHOR + +SNMP::Info Developers + +=head1 SYNOPSIS + + # Let SNMP::Info determine the correct subclass for you. + my $info = new SNMP::Info( + AutoSpecify => 1, + Debug => 1, + DestHost => 'myrouter', + Community => 'public', + Version => 2 + ) + or die "Can't connect to DestHost.\n"; + + my $class = $info->class(); + print "SNMP::Info determined this device to fall under subclass : $class\n"; + +=head1 DESCRIPTION + +This class provides access to Aggregated Links configuration on devices +supporting C. + +Use or create in a subclass of SNMP::Info. Do not use directly. + +=head2 Inherited Classes + +L + +=head2 Required MIBs + +=over + +=item F + +=back + +=head1 METHODS + +=over 4 + +=item C + +Returns a HASH reference mapping from slave to master port for each member of +a port bundle on the device. Keys are ifIndex of the slave ports, Values are +ifIndex of the corresponding master ports. + +=back + +=cut diff --git a/Info/CiscoAgg.pm b/Info/CiscoAgg.pm new file mode 100644 index 00000000..3e86beac --- /dev/null +++ b/Info/CiscoAgg.pm @@ -0,0 +1,129 @@ +# SNMP::Info::CiscoAgg +# +# Copyright (c) 2014 SNMP::Info Developers +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +package SNMP::Info::CiscoAgg; + +use strict; +use Exporter; +use SNMP::Info::IEEE802dot3ag 'agg_ports_lag'; + +@SNMP::Info::CiscoAgg::ISA = qw/ + SNMP::Info::IEEE802dot3ag + Exporter +/; +@SNMP::Info::CiscoAgg::EXPORT_OK = qw/ + agg_ports +/; + +use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; + +$VERSION = '3.10'; + +%MIBS = ( + %SNMP::Info::IEEE802dot3ag::MIBS, + 'CISCO-PAGP-MIB' => 'pagpGroupIfIndex', +); + +%GLOBALS = (); + +%FUNCS = (); + +%MUNGE = (); + +# until someone using PAgP sends us a patch +sub agg_ports_pagp { {} } + +# until we have PAgP data and need to combine with LAG data +sub agg_ports { return agg_ports_lag(@_) } + +1; + +__END__ + +=head1 NAME + +SNMP::Info::CiscoAgg - SNMP Interface to Cisco Aggregated Links + +=head1 AUTHOR + +SNMP::Info Developers + +=head1 SYNOPSIS + + # Let SNMP::Info determine the correct subclass for you. + my $info = new SNMP::Info( + AutoSpecify => 1, + Debug => 1, + DestHost => 'myrouter', + Community => 'public', + Version => 2 + ) + or die "Can't connect to DestHost.\n"; + + my $class = $info->class(); + print "SNMP::Info determined this device to fall under subclass : $class\n"; + +=head1 DESCRIPTION + +This class provides access to Aggregated Links configuration on Cisco devices. +It combines Cisco PAgP and IEEE 802.3ad information. + +Use or create in a subclass of SNMP::Info. Do not use directly. + +=head2 Inherited Classes + +L + +=head2 Required MIBs + +=over + +=item F + +=back + +MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz + +=head1 METHODS + +=over 4 + +=item C + +Returns a HASH reference mapping from slave to master port for each member of +a port bundle on the device. Keys are ifIndex of the slave ports, Values are +ifIndex of the corresponding master ports. + +=item C + +Unimplemented. Returns an empty HASH reference. + +=back + +=cut diff --git a/Info/IEEE802dot3ag.pm b/Info/IEEE802dot3ag.pm new file mode 100644 index 00000000..e0712813 --- /dev/null +++ b/Info/IEEE802dot3ag.pm @@ -0,0 +1,141 @@ +# SNMP::Info::IEEE802dot3ag +# +# Copyright (c) 2014 SNMP::Info Developers +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +package SNMP::Info::IEEE802dot3ag; + +use strict; +use Exporter; +use SNMP::Info::Aggregate; + +@SNMP::Info::IEEE802dot3ag::ISA = qw/ + SNMP::Info::Aggregate + Exporter +/; +@SNMP::Info::IEEE802dot3ag::EXPORT_OK = qw/ + agg_ports_lag +/; + +use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; + +$VERSION = '3.10'; + +%MIBS = ( + %SNMP::Info::Aggregate::MIBS, + 'IEEE8023-LAG-MIB' => 'dot3adAggPortSelectedAggID', +); + +%GLOBALS = (); + +%FUNCS = (); + +%MUNGE = (); + +sub agg_ports_lag { + my $dev = shift; + + # TODO: implement partial + my $masters = $dev->dot3adAggActorOperKey; + my $slaves = $dev->dot3adAggPortActorOperKey; + + return {} unless + ref {} eq ref $masters and scalar keys %$masters + and ref {} eq ref $slaves and scalar keys %$slaves; + + my $ret = {}; + foreach my $s (keys %$slaves) { + next if $slaves->{$s} == 0; + foreach my $m (keys %$masters) { + next unless $masters->{$m} == $slaves->{$s}; + $ret->{$s} = $m; + last; + } + } + + return $ret; +} + +1; + +__END__ + +=head1 NAME + +SNMP::Info::IEEE802dot3ag - SNMP Interface to IEEE Aggregated Links + +=head1 AUTHOR + +SNMP::Info Developers + +=head1 SYNOPSIS + + # Let SNMP::Info determine the correct subclass for you. + my $info = new SNMP::Info( + AutoSpecify => 1, + Debug => 1, + DestHost => 'myrouter', + Community => 'public', + Version => 2 + ) + or die "Can't connect to DestHost.\n"; + + my $class = $info->class(); + print "SNMP::Info determined this device to fall under subclass : $class\n"; + +=head1 DESCRIPTION + +This class provides access to Aggregated Links configuration on devices +implementing C. + +Use or create in a subclass of SNMP::Info. Do not use directly. + +=head2 Inherited Classes + +L + +=head2 Required MIBs + +=over + +=item F + +=back + +=head1 METHODS + +=over 4 + +=item C + +Returns a HASH reference mapping from slave to master port for each member of +a port bundle on the device. Keys are ifIndex of the slave ports, Values are +ifIndex of the corresponding master ports. + +=back + +=cut diff --git a/Info/Layer3/Arista.pm b/Info/Layer3/Arista.pm index a8874abd..664daf8c 100644 --- a/Info/Layer3/Arista.pm +++ b/Info/Layer3/Arista.pm @@ -36,9 +36,14 @@ use Exporter; use SNMP::Info::Layer3; use SNMP::Info::MAU; use SNMP::Info::LLDP; +use SNMP::Info::Aggregate; -@SNMP::Info::Layer3::Arista::ISA = qw/SNMP::Info::LLDP SNMP::Info::MAU - SNMP::Info::Layer3 Exporter/; +@SNMP::Info::Layer3::Arista::ISA = qw/ + SNMP::Info::Aggregate + SNMP::Info::LLDP + SNMP::Info::MAU + SNMP::Info::Layer3 Exporter +/; @SNMP::Info::Layer3::Arista::EXPORT_OK = qw//; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; @@ -49,6 +54,7 @@ $VERSION = '3.10'; %SNMP::Info::Layer3::MIBS, %SNMP::Info::MAU::MIBS, %SNMP::Info::LLDP::MIBS, + %SNMP::Info::Aggregate::MIBS, 'ARISTA-PRODUCTS-MIB' => 'aristaProducts', ); @@ -125,6 +131,8 @@ sub lldp_if { return $lldp_if; } +sub agg_ports { return agg_ports_ifstack(@_) } + 1; __END__ @@ -160,6 +168,8 @@ Subclass for Arista Networks EOS-based devices =over +=item SNMP::Info::Aggregate + =item SNMP::Info::Layer3 =item SNMP::Info::MAU @@ -178,6 +188,8 @@ Subclass for Arista Networks EOS-based devices See L for its own MIB requirements. +See L for its own MIB requirements. + See L for its own MIB requirements. See L for its own MIB requirements. @@ -241,6 +253,12 @@ Returns info from F Returns the mapping to the SNMP Interface Table. +=item C + +Returns a HASH reference mapping from slave to master port for each member of +a port bundle on the device. Keys are ifIndex of the slave ports, Values are +ifIndex of the corresponding master ports. + =back =head2 Table Methods imported from SNMP::Info::Layer3 diff --git a/Info/Layer3/C6500.pm b/Info/Layer3/C6500.pm index e634f34d..71fe6d03 100644 --- a/Info/Layer3/C6500.pm +++ b/Info/Layer3/C6500.pm @@ -43,12 +43,14 @@ use SNMP::Info::CiscoPower; use SNMP::Info::Layer3; use SNMP::Info::CiscoStpExtensions; use SNMP::Info::CiscoVTP; +use SNMP::Info::CiscoAgg; use SNMP::Info::MAU; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; # NOTE : Top-most items gets precedence for @ISA @SNMP::Info::Layer3::C6500::ISA = qw/ + SNMP::Info::CiscoAgg SNMP::Info::CiscoVTP SNMP::Info::CiscoStpExtensions SNMP::Info::CiscoStack @@ -89,6 +91,7 @@ $VERSION = '3.10'; %SNMP::Info::CiscoStack::MIBS, %SNMP::Info::CiscoStpExtensions::MIBS, %SNMP::Info::CiscoVTP::MIBS, + %SNMP::Info::CiscoAgg::MIBS, 'CISCO-VIRTUAL-SWITCH-MIB' => 'cvsSwitchMode', ); @@ -309,6 +312,8 @@ after determining a more specific class using the method above. =over +=item SNMP::Info::CiscoAgg + =item SNMP::Info::CiscoVTP =item SNMP::Info::CiscoStack @@ -337,6 +342,8 @@ after determining a more specific class using the method above. =item Inherited Classes' MIBs +See L for its own MIB requirements. + See L for its own MIB requirements. See L for its own MIB requirements. diff --git a/Info/Layer3/Foundry.pm b/Info/Layer3/Foundry.pm index 553c16e6..bcbf8851 100644 --- a/Info/Layer3/Foundry.pm +++ b/Info/Layer3/Foundry.pm @@ -38,8 +38,12 @@ use SNMP::Info::Layer3; use SNMP::Info::FDP; use SNMP::Info::LLDP; -@SNMP::Info::Layer3::Foundry::ISA = qw/SNMP::Info::FDP SNMP::Info::LLDP - SNMP::Info::Layer3 Exporter/; +@SNMP::Info::Layer3::Foundry::ISA = qw/ + SNMP::Info::FDP + SNMP::Info::LLDP + SNMP::Info::Layer3 + Exporter +/; @SNMP::Info::Layer3::Foundry::EXPORT_OK = qw//; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; @@ -50,17 +54,20 @@ $VERSION = '3.10'; %SNMP::Info::Layer3::MIBS, %SNMP::Info::LLDP::MIBS, %SNMP::Info::FDP::MIBS, + 'FOUNDRY-SN-ROOT-MIB' => 'foundry', 'FOUNDRY-SN-AGENT-MIB' => 'snChasPwrSupplyDescription', 'FOUNDRY-SN-SWITCH-GROUP-MIB' => 'snSwGroupOperMode', 'FOUNDRY-SN-STACKING-MIB' => 'snStackingOperUnitRole', 'FOUNDRY-POE-MIB' => 'snAgentPoeGblPowerCapacityTotal', + 'FOUNDRY-SN-SWITCH-GROUP-MIB' => 'snSwGroupOperMode', ); %GLOBALS = ( %SNMP::Info::Layer3::GLOBALS, %SNMP::Info::LLDP::GLOBALS, %SNMP::Info::FDP::GLOBALS, + 'mac' => 'ifPhysAddress.1', 'chassis' => 'entPhysicalDescr.1', 'temp' => 'snChasActualTemperature', @@ -93,8 +100,10 @@ $VERSION = '3.10'; ); %MUNGE = ( - %SNMP::Info::Layer3::MUNGE, %SNMP::Info::LLDP::MUNGE, + %SNMP::Info::Layer3::MUNGE, + %SNMP::Info::LLDP::MUNGE, %SNMP::Info::FDP::MUNGE, + 'ag_mod2_type' => \&SNMP::Info::munge_e_type, 'ag_mod_type' => \&SNMP::Info::munge_e_type, ); @@ -785,6 +794,29 @@ sub peth_power_consumption { return $peth_power_consumed; } +sub agg_ports { + my $dev = shift; + + # TODO: implement partial + my $trunks = $dev->snMSTrunkPortList; + my $ports = $dev->snSwPortIfIndex; # sw_index() + + return {} unless + ref {} eq ref $trunks and scalar keys %$trunks + and ref {} eq ref $ports and scalar keys %$ports; + + my $ret = {}; + foreach my $m (keys %$trunks) { + my $skip = 0; + while (my $s = unpack("x${skip}n2", $trunks->{$m})) { + $ret->{ $ports->{$s} } = $m; + $skip += 2; + } + } + + return $ret; +} + 1; __END__ @@ -848,6 +880,8 @@ after determining a more specific class using the method above. =item F +=item F + =item Inherited Classes' MIBs See L for its own MIB requirements. @@ -982,6 +1016,12 @@ Skipped if device is an EdgeIron 24G due to reports of hangs. (C) +=item $foundry->agg_ports() + +Returns a HASH reference mapping from slave to master port for each member of +a port bundle on the device. Keys are ifIndex of the slave ports, Values are +ifIndex of the corresponding master ports. + =back =head2 F Information diff --git a/Info/Layer3/Passport.pm b/Info/Layer3/Passport.pm index 06565876..cdca83ec 100644 --- a/Info/Layer3/Passport.pm +++ b/Info/Layer3/Passport.pm @@ -583,6 +583,20 @@ sub bp_index { foreach my $iid ( keys %$if_index ) { $bp_index{$iid} = $iid; } + + # If we have MLT's map them to the designated port + my $trunks = $passport->rc_mlt_index; + my $dps = $passport->rc_mlt_dp || {}; + + if ( ref {} eq ref $trunks and scalar keys %$trunks ) { + foreach my $m ( keys %$trunks ) { + my $m_idx = $trunks->{$m}; + next unless $m_idx; + my $i_idx = $dps->{$m} ? $dps->{$m} : $m_idx; + $bp_index{$m_idx} = $i_idx; + } + } + return \%bp_index; } diff --git a/Info/RapidCity.pm b/Info/RapidCity.pm index f9807772..3f350b86 100644 --- a/Info/RapidCity.pm +++ b/Info/RapidCity.pm @@ -148,6 +148,11 @@ $VERSION = '3.10'; 'rc2k_mda_part' => 'rc2kMdaCardPartNumber', 'rc2k_mda_date' => 'rc2kMdaCardDateCode', 'rc2k_mda_dev' => 'rc2kMdaCardDeviations', + + # From RAPID-CITY::rcMltTable + 'rc_mlt_ports' => 'rcMltPortMembers', + 'rc_mlt_index' => 'rcMltIfIndex', + 'rc_mlt_dp' => 'rcMltDesignatedPort', ); %MUNGE = ( @@ -156,6 +161,7 @@ $VERSION = '3.10'; 'rc_cpu_mac' => \&SNMP::Info::munge_mac, 'rc_vlan_members' => \&SNMP::Info::munge_port_list, 'rc_vlan_no_join' => \&SNMP::Info::munge_port_list, + 'rc_mlt_ports' => \&SNMP::Info::munge_port_list, ); # Need to override here since overridden in Layer2 and Layer3 classes @@ -566,6 +572,35 @@ sub _validate_vlan_param { return 1; } +sub agg_ports { + my $rapidcity = shift; + + # TODO: implement partial + my $ports = $rapidcity->rc_mlt_ports; + my $trunks = $rapidcity->rc_mlt_index; + my $dps = $rapidcity->rc_mlt_dp || {}; + + return {} + unless ref {} eq ref $trunks + and scalar keys %$trunks + and ref {} eq ref $ports + and scalar keys %$ports; + + my $ret = {}; + foreach my $m ( keys %$trunks ) { + my $idx = $trunks->{$m}; + next unless $idx; + $idx = $dps->{$m} ? $dps->{$m} : $idx; + my $portlist = $ports->{$m}; + next unless $portlist; + for ( my $i = 0; $i <= scalar(@$portlist); $i++ ) { + $ret->{$i} = $idx if ( @$portlist[$i] ); + } + } + + return $ret; +} + 1; __END__ @@ -717,6 +752,12 @@ Returns VLAN IDs (C) +=item $rapidcity->agg_ports() + +Returns a HASH reference mapping from slave to master port for each member of +a port bundle (MLT) on the device. Keys are ifIndex of the slave ports, +Values are ifIndex of the corresponding master ports. + =back =head2 RAPID-CITY Port Table (C)