Squashed commit of the following:

commit 9be20cd3e24b401d5bfeb2bcb40d61a7b33ffe2c
Author: Eric A. Miller <emiller@cpan.org>
Date:   Sun Jan 19 10:13:41 2014 -0500

    Re-organize part 2

commit 058fc6e000a27b8ffadf5857078e0ab1569d3fa2
Author: Eric A. Miller <emiller@cpan.org>
Date:   Sun Jan 19 10:08:31 2014 -0500

    Re-organize

commit 04f4602d6cf06f917bd4f19db737f877a46fd28e
Author: Eric A. Miller <emiller@cpan.org>
Date:   Sun Jan 19 10:04:09 2014 -0500

    Add MLT agg_ports() support for Avaya

commit 2cdc3aed77f551e3c6d04f4cfe390a876010ebcb
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Sun Jan 12 14:24:38 2014 +0000

    implement LAG support for Foundry

commit 7465816b53981f3211bdeb5a7a414d5a4e65c79f
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Sun Jan 12 13:15:13 2014 +0000

    implement LAG support for Arista

commit 67e8f13f635f4fb450ab5df6e9145830ef72cf7b
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Sun Jan 12 12:59:09 2014 +0000

    update gitignore to ignore SNMP dir

commit df4ca0eb44a4f0e5aa114630f0d22b5c9d7861f3
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Sun Jan 12 12:49:53 2014 +0000

    implement LAG support for Cisco
This commit is contained in:
Eric A. Miller
2014-01-19 10:25:41 -05:00
parent 6b49bfd4c4
commit 31a8abc3b8
9 changed files with 526 additions and 5 deletions

1
.gitignore vendored
View File

@@ -1 +1,2 @@
*.db *.db
SNMP

130
Info/Aggregate.pm Normal file
View File

@@ -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<ifStackTable>.
Use or create in a subclass of SNMP::Info. Do not use directly.
=head2 Inherited Classes
L<SNMP::Info>
=head2 Required MIBs
=over
=item F<IF-MIB>
=back
=head1 METHODS
=over 4
=item C<agg_ports_ifstack>
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

129
Info/CiscoAgg.pm Normal file
View File

@@ -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<SNMP::Info::IEEE802dot3ag>
=head2 Required MIBs
=over
=item F<CISCO-PAGP-MIB>
=back
MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
=head1 METHODS
=over 4
=item C<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.
=item C<agg_ports_pagp>
Unimplemented. Returns an empty HASH reference.
=back
=cut

141
Info/IEEE802dot3ag.pm Normal file
View File

@@ -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<IEEE8023-LAG-MIB>.
Use or create in a subclass of SNMP::Info. Do not use directly.
=head2 Inherited Classes
L<SNMP::Info::Aggregate>
=head2 Required MIBs
=over
=item F<IEEE8023-LAG-MIB>
=back
=head1 METHODS
=over 4
=item C<agg_ports_lag>
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

View File

@@ -36,9 +36,14 @@ use Exporter;
use SNMP::Info::Layer3; use SNMP::Info::Layer3;
use SNMP::Info::MAU; use SNMP::Info::MAU;
use SNMP::Info::LLDP; use SNMP::Info::LLDP;
use SNMP::Info::Aggregate;
@SNMP::Info::Layer3::Arista::ISA = qw/SNMP::Info::LLDP SNMP::Info::MAU @SNMP::Info::Layer3::Arista::ISA = qw/
SNMP::Info::Layer3 Exporter/; SNMP::Info::Aggregate
SNMP::Info::LLDP
SNMP::Info::MAU
SNMP::Info::Layer3 Exporter
/;
@SNMP::Info::Layer3::Arista::EXPORT_OK = qw//; @SNMP::Info::Layer3::Arista::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
@@ -49,6 +54,7 @@ $VERSION = '3.10';
%SNMP::Info::Layer3::MIBS, %SNMP::Info::Layer3::MIBS,
%SNMP::Info::MAU::MIBS, %SNMP::Info::MAU::MIBS,
%SNMP::Info::LLDP::MIBS, %SNMP::Info::LLDP::MIBS,
%SNMP::Info::Aggregate::MIBS,
'ARISTA-PRODUCTS-MIB' => 'aristaProducts', 'ARISTA-PRODUCTS-MIB' => 'aristaProducts',
); );
@@ -125,6 +131,8 @@ sub lldp_if {
return $lldp_if; return $lldp_if;
} }
sub agg_ports { return agg_ports_ifstack(@_) }
1; 1;
__END__ __END__
@@ -160,6 +168,8 @@ Subclass for Arista Networks EOS-based devices
=over =over
=item SNMP::Info::Aggregate
=item SNMP::Info::Layer3 =item SNMP::Info::Layer3
=item SNMP::Info::MAU =item SNMP::Info::MAU
@@ -178,6 +188,8 @@ Subclass for Arista Networks EOS-based devices
See L<SNMP::Info::Layer3/"Required MIBs"> for its own MIB requirements. See L<SNMP::Info::Layer3/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::Aggregate/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::MAU/"Required MIBs"> for its own MIB requirements. See L<SNMP::Info::MAU/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::LLDP/"Required MIBs"> for its own MIB requirements. See L<SNMP::Info::LLDP/"Required MIBs"> for its own MIB requirements.
@@ -241,6 +253,12 @@ Returns info from F<MAU-MIB>
Returns the mapping to the SNMP Interface Table. Returns the mapping to the SNMP Interface Table.
=item C<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 =back
=head2 Table Methods imported from SNMP::Info::Layer3 =head2 Table Methods imported from SNMP::Info::Layer3

View File

@@ -43,12 +43,14 @@ use SNMP::Info::CiscoPower;
use SNMP::Info::Layer3; use SNMP::Info::Layer3;
use SNMP::Info::CiscoStpExtensions; use SNMP::Info::CiscoStpExtensions;
use SNMP::Info::CiscoVTP; use SNMP::Info::CiscoVTP;
use SNMP::Info::CiscoAgg;
use SNMP::Info::MAU; use SNMP::Info::MAU;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
# NOTE : Top-most items gets precedence for @ISA # NOTE : Top-most items gets precedence for @ISA
@SNMP::Info::Layer3::C6500::ISA = qw/ @SNMP::Info::Layer3::C6500::ISA = qw/
SNMP::Info::CiscoAgg
SNMP::Info::CiscoVTP SNMP::Info::CiscoVTP
SNMP::Info::CiscoStpExtensions SNMP::Info::CiscoStpExtensions
SNMP::Info::CiscoStack SNMP::Info::CiscoStack
@@ -89,6 +91,7 @@ $VERSION = '3.10';
%SNMP::Info::CiscoStack::MIBS, %SNMP::Info::CiscoStack::MIBS,
%SNMP::Info::CiscoStpExtensions::MIBS, %SNMP::Info::CiscoStpExtensions::MIBS,
%SNMP::Info::CiscoVTP::MIBS, %SNMP::Info::CiscoVTP::MIBS,
%SNMP::Info::CiscoAgg::MIBS,
'CISCO-VIRTUAL-SWITCH-MIB' => 'cvsSwitchMode', 'CISCO-VIRTUAL-SWITCH-MIB' => 'cvsSwitchMode',
); );
@@ -309,6 +312,8 @@ after determining a more specific class using the method above.
=over =over
=item SNMP::Info::CiscoAgg
=item SNMP::Info::CiscoVTP =item SNMP::Info::CiscoVTP
=item SNMP::Info::CiscoStack =item SNMP::Info::CiscoStack
@@ -337,6 +342,8 @@ after determining a more specific class using the method above.
=item Inherited Classes' MIBs =item Inherited Classes' MIBs
See L<SNMP::Info::CiscoAgg/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::CiscoVTP/"Required MIBs"> for its own MIB requirements. See L<SNMP::Info::CiscoVTP/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::CiscoStack/"Required MIBs"> for its own MIB requirements. See L<SNMP::Info::CiscoStack/"Required MIBs"> for its own MIB requirements.

View File

@@ -38,8 +38,12 @@ use SNMP::Info::Layer3;
use SNMP::Info::FDP; use SNMP::Info::FDP;
use SNMP::Info::LLDP; use SNMP::Info::LLDP;
@SNMP::Info::Layer3::Foundry::ISA = qw/SNMP::Info::FDP SNMP::Info::LLDP @SNMP::Info::Layer3::Foundry::ISA = qw/
SNMP::Info::Layer3 Exporter/; SNMP::Info::FDP
SNMP::Info::LLDP
SNMP::Info::Layer3
Exporter
/;
@SNMP::Info::Layer3::Foundry::EXPORT_OK = qw//; @SNMP::Info::Layer3::Foundry::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/;
@@ -50,17 +54,20 @@ $VERSION = '3.10';
%SNMP::Info::Layer3::MIBS, %SNMP::Info::Layer3::MIBS,
%SNMP::Info::LLDP::MIBS, %SNMP::Info::LLDP::MIBS,
%SNMP::Info::FDP::MIBS, %SNMP::Info::FDP::MIBS,
'FOUNDRY-SN-ROOT-MIB' => 'foundry', 'FOUNDRY-SN-ROOT-MIB' => 'foundry',
'FOUNDRY-SN-AGENT-MIB' => 'snChasPwrSupplyDescription', 'FOUNDRY-SN-AGENT-MIB' => 'snChasPwrSupplyDescription',
'FOUNDRY-SN-SWITCH-GROUP-MIB' => 'snSwGroupOperMode', 'FOUNDRY-SN-SWITCH-GROUP-MIB' => 'snSwGroupOperMode',
'FOUNDRY-SN-STACKING-MIB' => 'snStackingOperUnitRole', 'FOUNDRY-SN-STACKING-MIB' => 'snStackingOperUnitRole',
'FOUNDRY-POE-MIB' => 'snAgentPoeGblPowerCapacityTotal', 'FOUNDRY-POE-MIB' => 'snAgentPoeGblPowerCapacityTotal',
'FOUNDRY-SN-SWITCH-GROUP-MIB' => 'snSwGroupOperMode',
); );
%GLOBALS = ( %GLOBALS = (
%SNMP::Info::Layer3::GLOBALS, %SNMP::Info::Layer3::GLOBALS,
%SNMP::Info::LLDP::GLOBALS, %SNMP::Info::LLDP::GLOBALS,
%SNMP::Info::FDP::GLOBALS, %SNMP::Info::FDP::GLOBALS,
'mac' => 'ifPhysAddress.1', 'mac' => 'ifPhysAddress.1',
'chassis' => 'entPhysicalDescr.1', 'chassis' => 'entPhysicalDescr.1',
'temp' => 'snChasActualTemperature', 'temp' => 'snChasActualTemperature',
@@ -93,8 +100,10 @@ $VERSION = '3.10';
); );
%MUNGE = ( %MUNGE = (
%SNMP::Info::Layer3::MUNGE, %SNMP::Info::LLDP::MUNGE, %SNMP::Info::Layer3::MUNGE,
%SNMP::Info::LLDP::MUNGE,
%SNMP::Info::FDP::MUNGE, %SNMP::Info::FDP::MUNGE,
'ag_mod2_type' => \&SNMP::Info::munge_e_type, 'ag_mod2_type' => \&SNMP::Info::munge_e_type,
'ag_mod_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; 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; 1;
__END__ __END__
@@ -848,6 +880,8 @@ after determining a more specific class using the method above.
=item F<FOUNDRY-POE-MIB> =item F<FOUNDRY-POE-MIB>
=item F<FOUNDRY-SN-SWITCH-GROUP-MIB>
=item Inherited Classes' MIBs =item Inherited Classes' MIBs
See L<SNMP::Info::Layer3/"Required MIBs"> for its own MIB requirements. See L<SNMP::Info::Layer3/"Required MIBs"> for its own MIB requirements.
@@ -982,6 +1016,12 @@ Skipped if device is an EdgeIron 24G due to reports of hangs.
(C<dot1dStpPortState>) (C<dot1dStpPortState>)
=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 =back
=head2 F<ENTITY-MIB> Information =head2 F<ENTITY-MIB> Information

View File

@@ -583,6 +583,20 @@ sub bp_index {
foreach my $iid ( keys %$if_index ) { foreach my $iid ( keys %$if_index ) {
$bp_index{$iid} = $iid; $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; return \%bp_index;
} }

View File

@@ -148,6 +148,11 @@ $VERSION = '3.10';
'rc2k_mda_part' => 'rc2kMdaCardPartNumber', 'rc2k_mda_part' => 'rc2kMdaCardPartNumber',
'rc2k_mda_date' => 'rc2kMdaCardDateCode', 'rc2k_mda_date' => 'rc2kMdaCardDateCode',
'rc2k_mda_dev' => 'rc2kMdaCardDeviations', 'rc2k_mda_dev' => 'rc2kMdaCardDeviations',
# From RAPID-CITY::rcMltTable
'rc_mlt_ports' => 'rcMltPortMembers',
'rc_mlt_index' => 'rcMltIfIndex',
'rc_mlt_dp' => 'rcMltDesignatedPort',
); );
%MUNGE = ( %MUNGE = (
@@ -156,6 +161,7 @@ $VERSION = '3.10';
'rc_cpu_mac' => \&SNMP::Info::munge_mac, 'rc_cpu_mac' => \&SNMP::Info::munge_mac,
'rc_vlan_members' => \&SNMP::Info::munge_port_list, 'rc_vlan_members' => \&SNMP::Info::munge_port_list,
'rc_vlan_no_join' => \&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 # Need to override here since overridden in Layer2 and Layer3 classes
@@ -566,6 +572,35 @@ sub _validate_vlan_param {
return 1; 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; 1;
__END__ __END__
@@ -717,6 +752,12 @@ Returns VLAN IDs
(C<rcVlanId>) (C<rcVlanId>)
=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 =back
=head2 RAPID-CITY Port Table (C<rcPortTable>) =head2 RAPID-CITY Port Table (C<rcPortTable>)