Moved older HP Procurve switch models to separate L2:HP4000 class. Reimplemented VLAN changing for Procurve switches; several updates to MODEL_MAP.
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
SNMP::Info - Friendly OO-style interface to Network devices using SNMP.
|
||||
ChangeLog $Id$
|
||||
|
||||
version 2.02 ()
|
||||
+ Support for older HP switch models moved to new L2::HP4000 class
|
||||
+ Fix VLAN changing in L2::HP and L2::HP4000 classes
|
||||
* Updated model lists in HP classes
|
||||
|
||||
version 2.01 (06/12/09)
|
||||
+ Added CiscoStpExtensions Class (Carlos Vicente)
|
||||
+ Added Layer3::Arista (fenner)
|
||||
|
||||
@@ -512,30 +512,43 @@ device: FLS624, FLS648
|
||||
# HP
|
||||
#
|
||||
device-vendor: HP
|
||||
class: Layer2::HP
|
||||
note: HP Devices are very widely supported.
|
||||
ver: 2
|
||||
modules: yes
|
||||
|
||||
device-family: HP ProCurve
|
||||
device-family: HP ProCurve (old)
|
||||
class: Layer2::HP4000
|
||||
duplex: both
|
||||
macsuck: yes
|
||||
arpnip: no
|
||||
cdp: yes
|
||||
vlan: write
|
||||
note: CDP and LLDP support are very firmware version dependent
|
||||
note: This list hasn't been updated since 2003
|
||||
note: devices in this class only have CDP support
|
||||
note: VLAN info in HP-VLAN MIB
|
||||
|
||||
device: 2512, 2524
|
||||
ver: 1
|
||||
|
||||
device: 4000,4104GL
|
||||
device: 1600M,2400,2424M,4000,8000
|
||||
duplex: link
|
||||
note: duplex issues?
|
||||
|
||||
device: 4108GL,8000,2626,2650,8000
|
||||
device-family: HP ProCurve (recent)
|
||||
class: Layer2::HP
|
||||
duplex: both
|
||||
macsuck: yes
|
||||
arpnip: no
|
||||
cdp: yes
|
||||
vlan: write
|
||||
note: old firmware versions only have CDP support, more recent have LLDP
|
||||
note: VLAN info in Q-BRIDGE-MIB
|
||||
|
||||
device: 2312,2324,2512,2524
|
||||
ver: 1
|
||||
|
||||
device: 2510,2600,2610,2800,2810,2900,2910al
|
||||
device: 3124,3324XL,3400cl,3500,3500yl
|
||||
device: 4100GL,4200vl,5300XL,5400yy,5400zl
|
||||
device: 6108,6200yl,6400cl,6410cl,6600,6600ml,8200zl
|
||||
|
||||
|
||||
#
|
||||
# Juniper
|
||||
#
|
||||
|
||||
22
Info.pm
22
Info.pm
@@ -23,7 +23,7 @@ use vars
|
||||
qw/$VERSION $VERSION_CVS %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG %SPEED_MAP
|
||||
$NOSUCH $BIGINT $REPEATERS/;
|
||||
|
||||
$VERSION = '2.01';
|
||||
$VERSION = '2.02-cvs';
|
||||
$VERSION_CVS = '$Id$';
|
||||
|
||||
=head1 NAME
|
||||
@@ -523,12 +523,20 @@ Depreciated. Use SNMP::Info::Layer3::Foundry.
|
||||
|
||||
=item SNMP::Info::Layer2::HP
|
||||
|
||||
Subclass for HP Procurve Switches
|
||||
Subclass for more recent HP Procurve Switches
|
||||
|
||||
Requires F<HP-ICF-OID> and F<ENTITY-MIB> downloaded from HP.
|
||||
|
||||
See documentation in L<SNMP::Info::Layer2::HP> for details.
|
||||
|
||||
=item SNMP::Info::Layer2::HP4000
|
||||
|
||||
Subclass for older HP Procurve Switches
|
||||
|
||||
Requires F<HP-ICF-OID> and F<ENTITY-MIB> downloaded from HP.
|
||||
|
||||
See documentation in L<SNMP::Info::Layer2::HP4000> for details.
|
||||
|
||||
=item SNMP::Info::Layer2::N2270
|
||||
|
||||
Subclass for Nortel 2270 wireless switches.
|
||||
@@ -668,7 +676,7 @@ See documentation in L<SNMP::Info::Layer3::Foundry> for details.
|
||||
=item SNMP::Info::Layer3::HP9300
|
||||
|
||||
Subclass for HP network devices which Foundry Networks was the
|
||||
Original Equipment Manufacturer (OEM) such as the HP ProCurve 9300 series.
|
||||
Original Equipment Manufacturer (OEM) such as the HP ProCurve 9300 and 6300 series.
|
||||
|
||||
See documentation in L<SNMP::Info::Layer3::HP9300> for details.
|
||||
|
||||
@@ -1235,6 +1243,10 @@ sub device_type {
|
||||
$objtype = 'SNMP::Info::Layer3::C6500'
|
||||
if $desc =~ /(s72033_rp|s3223_rp|s32p3_rp|s222_rp)/;
|
||||
|
||||
# HP, older ProCurve models (1600, 2400, 2424m, 4000, 8000)
|
||||
$objtype = 'SNMP::Info::Layer2::HP4000'
|
||||
if $desc =~ /\b(J4093A|J4110A|J4120A|J4121A|J4122A|J4122B)\b/;
|
||||
|
||||
# HP, Foundry OEM
|
||||
$objtype = 'SNMP::Info::Layer3::HP9300'
|
||||
if $desc =~ /\b(J4874A|J4138A|J4139A|J4840A|J4841A)\b/;
|
||||
@@ -1296,6 +1308,10 @@ sub device_type {
|
||||
$objtype = 'SNMP::Info::Layer3::C6500'
|
||||
if ( $desc =~ /(C2970|C2960)/ );
|
||||
|
||||
# HP, older ProCurve models (1600, 2400, 2424m, 4000, 8000)
|
||||
$objtype = 'SNMP::Info::Layer2::HP4000'
|
||||
if $desc =~ /\b(J4093A|J4110A|J4120A|J4121A|J4122A|J4122B)\b/;
|
||||
|
||||
# HP, Foundry OEM
|
||||
$objtype = 'SNMP::Info::Layer3::HP9300'
|
||||
if $desc =~ /\b(J4874A|J4138A|J4139A|J4840A|J4841A)\b/;
|
||||
|
||||
@@ -46,7 +46,7 @@ use SNMP::Info::CDP;
|
||||
|
||||
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %PORTSTAT %MODEL_MAP %MUNGE/;
|
||||
|
||||
$VERSION = '2.01';
|
||||
$VERSION = '2.02-cvs';
|
||||
|
||||
%MIBS = (
|
||||
%SNMP::Info::Layer3::MIBS,
|
||||
@@ -55,11 +55,9 @@ $VERSION = '2.01';
|
||||
%SNMP::Info::CDP::MIBS,
|
||||
'RFC1271-MIB' => 'logDescription',
|
||||
'HP-ICF-OID' => 'hpSwitch4000',
|
||||
'HP-VLAN' => 'hpVlanMemberIndex',
|
||||
'STATISTICS-MIB' => 'hpSwitchCpuStat',
|
||||
'NETSWITCH-MIB' => 'hpMsgBufFree',
|
||||
'CONFIG-MIB' => 'hpSwitchConfig',
|
||||
'SEMI-MIB' => 'hpHttpMgSerialNumber',
|
||||
'HP-ICF-CHASSIS' => 'hpicfSensorObjectId',
|
||||
);
|
||||
|
||||
@@ -69,7 +67,6 @@ $VERSION = '2.01';
|
||||
%SNMP::Info::LLDP::GLOBALS,
|
||||
%SNMP::Info::CDP::GLOBALS,
|
||||
'serial1' => 'entPhysicalSerialNum.1',
|
||||
'serial2' => 'hpHttpMgSerialNumber.0',
|
||||
'hp_cpu' => 'hpSwitchCpuStat.0',
|
||||
'hp_mem_total' => 'hpGlobalMemTotalBytes.1',
|
||||
'mem_free' => 'hpGlobalMemFreeBytes.1',
|
||||
@@ -77,7 +74,6 @@ $VERSION = '2.01';
|
||||
'os_version' => 'hpSwitchOsVersion.0',
|
||||
'os_bin' => 'hpSwitchRomVersion.0',
|
||||
'mac' => 'hpSwitchBaseMACAddress.0',
|
||||
'hp_vlans' => 'hpVlanNumber',
|
||||
);
|
||||
|
||||
%FUNCS = (
|
||||
@@ -85,22 +81,11 @@ $VERSION = '2.01';
|
||||
%SNMP::Info::MAU::FUNCS,
|
||||
%SNMP::Info::LLDP::FUNCS,
|
||||
%SNMP::Info::CDP::FUNCS,
|
||||
'bp_index2' => 'dot1dBasePortIfIndex',
|
||||
'i_type2' => 'ifType',
|
||||
|
||||
# RFC1271
|
||||
'l_descr' => 'logDescription',
|
||||
|
||||
# HP-VLAN-MIB
|
||||
'hp_v_index' => 'hpVlanDot1QID',
|
||||
'hp_v_name' => 'hpVlanIdentName',
|
||||
'hp_v_state' => 'hpVlanIdentState',
|
||||
'hp_v_type' => 'hpVlanIdentType',
|
||||
'hp_v_status' => 'hpVlanIdentStatus',
|
||||
'hp_v_mac' => 'hpVlanAddrPhysAddress',
|
||||
'hp_v_if_index' => 'hpVlanMemberIndex',
|
||||
'hp_v_if_tag' => 'hpVlanMemberTagged2',
|
||||
|
||||
# CONFIG-MIB::hpSwitchPortTable
|
||||
'hp_duplex' => 'hpSwitchPortEtherMode',
|
||||
'hp_duplex_admin' => 'hpSwitchPortFastEtherMode',
|
||||
@@ -120,65 +105,86 @@ $VERSION = '2.01';
|
||||
'c_id' => \&munge_hp_c_id,
|
||||
);
|
||||
|
||||
|
||||
# Model map, reverse sorted by common model name (sort -k2 -r)
|
||||
# Potential sources for model information: http://www.hp.com/rnd/software/switches.htm or HP-ICF-OID MIB
|
||||
%MODEL_MAP = (
|
||||
'J4093A' => '2424M',
|
||||
'J4110A' => '8000M',
|
||||
'J4120A' => '1600M',
|
||||
'J4121A' => '4000M',
|
||||
'J4122A' => '2400M',
|
||||
'J4122B' => '2424M',
|
||||
'J4138A' => '9308M',
|
||||
'J4139A' => '9304M',
|
||||
'J4812A' => '2512',
|
||||
'J4813A' => '2524',
|
||||
'J4815A' => '3324XL',
|
||||
'J4819A' => '5308XL',
|
||||
'J4840A' => '6308M-SX',
|
||||
'J4841A' => '6208M-SX',
|
||||
'J4850A' => '5304XL',
|
||||
'J4851A' => '3124',
|
||||
'J4865A' => '4108GL',
|
||||
'J4874A' => '9315M',
|
||||
'J4887A' => '4104GL',
|
||||
'J4899A' => '2650',
|
||||
'J4899B' => '2650-CR',
|
||||
'J4900A' => '2626',
|
||||
'J4900B' => '2626-CR',
|
||||
'J4902A' => '6108',
|
||||
'J4903A' => '2824',
|
||||
'J4904A' => '2848',
|
||||
'J4905A' => '3400cl-24G',
|
||||
'J4906A' => '3400cl-48G',
|
||||
'J8130A' => 'WAP-420-NA',
|
||||
'J8131A' => 'WAP-420-WW',
|
||||
'J8130A' => 'WAP-420-NA',
|
||||
'J8133A' => 'AP520WL',
|
||||
'J8164A' => '2626-PWR',
|
||||
'J8165A' => '2650-PWR',
|
||||
'J8433A' => 'CX4-6400cl-6XG',
|
||||
'J8474A' => 'MF-6400cl-6XG',
|
||||
'J8680A' => '9608sl',
|
||||
'J8692A' => '3500yl-24G-PWR',
|
||||
'J8693A' => '3500yl-48G-PWR',
|
||||
'J8697A' => '5406zl',
|
||||
'J8698A' => '5412zl',
|
||||
'J8718A' => '5404yl',
|
||||
'J8719A' => '5408yl',
|
||||
'J8770A' => '4204vl',
|
||||
'J8771A' => '4202vl-48G',
|
||||
'J8772A' => '4202vl-72',
|
||||
'J8773A' => '4208vl',
|
||||
'J8762A' => '2600-8-PWR',
|
||||
'J8680A' => '9408sl',
|
||||
'J9091A' => '8212zl',
|
||||
'J9475A' => '8206zl',
|
||||
'J9265A' => '6600ml-24XG',
|
||||
'J9264A' => '6600ml-24G-4XG',
|
||||
'J9263A' => '6600ml-24G',
|
||||
'J9452A' => '6600-48G-4XG',
|
||||
'J9451A' => '6600-48G',
|
||||
'J8474A' => '6410cl-6XG',
|
||||
'J8433A' => '6400cl-6XG',
|
||||
'J8992A' => '6200yl-24G',
|
||||
'J9019A' => '2510-24A',
|
||||
'J9020A' => '2510-48A',
|
||||
'J9021A' => '2810-24G',
|
||||
'J9022A' => '2810-48G',
|
||||
'J9028A' => '1800-24G',
|
||||
'J9029A' => '1800-8G',
|
||||
'J4902A' => '6108',
|
||||
'J8698A' => '5412zl',
|
||||
'J8719A' => '5408yl',
|
||||
'J8697A' => '5406zl',
|
||||
'J8718A' => '5404yl',
|
||||
'J4819A' => '5308XL',
|
||||
'J4850A' => '5304XL',
|
||||
'J8773A' => '4208vl',
|
||||
'J8770A' => '4204vl',
|
||||
'J8772A' => '4202vl-72',
|
||||
'J9032A' => '4202vl-68G',
|
||||
'J9031A' => '4202vl-68',
|
||||
'J8771A' => '4202vl-48G',
|
||||
'J4865A' => '4108GL',
|
||||
'J4887A' => '4104GL',
|
||||
'J8693A' => '3500yl-48G-PWR',
|
||||
'J8692A' => '3500yl-24G-PWR',
|
||||
'J9473A' => '3500-48-PoE',
|
||||
'J9472A' => '3500-48',
|
||||
'J9471A' => '3500-24-PoE',
|
||||
'J9470A' => '3500-24',
|
||||
'J4906A' => '3400cl-48G',
|
||||
'J4905A' => '3400cl-24G',
|
||||
'J4815A' => '3324XL',
|
||||
'J4851A' => '3124',
|
||||
'J9148A' => '2910al-48G-PoE+',
|
||||
'J9147A' => '2910al-48G',
|
||||
'J9146A' => '2910al-24G-PoE+',
|
||||
'J9145A' => '2910al-24G',
|
||||
'J9050A' => '2900-48G',
|
||||
'J9049A' => '2900-24G',
|
||||
'J9032A' => '4202vl-68G',
|
||||
'J9091A' => '8212zl',
|
||||
'J4904A' => '2848',
|
||||
'J4903A' => '2824',
|
||||
'J9022A' => '2810-48G',
|
||||
'J9021A' => '2810-24G',
|
||||
'J8165A' => '2650-PWR',
|
||||
'J4899B' => '2650-CR',
|
||||
'J4899C' => '2650C',
|
||||
'J4899A' => '2650',
|
||||
'J8164A' => '2626-PWR',
|
||||
'J4900B' => '2626-CR',
|
||||
'J4900C' => '2626C',
|
||||
'J4900A' => '2626',
|
||||
'J9089A' => '2610-48-PWR',
|
||||
'J9088A' => '2610-48',
|
||||
'J9087A' => '2610-24-PWR',
|
||||
'J9086A' => '2610-24/12PWR',
|
||||
'J9085A' => '2610-24',
|
||||
'J8762A' => '2600-8-PWR',
|
||||
'J4813A' => '2524',
|
||||
'J9137A' => '2520-8-PoE',
|
||||
'J9138A' => '2520-24-PoE',
|
||||
'J4812A' => '2512',
|
||||
'J9280A' => '2510G-48',
|
||||
'J9279A' => '2510G-24',
|
||||
'J9020A' => '2510-48A',
|
||||
'J9019B' => '2510-24B',
|
||||
'J9019A' => '2510-24A',
|
||||
'J4818A' => '2324',
|
||||
'J4817A' => '2312',
|
||||
'J9029A' => '1800-8G',
|
||||
'J9028A' => '1800-24G',
|
||||
);
|
||||
|
||||
# Method Overrides
|
||||
@@ -223,15 +229,6 @@ sub model {
|
||||
return defined $MODEL_MAP{$model} ? $MODEL_MAP{$model} : $model;
|
||||
}
|
||||
|
||||
# Some have the serial in entity mib, some have it in SEMI-MIB::hphttpmanageable
|
||||
sub serial {
|
||||
my $hp = shift;
|
||||
|
||||
my $serial = $hp->serial1() || $hp->serial2() || undef;
|
||||
|
||||
return $serial;
|
||||
}
|
||||
|
||||
sub interfaces {
|
||||
my $hp = shift;
|
||||
my $interfaces = $hp->i_index();
|
||||
@@ -371,116 +368,7 @@ sub _sensor {
|
||||
return $result;
|
||||
}
|
||||
|
||||
# Bridge MIB does not map Bridge Port to ifIndex correctly on all models
|
||||
sub bp_index {
|
||||
my $hp = shift;
|
||||
my $partial = shift;
|
||||
|
||||
my $if_index = $hp->i_index($partial);
|
||||
my $model = $hp->model();
|
||||
my $bp_index = $hp->bp_index2($partial);
|
||||
|
||||
unless ( defined $model and $model =~ /(1600|2424|4000|8000)/ ) {
|
||||
return $bp_index;
|
||||
}
|
||||
|
||||
my %mod_bp_index;
|
||||
foreach my $iid ( keys %$if_index ) {
|
||||
$mod_bp_index{$iid} = $iid;
|
||||
}
|
||||
return \%mod_bp_index;
|
||||
}
|
||||
|
||||
# VLAN methods. Newer HPs use Q-BRIDGE, older use proprietary MIB. Use
|
||||
# Q-BRIDGE if available.
|
||||
|
||||
sub v_index {
|
||||
my $hp = shift;
|
||||
my $partial = shift;
|
||||
|
||||
# Newer devices
|
||||
my $q_index = $hp->SUPER::v_index($partial);
|
||||
if ( defined $q_index and scalar( keys %$q_index ) ) {
|
||||
return $q_index;
|
||||
}
|
||||
|
||||
# Older devices
|
||||
return $hp->hp_v_index($partial);
|
||||
}
|
||||
|
||||
sub v_name {
|
||||
my $hp = shift;
|
||||
my $partial = shift;
|
||||
|
||||
# Newer devices
|
||||
my $q_name = $hp->SUPER::v_name($partial);
|
||||
if ( defined $q_name and scalar( keys %$q_name ) ) {
|
||||
return $q_name;
|
||||
}
|
||||
|
||||
# Older devices
|
||||
return $hp->hp_v_name($partial);
|
||||
}
|
||||
|
||||
sub i_vlan {
|
||||
my $hp = shift;
|
||||
|
||||
# Newer devices use Q-BRIDGE-MIB
|
||||
my $qb_i_vlan = $hp->SUPER::i_vlan();
|
||||
if ( defined $qb_i_vlan and scalar( keys %$qb_i_vlan ) ) {
|
||||
return $qb_i_vlan;
|
||||
}
|
||||
|
||||
# HP4000 ... get it from HP-VLAN
|
||||
# the hpvlanmembertagged2 table has an entry in the form of
|
||||
# vlan.interface = /untagged/no/tagged/auto
|
||||
my $i_vlan = {};
|
||||
my $hp_v_index = $hp->hp_v_index();
|
||||
my $hp_v_if_tag = $hp->hp_v_if_tag();
|
||||
foreach my $row ( keys %$hp_v_if_tag ) {
|
||||
my ( $index, $if ) = split( /\./, $row );
|
||||
|
||||
my $tag = $hp_v_if_tag->{$row};
|
||||
my $vlan = $hp_v_index->{$index};
|
||||
|
||||
next unless ( defined $tag and $tag =~ /untagged/ );
|
||||
|
||||
$i_vlan->{$if} = $vlan if defined $vlan;
|
||||
}
|
||||
|
||||
return $i_vlan;
|
||||
}
|
||||
|
||||
sub i_vlan_membership {
|
||||
my $hp = shift;
|
||||
|
||||
# Newer devices use Q-BRIDGE-MIB
|
||||
my $qb_i_vlan = $hp->SUPER::i_vlan_membership();
|
||||
if ( defined $qb_i_vlan and scalar( keys %$qb_i_vlan ) ) {
|
||||
return $qb_i_vlan;
|
||||
}
|
||||
|
||||
# Older get it from HP-VLAN
|
||||
my $i_vlan_membership = {};
|
||||
my $hp_v_index = $hp->hp_v_index();
|
||||
my $hp_v_if_tag = $hp->hp_v_if_tag();
|
||||
foreach my $row ( keys %$hp_v_if_tag ) {
|
||||
my ( $index, $if ) = split( /\./, $row );
|
||||
|
||||
my $tag = $hp_v_if_tag->{$row};
|
||||
my $vlan = $hp_v_index->{$index};
|
||||
|
||||
next unless ( defined $tag );
|
||||
next if ( $tag eq 'no' );
|
||||
|
||||
push( @{ $i_vlan_membership->{$if} }, $vlan );
|
||||
}
|
||||
|
||||
return $i_vlan_membership;
|
||||
}
|
||||
|
||||
# Use CDP and/or LLDP
|
||||
|
||||
sub hasCDP {
|
||||
my $hp = shift;
|
||||
|
||||
@@ -639,6 +527,75 @@ sub peth_port_ifindex {
|
||||
return $peth_port_ifindex;
|
||||
}
|
||||
|
||||
sub set_i_vlan {
|
||||
my $hp = shift;
|
||||
my $rv;
|
||||
|
||||
my $qb_i_vlan = $hp->qb_i_vlan_t();
|
||||
if (defined $qb_i_vlan and scalar(keys %$qb_i_vlan)){
|
||||
my $vlan = shift;
|
||||
my $iid = shift;
|
||||
|
||||
my $qb_v_egress = $hp->qb_v_egress();
|
||||
if (defined $qb_v_egress and scalar($qb_v_egress->{$vlan})) {
|
||||
# store current untagged VLAN to remove it from the port list later
|
||||
my $old_untagged = $qb_i_vlan->{$iid};
|
||||
|
||||
# set new untagged / native VLAN
|
||||
$rv = $hp->set_qb_i_vlan($vlan, $iid);
|
||||
|
||||
# If change is successful, the old native VLAN will now be a tagged VLAN on the port. This is generally not what we want.
|
||||
# We'll have to remove this VLAN from the "egress list" on the port.
|
||||
if (defined $rv and $old_untagged != $vlan) {
|
||||
if (defined $old_untagged and defined $qb_v_egress and scalar($qb_v_egress->{$vlan})){
|
||||
|
||||
# First, get the egress list of the old native VLAN (arrayref structure)
|
||||
my $egressports = $qb_v_egress->{$old_untagged};
|
||||
|
||||
# Since arrays are zero-based, we have to change the element at Index - 1
|
||||
$egressports->[$iid-1] = "0";
|
||||
|
||||
# After changing, pack the array into a binary structure (expected by set_qb_v_egress) and set the new value on the device.
|
||||
my $new_egresslist = pack("B*", join('', @$egressports));
|
||||
|
||||
$rv = $hp->set_qb_v_egress($new_egresslist, $old_untagged);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$hp->error_throw(sprintf("Requested VLAN %s doesn't seem to exist on device...", $vlan));
|
||||
}
|
||||
}
|
||||
return $rv;
|
||||
}
|
||||
|
||||
sub set_i_vlan_tagged {
|
||||
my $hp = shift;
|
||||
my $rv;
|
||||
|
||||
my $qb_i_vlan = $hp->qb_i_vlan_t();
|
||||
if (defined $qb_i_vlan and scalar(keys %$qb_i_vlan)){
|
||||
my $vlan = shift;
|
||||
my $iid = shift;
|
||||
|
||||
my $qb_v_egress = $hp->qb_v_egress();
|
||||
if (defined $qb_v_egress and scalar($qb_v_egress->{$vlan})) {
|
||||
|
||||
# First, get the egress list of the VLAN we want to add to the port.
|
||||
my $egressports = $qb_v_egress->{$vlan};
|
||||
|
||||
# Since arrays are zero-based, we have to change the element at Index - 1
|
||||
$egressports->[$iid-1] = "1";
|
||||
|
||||
# After changing, pack the array into a binary structure (expected by set_qb_v_egress) and set the new value on the device.
|
||||
my $new_egresslist = pack("B*", join('', @$egressports));
|
||||
$rv = $hp->set_qb_v_egress($new_egresslist, $vlan);
|
||||
return $rv;
|
||||
} else {
|
||||
$hp->error_throw(sprintf("Requested VLAN %s doesn't seem to exist on device...", $vlan));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
@@ -701,8 +658,6 @@ Included in V2 mibs from Cisco
|
||||
|
||||
=item F<HP-ICF-OID>
|
||||
|
||||
=item F<HP-VLAN>
|
||||
|
||||
(this MIB new with SNMP::Info 0.8)
|
||||
|
||||
=item F<STATISTICS-MIB>
|
||||
@@ -713,7 +668,7 @@ Included in V2 mibs from Cisco
|
||||
|
||||
=back
|
||||
|
||||
The last five MIBs listed are from HP and can be found at
|
||||
The last four MIBs listed are from HP and can be found at
|
||||
L<http://www.hp.com/rnd/software> or
|
||||
L<http://www.hp.com/rnd/software/MIBs.htm>
|
||||
|
||||
@@ -754,66 +709,84 @@ Returns bytes of used memory
|
||||
Returns the model number of the HP Switch. Will translate between the HP Part
|
||||
number and the common model number with this map :
|
||||
|
||||
%MODEL_MAP = (
|
||||
'J4093A' => '2424M',
|
||||
'J4110A' => '8000M',
|
||||
'J4120A' => '1600M',
|
||||
'J4121A' => '4000M',
|
||||
'J4122A' => '2400M',
|
||||
'J4122B' => '2424M',
|
||||
'J4138A' => '9308M',
|
||||
'J4139A' => '9304M',
|
||||
'J4812A' => '2512',
|
||||
'J4813A' => '2524',
|
||||
'J4815A' => '3324XL',
|
||||
'J4819A' => '5308XL',
|
||||
'J4840A' => '6308M-SX',
|
||||
'J4841A' => '6208M-SX',
|
||||
'J4850A' => '5304XL',
|
||||
'J4851A' => '3124',
|
||||
'J4865A' => '4108GL',
|
||||
'J4874A' => '9315M',
|
||||
'J4887A' => '4104GL',
|
||||
'J4899A' => '2650',
|
||||
'J4899B' => '2650-CR',
|
||||
'J4900A' => '2626',
|
||||
'J4900B' => '2626-CR',
|
||||
'J4902A' => '6108',
|
||||
'J4903A' => '2824',
|
||||
'J4904A' => '2848',
|
||||
'J4905A' => '3400cl-24G',
|
||||
'J4906A' => '3400cl-48G',
|
||||
'J8130A' => 'WAP-420-NA',
|
||||
%MODEL_MAP = (
|
||||
'J8131A' => 'WAP-420-WW',
|
||||
'J8130A' => 'WAP-420-NA',
|
||||
'J8133A' => 'AP520WL',
|
||||
'J8164A' => '2626-PWR',
|
||||
'J8165A' => '2650-PWR',
|
||||
'J8433A' => 'CX4-6400cl-6XG',
|
||||
'J8474A' => 'MF-6400cl-6XG',
|
||||
'J8680A' => '9608sl',
|
||||
'J8692A' => '3500yl-24G-PWR',
|
||||
'J8693A' => '3500yl-48G-PWR',
|
||||
'J8697A' => '5406zl',
|
||||
'J8698A' => '5412zl',
|
||||
'J8718A' => '5404yl',
|
||||
'J8719A' => '5408yl',
|
||||
'J8770A' => '4204vl',
|
||||
'J8771A' => '4202vl-48G',
|
||||
'J8772A' => '4202vl-72',
|
||||
'J8773A' => '4208vl',
|
||||
'J8762A' => '2600-8-PWR',
|
||||
'J8680A' => '9408sl',
|
||||
'J9091A' => '8212zl',
|
||||
'J9475A' => '8206zl',
|
||||
'J9265A' => '6600ml-24XG',
|
||||
'J9264A' => '6600ml-24G-4XG',
|
||||
'J9263A' => '6600ml-24G',
|
||||
'J9452A' => '6600-48G-4XG',
|
||||
'J9451A' => '6600-48G',
|
||||
'J8474A' => '6410cl-6XG',
|
||||
'J8433A' => '6400cl-6XG',
|
||||
'J8992A' => '6200yl-24G',
|
||||
'J9019A' => '2510-24A',
|
||||
'J9020A' => '2510-48A',
|
||||
'J9021A' => '2810-24G',
|
||||
'J9022A' => '2810-48G',
|
||||
'J9028A' => '1800-24G',
|
||||
'J9029A' => '1800-8G',
|
||||
'J4902A' => '6108',
|
||||
'J8698A' => '5412zl',
|
||||
'J8719A' => '5408yl',
|
||||
'J8697A' => '5406zl',
|
||||
'J8718A' => '5404yl',
|
||||
'J4819A' => '5308XL',
|
||||
'J4850A' => '5304XL',
|
||||
'J8773A' => '4208vl',
|
||||
'J8770A' => '4204vl',
|
||||
'J8772A' => '4202vl-72',
|
||||
'J9032A' => '4202vl-68G',
|
||||
'J9031A' => '4202vl-68',
|
||||
'J8771A' => '4202vl-48G',
|
||||
'J4865A' => '4108GL',
|
||||
'J4887A' => '4104GL',
|
||||
'J8693A' => '3500yl-48G-PWR',
|
||||
'J8692A' => '3500yl-24G-PWR',
|
||||
'J9473A' => '3500-48-PoE',
|
||||
'J9472A' => '3500-48',
|
||||
'J9471A' => '3500-24-PoE',
|
||||
'J9470A' => '3500-24',
|
||||
'J4906A' => '3400cl-48G',
|
||||
'J4905A' => '3400cl-24G',
|
||||
'J4815A' => '3324XL',
|
||||
'J4851A' => '3124',
|
||||
'J9148A' => '2910al-48G-PoE+',
|
||||
'J9147A' => '2910al-48G',
|
||||
'J9146A' => '2910al-24G-PoE+',
|
||||
'J9145A' => '2910al-24G',
|
||||
'J9050A' => '2900-48G',
|
||||
'J9049A' => '2900-24G',
|
||||
'J9032A' => '4202vl-68G',
|
||||
'J9091A' => '8212zl',
|
||||
);
|
||||
'J4904A' => '2848',
|
||||
'J4903A' => '2824',
|
||||
'J9022A' => '2810-48G',
|
||||
'J9021A' => '2810-24G',
|
||||
'J8165A' => '2650-PWR',
|
||||
'J4899B' => '2650-CR',
|
||||
'J4899C' => '2650C',
|
||||
'J4899A' => '2650',
|
||||
'J8164A' => '2626-PWR',
|
||||
'J4900B' => '2626-CR',
|
||||
'J4900C' => '2626C',
|
||||
'J4900A' => '2626',
|
||||
'J9089A' => '2610-48-PWR',
|
||||
'J9088A' => '2610-48',
|
||||
'J9087A' => '2610-24-PWR',
|
||||
'J9086A' => '2610-24/12PWR',
|
||||
'J9085A' => '2610-24',
|
||||
'J8762A' => '2600-8-PWR',
|
||||
'J4813A' => '2524',
|
||||
'J9137A' => '2520-8-PoE',
|
||||
'J9138A' => '2520-24-PoE',
|
||||
'J4812A' => '2512',
|
||||
'J9280A' => '2510G-48',
|
||||
'J9279A' => '2510G-24',
|
||||
'J9020A' => '2510-48A',
|
||||
'J9019B' => '2510-24B',
|
||||
'J9019A' => '2510-24A',
|
||||
'J4818A' => '2324',
|
||||
'J4817A' => '2312',
|
||||
'J9029A' => '1800-8G',
|
||||
'J9028A' => '1800-24G',
|
||||
);
|
||||
|
||||
=item $hp->os()
|
||||
|
||||
@@ -832,10 +805,6 @@ the description field.
|
||||
|
||||
C<hpSwitchOsVersion.0>
|
||||
|
||||
=item $hp->serial()
|
||||
|
||||
Returns serial number if available through SNMP
|
||||
|
||||
=item $hp->slots()
|
||||
|
||||
Returns number of entries in $hp->e_name that have 'slot' in them.
|
||||
@@ -895,49 +864,6 @@ Returns reference to hash of IIDs to admin duplex setting.
|
||||
|
||||
Crosses i_name() with $hp->e_name() using $hp->e_port() and i_alias()
|
||||
|
||||
=item $hp->i_vlan()
|
||||
|
||||
Returns a mapping between C<ifIndex> and the PVID (default VLAN) or untagged
|
||||
port when using F<HP-VLAN>.
|
||||
|
||||
Looks in F<Q-BRIDGE-MIB> first (L<SNMP::Info::Bridge/"TABLE METHODS">) and for
|
||||
older devices looks in F<HP-VLAN>.
|
||||
|
||||
=item $hp->i_vlan_membership()
|
||||
|
||||
Returns reference to hash of arrays: key = C<ifIndex>, value = array of VLAN
|
||||
IDs. These are the VLANs which are members of the egress list for the port.
|
||||
It is the union of tagged, untagged, and auto ports when using F<HP-VLAN>.
|
||||
|
||||
Looks in F<Q-BRIDGE-MIB> first (L<SNMP::Info::Bridge/"TABLE METHODS">) and for
|
||||
older devices looks in F<HP-VLAN>.
|
||||
|
||||
Example:
|
||||
my $interfaces = $hp->interfaces();
|
||||
my $vlans = $hp->i_vlan_membership();
|
||||
|
||||
foreach my $iid (sort keys %$interfaces) {
|
||||
my $port = $interfaces->{$iid};
|
||||
my $vlan = join(',', sort(@{$vlans->{$iid}}));
|
||||
print "Port: $port VLAN: $vlan\n";
|
||||
}
|
||||
|
||||
=item $hp->v_index()
|
||||
|
||||
Returns VLAN IDs
|
||||
|
||||
=item $hp->v_name()
|
||||
|
||||
Returns VLAN names
|
||||
|
||||
=item $hp->bp_index()
|
||||
|
||||
Returns reference to hash of bridge port table entries map back to interface
|
||||
identifier (iid)
|
||||
|
||||
Returns (C<ifIndex>) for both key and value for 1600, 2424, 4000, and 8000
|
||||
models since they seem to have problems with F<BRIDGE-MIB>
|
||||
|
||||
=item $hp->peth_port_ifindex()
|
||||
|
||||
Returns reference to hash of power Ethernet port table entries map back to
|
||||
|
||||
703
Info/Layer2/HP4000.pm
Normal file
703
Info/Layer2/HP4000.pm
Normal file
@@ -0,0 +1,703 @@
|
||||
# SNMP::Info::Layer2::HP4000 - SNMP Interface to older HP ProCurve Switches (1600, 2400, 2424M, 4000 and 8000)
|
||||
#
|
||||
# Copyright (c) 2008 Max Baker changes from version 0.8 and beyond.
|
||||
#
|
||||
# Copyright (c) 2002,2003 Regents of the University of California
|
||||
# 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::Layer2::HP4000;
|
||||
|
||||
use strict;
|
||||
use Exporter;
|
||||
use SNMP::Info::Layer3;
|
||||
use SNMP::Info::MAU;
|
||||
use SNMP::Info::CDP;
|
||||
|
||||
@SNMP::Info::Layer2::HP4000::ISA
|
||||
= qw/SNMP::Info::Layer3 SNMP::Info::MAU
|
||||
SNMP::Info::CDP Exporter/;
|
||||
@SNMP::Info::Layer2::HP4000::EXPORT_OK = qw//;
|
||||
|
||||
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %PORTSTAT %MODEL_MAP %MUNGE/;
|
||||
|
||||
$VERSION = '2.02-cvs';
|
||||
|
||||
%MIBS = (
|
||||
%SNMP::Info::Layer3::MIBS,
|
||||
%SNMP::Info::MAU::MIBS,
|
||||
%SNMP::Info::LLDP::MIBS,
|
||||
%SNMP::Info::CDP::MIBS,
|
||||
'RFC1271-MIB' => 'logDescription',
|
||||
'HP-ICF-OID' => 'hpSwitch4000',
|
||||
'HP-VLAN' => 'hpVlanMemberIndex',
|
||||
'STATISTICS-MIB' => 'hpSwitchCpuStat',
|
||||
'NETSWITCH-MIB' => 'hpMsgBufFree',
|
||||
'CONFIG-MIB' => 'hpSwitchConfig',
|
||||
'SEMI-MIB' => 'hpHttpMgSerialNumber',
|
||||
'HP-ICF-CHASSIS' => 'hpicfSensorObjectId',
|
||||
);
|
||||
|
||||
%GLOBALS = (
|
||||
%SNMP::Info::Layer3::GLOBALS,
|
||||
%SNMP::Info::MAU::GLOBALS,
|
||||
%SNMP::Info::CDP::GLOBALS,
|
||||
'serial1' => 'hpHttpMgSerialNumber.0',
|
||||
'hp_cpu' => 'hpSwitchCpuStat.0',
|
||||
'hp_mem_total' => 'hpGlobalMemTotalBytes.1',
|
||||
'mem_free' => 'hpGlobalMemFreeBytes.1',
|
||||
'mem_used' => 'hpGlobalMemAllocBytes.1',
|
||||
'os_version' => 'hpSwitchOsVersion.0',
|
||||
'os_bin' => 'hpSwitchRomVersion.0',
|
||||
'mac' => 'hpSwitchBaseMACAddress.0',
|
||||
'hp_vlans' => 'hpVlanNumber',
|
||||
);
|
||||
|
||||
%FUNCS = (
|
||||
%SNMP::Info::Layer3::FUNCS,
|
||||
%SNMP::Info::MAU::FUNCS,
|
||||
%SNMP::Info::CDP::FUNCS,
|
||||
'bp_index2' => 'dot1dBasePortIfIndex',
|
||||
'i_type2' => 'ifType',
|
||||
|
||||
# RFC1271
|
||||
'l_descr' => 'logDescription',
|
||||
|
||||
# HP-VLAN-MIB
|
||||
'hp_v_index' => 'hpVlanDot1QID',
|
||||
'hp_v_name' => 'hpVlanIdentName',
|
||||
'hp_v_state' => 'hpVlanIdentState',
|
||||
'hp_v_type' => 'hpVlanIdentType',
|
||||
'hp_v_status' => 'hpVlanIdentStatus',
|
||||
'hp_v_mac' => 'hpVlanAddrPhysAddress',
|
||||
'hp_v_if_index' => 'hpVlanMemberIndex',
|
||||
'hp_v_if_tag' => 'hpVlanMemberTagged2',
|
||||
|
||||
# CONFIG-MIB::hpSwitchPortTable
|
||||
'hp_duplex' => 'hpSwitchPortEtherMode',
|
||||
'hp_duplex_admin' => 'hpSwitchPortFastEtherMode',
|
||||
|
||||
# HP-ICF-CHASSIS
|
||||
'hp_s_oid' => 'hpicfSensorObjectId',
|
||||
'hp_s_name' => 'hpicfSensorDescr',
|
||||
'hp_s_status' => 'hpicfSensorStatus',
|
||||
);
|
||||
|
||||
%MUNGE = (
|
||||
|
||||
# Inherit all the built in munging
|
||||
%SNMP::Info::Layer3::MUNGE,
|
||||
%SNMP::Info::MAU::MUNGE,
|
||||
%SNMP::Info::CDP::MUNGE
|
||||
);
|
||||
|
||||
%MODEL_MAP = (
|
||||
'J4093A' => '2424M',
|
||||
'J4110A' => '8000M',
|
||||
'J4120A' => '1600M',
|
||||
'J4121A' => '4000M',
|
||||
'J4122A' => '2400M',
|
||||
'J4122B' => '2424M',
|
||||
);
|
||||
|
||||
# Method Overrides
|
||||
|
||||
sub cpu {
|
||||
my $hp = shift;
|
||||
return $hp->hp_cpu();
|
||||
}
|
||||
|
||||
sub mem_total {
|
||||
my $hp = shift;
|
||||
return $hp->hp_mem_total();
|
||||
}
|
||||
|
||||
sub os {
|
||||
return 'hp';
|
||||
}
|
||||
|
||||
sub os_ver {
|
||||
my $hp = shift;
|
||||
my $os_version = $hp->os_version();
|
||||
return $os_version if defined $os_version;
|
||||
|
||||
# Some older ones don't have this value,so we cull it from the description
|
||||
my $descr = $hp->description();
|
||||
if ( $descr =~ m/revision ([A-Z]{1}\.\d{2}\.\d{2})/ ) {
|
||||
return $1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
# Lookup model number, and translate the part number to the common number
|
||||
sub model {
|
||||
my $hp = shift;
|
||||
my $id = $hp->id();
|
||||
return unless defined $id;
|
||||
my $model = &SNMP::translateObj($id);
|
||||
return $id unless defined $model;
|
||||
|
||||
$model =~ s/^hpswitch//i;
|
||||
|
||||
return defined $MODEL_MAP{$model} ? $MODEL_MAP{$model} : $model;
|
||||
}
|
||||
|
||||
sub interfaces {
|
||||
my $hp = shift;
|
||||
my $interfaces = $hp->i_index();
|
||||
my $i_descr = $hp->i_description();
|
||||
|
||||
my %if;
|
||||
foreach my $iid ( keys %$interfaces ) {
|
||||
my $descr = $i_descr->{$iid};
|
||||
next unless defined $descr;
|
||||
$if{$iid} = $descr if ( defined $descr and length $descr );
|
||||
}
|
||||
|
||||
return \%if
|
||||
}
|
||||
|
||||
sub i_name {
|
||||
my $hp = shift;
|
||||
my $i_alias = $hp->i_alias();
|
||||
my $e_name = $hp->e_name();
|
||||
my $e_port = $hp->e_port();
|
||||
|
||||
my %i_name;
|
||||
|
||||
foreach my $port ( keys %$e_name ) {
|
||||
my $iid = $e_port->{$port};
|
||||
next unless defined $iid;
|
||||
my $alias = $i_alias->{$iid};
|
||||
next unless defined $iid;
|
||||
$i_name{$iid} = $e_name->{$port};
|
||||
|
||||
# Check for alias
|
||||
$i_name{$iid} = $alias if ( defined $alias and length($alias) );
|
||||
}
|
||||
|
||||
return \%i_name;
|
||||
}
|
||||
|
||||
sub i_duplex {
|
||||
my $hp = shift;
|
||||
|
||||
return $hp->mau_i_duplex();
|
||||
}
|
||||
|
||||
sub i_duplex_admin {
|
||||
my $hp = shift;
|
||||
my $partial = shift;
|
||||
|
||||
# Try HP MIB first
|
||||
my $hp_duplex = $hp->hp_duplex_admin($partial);
|
||||
if ( defined $hp_duplex and scalar( keys %$hp_duplex ) ) {
|
||||
|
||||
my %i_duplex;
|
||||
foreach my $if ( keys %$hp_duplex ) {
|
||||
my $duplex = $hp_duplex->{$if};
|
||||
next unless defined $duplex;
|
||||
|
||||
$duplex = 'half' if $duplex =~ /half/i;
|
||||
$duplex = 'full' if $duplex =~ /full/i;
|
||||
$duplex = 'auto' if $duplex =~ /auto/i;
|
||||
$i_duplex{$if} = $duplex;
|
||||
}
|
||||
return \%i_duplex;
|
||||
}
|
||||
else {
|
||||
return $hp->mau_i_duplex_admin();
|
||||
}
|
||||
}
|
||||
|
||||
sub vendor {
|
||||
return 'hp';
|
||||
}
|
||||
|
||||
sub log {
|
||||
my $hp = shift;
|
||||
|
||||
my $log = $hp->l_descr();
|
||||
|
||||
my $logstring = undef;
|
||||
|
||||
foreach my $val ( values %$log ) {
|
||||
next if $val =~ /^Link\s+(Up|Down)/;
|
||||
$logstring .= "$val\n";
|
||||
}
|
||||
|
||||
return $logstring;
|
||||
}
|
||||
|
||||
sub slots {
|
||||
my $hp = shift;
|
||||
|
||||
my $e_name = $hp->e_name();
|
||||
|
||||
return unless defined $e_name;
|
||||
|
||||
my $slots;
|
||||
foreach my $slot ( keys %$e_name ) {
|
||||
$slots++ if $e_name->{$slot} =~ /slot/i;
|
||||
}
|
||||
|
||||
return $slots;
|
||||
}
|
||||
|
||||
sub fan {
|
||||
my $hp = shift;
|
||||
return &_sensor( $hp, 'fan' );
|
||||
}
|
||||
|
||||
sub ps1_status {
|
||||
my $hp = shift;
|
||||
return &_sensor( $hp, 'power', '^power supply 1' )
|
||||
|| &_sensor( $hp, 'power', '^power supply sensor' );
|
||||
}
|
||||
|
||||
sub ps2_status {
|
||||
my $hp = shift;
|
||||
return &_sensor( $hp, 'power', '^power supply 2' )
|
||||
|| &_sensor( $hp, 'power', '^redundant' );
|
||||
}
|
||||
|
||||
sub _sensor {
|
||||
my $hp = shift;
|
||||
my $search_type = shift || 'fan';
|
||||
my $search_name = shift || '';
|
||||
my $hp_s_oid = $hp->hp_s_oid();
|
||||
my $result;
|
||||
foreach my $sensor ( keys %$hp_s_oid ) {
|
||||
my $sensortype = &SNMP::translateObj( $hp_s_oid->{$sensor} );
|
||||
if ( $sensortype =~ /$search_type/i ) {
|
||||
my $sensorname = $hp->hp_s_name()->{$sensor};
|
||||
my $sensorstatus = $hp->hp_s_status()->{$sensor};
|
||||
if ( $sensorname =~ /$search_name/i ) {
|
||||
$result = $sensorstatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
# Bridge MIB does not map Bridge Port to ifIndex correctly on older models, but Bridge Port equals ifIndex in these devices
|
||||
sub bp_index {
|
||||
my $hp = shift;
|
||||
my $partial = shift;
|
||||
|
||||
my $if_index = $hp->i_index($partial);
|
||||
my %mod_bp_index;
|
||||
foreach my $iid ( keys %$if_index ) {
|
||||
$mod_bp_index{$iid} = $iid;
|
||||
}
|
||||
return \%mod_bp_index;
|
||||
}
|
||||
|
||||
# VLAN methods. Devices in this class use the proprietary HP-VLAN-MIB.
|
||||
|
||||
sub v_index {
|
||||
my $hp = shift;
|
||||
my $partial = shift;
|
||||
|
||||
return $hp->hp_v_index($partial);
|
||||
}
|
||||
|
||||
sub v_name {
|
||||
my $hp = shift;
|
||||
my $partial = shift;
|
||||
|
||||
return $hp->hp_v_name($partial);
|
||||
}
|
||||
|
||||
sub i_vlan {
|
||||
my $hp = shift;
|
||||
|
||||
# the hpvlanmembertagged2 table has an entry in the form of
|
||||
# vlan.interface = /untagged/no/tagged/auto
|
||||
my $i_vlan = {};
|
||||
my $hp_v_index = $hp->hp_v_index();
|
||||
my $hp_v_if_tag = $hp->hp_v_if_tag();
|
||||
foreach my $row ( keys %$hp_v_if_tag ) {
|
||||
my ( $index, $if ) = split( /\./, $row );
|
||||
|
||||
my $tag = $hp_v_if_tag->{$row};
|
||||
my $vlan = $hp_v_index->{$index};
|
||||
|
||||
next unless ( defined $tag and $tag =~ /untagged/ );
|
||||
|
||||
$i_vlan->{$if} = $vlan if defined $vlan;
|
||||
}
|
||||
|
||||
return $i_vlan;
|
||||
}
|
||||
|
||||
sub i_vlan_membership {
|
||||
my $hp = shift;
|
||||
|
||||
my $i_vlan_membership = {};
|
||||
my $hp_v_index = $hp->hp_v_index();
|
||||
my $hp_v_if_tag = $hp->hp_v_if_tag();
|
||||
foreach my $row ( keys %$hp_v_if_tag ) {
|
||||
my ( $index, $if ) = split( /\./, $row );
|
||||
|
||||
my $tag = $hp_v_if_tag->{$row};
|
||||
my $vlan = $hp_v_index->{$index};
|
||||
|
||||
next unless ( defined $tag );
|
||||
next if ( $tag eq 'no' );
|
||||
|
||||
push( @{ $i_vlan_membership->{$if} }, $vlan );
|
||||
}
|
||||
|
||||
return $i_vlan_membership;
|
||||
}
|
||||
|
||||
sub set_i_vlan {
|
||||
my $hp = shift;
|
||||
my $rv;
|
||||
|
||||
my $hp_v_index = $hp->hp_v_index();
|
||||
my $hp_v_if_tag = $hp->hp_v_if_tag();
|
||||
if (defined $hp_v_index and scalar(keys %$hp_v_index)){
|
||||
my $vlan = shift;
|
||||
my $iid = shift;
|
||||
my $old_untagged;
|
||||
# Hash to lookup VLAN index of the VID (dot1q tag)
|
||||
my %vl_trans = reverse %$hp_v_index;
|
||||
|
||||
# Translate the VLAN identifier (tag) value to the index used by the HP-VLAN MIB
|
||||
my $vlan_index = $vl_trans{$vlan};
|
||||
if (defined $vlan_index) {
|
||||
|
||||
# First, loop through table to determine current untagged vlan for the port we're about to change
|
||||
foreach my $row (keys %$hp_v_if_tag){
|
||||
my ($index,$if) = split(/\./,$row);
|
||||
if ($if == $iid and $hp_v_if_tag->{$row} =~ /untagged/) {
|
||||
# Store the row information of the current untagged VLAN and temporarily set it to tagged
|
||||
$old_untagged = $row;
|
||||
$rv = $hp->set_hp_v_if_tag(1, $row);
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
# Then set our port untagged in the desired VLAN
|
||||
my $rv = $hp->set_hp_v_if_tag(2, "$vlan_index.$iid");
|
||||
if (defined $rv) {
|
||||
# If vlan change is successful, remove VLAN that used to be untagged from the port
|
||||
if (defined $old_untagged) {
|
||||
$rv = $hp->set_hp_v_if_tag(3, $old_untagged);
|
||||
$hp->error_throw("Error removing previous untagged vlan from port, should never happen...\n") unless defined $rv;
|
||||
}
|
||||
} else {
|
||||
# If vlan change was not succesful, try to revert to the old situation.
|
||||
if (defined $old_untagged) {
|
||||
$rv = $hp->set_hp_v_if_tag(2, $old_untagged) if defined $old_untagged;
|
||||
if (defined $rv) {
|
||||
$hp->error_throw("VLAN change failed, restored port to previous configuration.\n");
|
||||
} else {
|
||||
$hp->error_throw("VLAN change failed, unable to restore old configuration. Check device.\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$hp->error_throw("Requested VLAN (VLAN ID: $vlan) not available on device.\n");
|
||||
}
|
||||
} else {
|
||||
$hp->error_throw("Error retrieving VLAN information from device.\n");
|
||||
}
|
||||
return $rv;
|
||||
}
|
||||
|
||||
sub set_i_vlan_tagged {
|
||||
my $hp = shift;
|
||||
my $vlan = shift;
|
||||
my $iid = shift;
|
||||
my $rv;
|
||||
|
||||
my $hp_v_index = $hp->hp_v_index();
|
||||
if (defined $hp_v_index and scalar(keys %$hp_v_index)){
|
||||
# Hash to lookup VLAN index of the VID (dot1q tag)
|
||||
my %vl_trans = reverse %$hp_v_index;
|
||||
|
||||
# Translate the VLAN identifier (tag) value to the index used by the HP-VLAN MIB
|
||||
my $vlan_index = $vl_trans{$vlan};
|
||||
if (defined $vlan_index) {
|
||||
# Set our port tagged in the desired VLAN
|
||||
$rv = $hp->set_hp_v_if_tag(1, "$vlan_index.$iid");
|
||||
} else {
|
||||
$hp->error_throw("Requested VLAN (VLAN ID: $vlan) not available on device.\n");
|
||||
}
|
||||
}
|
||||
return $rv;
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::Layer2::HP4000 - SNMP Interface to older HP ProCurve Switches (1600, 2400, 2424M, 4000 and 8000)
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Max Baker
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
# Let SNMP::Info determine the correct subclass for you.
|
||||
my $hp = new SNMP::Info(
|
||||
AutoSpecify => 1,
|
||||
Debug => 1,
|
||||
DestHost => 'myswitch',
|
||||
Community => 'public',
|
||||
Version => 2
|
||||
)
|
||||
or die "Can't connect to DestHost.\n";
|
||||
|
||||
my $class = $hp->class();
|
||||
print "SNMP::Info determined this device to fall under subclass : $class\n";
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Provides abstraction to the configuration information obtainable from a
|
||||
HP ProCurve Switch via SNMP.
|
||||
|
||||
Note: Some HP Switches will connect via SNMP version 1, but a lot of config
|
||||
data will not be available. Make sure you try and connect with Version 2
|
||||
first, and then fail back to version 1.
|
||||
|
||||
For speed or debugging purposes you can call the subclass directly, but not
|
||||
after determining a more specific class using the method above.
|
||||
|
||||
my $hp = new SNMP::Info::Layer2::HP4000(...);
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
=over
|
||||
|
||||
=item SNMP::Info::Layer2
|
||||
|
||||
|
||||
=item SNMP::Info::MAU
|
||||
|
||||
=back
|
||||
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item F<RFC1271-MIB>
|
||||
|
||||
Included in V2 mibs from Cisco
|
||||
|
||||
=item F<HP-ICF-OID>
|
||||
|
||||
=item F<HP-VLAN>
|
||||
|
||||
(this MIB new with SNMP::Info 0.8)
|
||||
|
||||
=item F<STATISTICS-MIB>
|
||||
|
||||
=item F<NETSWITCH-MIB>
|
||||
|
||||
=item F<CONFIG-MIB>
|
||||
|
||||
=back
|
||||
|
||||
The last five MIBs listed are from HP and can be found at
|
||||
L<http://www.hp.com/rnd/software> or
|
||||
L<http://www.hp.com/rnd/software/MIBs.htm>
|
||||
|
||||
=head1 Change Log
|
||||
|
||||
Version 0.4 - Removed F<ENTITY-MIB> e_*() methods to separate sub-class -
|
||||
SNMP::Info::Entity
|
||||
|
||||
=head1 GLOBALS
|
||||
|
||||
These are methods that return scalar value from SNMP
|
||||
|
||||
=over
|
||||
|
||||
=item $hp->cpu()
|
||||
|
||||
Returns CPU Utilization in percentage.
|
||||
|
||||
=item $hp->log()
|
||||
|
||||
Returns all the log entries from the switch's log that are not Link up or
|
||||
down messages.
|
||||
|
||||
=item $hp->mem_free()
|
||||
|
||||
Returns bytes of free memory
|
||||
|
||||
=item $hp->mem_total()
|
||||
|
||||
Return bytes of total memory
|
||||
|
||||
=item $hp->mem_used()
|
||||
|
||||
Returns bytes of used memory
|
||||
|
||||
=item $hp->model()
|
||||
|
||||
Returns the model number of the HP Switch. Will translate between the HP Part
|
||||
number and the common model number with this map :
|
||||
|
||||
%MODEL_MAP = (
|
||||
'J4093A' => '2424M',
|
||||
'J4110A' => '8000M',
|
||||
'J4120A' => '1600M',
|
||||
'J4121A' => '4000M',
|
||||
'J4122A' => '2400M',
|
||||
'J4122B' => '2424M',
|
||||
);
|
||||
|
||||
=item $hp->os()
|
||||
|
||||
Returns hp
|
||||
|
||||
=item $hp->os_bin()
|
||||
|
||||
C<hpSwitchRomVersion.0>
|
||||
|
||||
=item $hp->os_ver()
|
||||
|
||||
Tries to use os_version() and if that fails will try and cull the version from
|
||||
the description field.
|
||||
|
||||
=item $hp->os_version()
|
||||
|
||||
C<hpSwitchOsVersion.0>
|
||||
|
||||
=item $hp->serial()
|
||||
|
||||
Returns serial number if available through SNMP
|
||||
|
||||
=item $hp->slots()
|
||||
|
||||
Returns number of entries in $hp->e_name that have 'slot' in them.
|
||||
|
||||
=item $hp->vendor()
|
||||
|
||||
hp
|
||||
|
||||
=item $hp->fan()
|
||||
|
||||
Returns fan status
|
||||
|
||||
=item $hp->ps1_status()
|
||||
|
||||
Power supply 1 status
|
||||
|
||||
=item $hp->ps2_status()
|
||||
|
||||
Power supply 2 status
|
||||
|
||||
=back
|
||||
|
||||
=head2 Globals imported from SNMP::Info::Layer2
|
||||
|
||||
See documentation in L<SNMP::Info::Layer2/"GLOBALS"> for details.
|
||||
|
||||
=head2 Globals imported from SNMP::Info::MAU
|
||||
|
||||
See documentation in L<SNMP::Info::MAU/"GLOBALS"> for details.
|
||||
|
||||
=head1 TABLE METHODS
|
||||
|
||||
These are methods that return tables of information in the form of a reference
|
||||
to a hash.
|
||||
|
||||
=head2 Overrides
|
||||
|
||||
=over
|
||||
|
||||
=item $hp->interfaces()
|
||||
|
||||
Uses $hp->i_description()
|
||||
|
||||
=item $hp->i_duplex()
|
||||
|
||||
Returns reference to map of IIDs to current link duplex.
|
||||
|
||||
=item $hp->i_duplex_admin()
|
||||
|
||||
Returns reference to hash of IIDs to admin duplex setting.
|
||||
|
||||
=item $hp->i_name()
|
||||
|
||||
Crosses i_name() with $hp->e_name() using $hp->e_port() and i_alias()
|
||||
|
||||
=item $hp->i_vlan()
|
||||
|
||||
Returns a mapping between C<ifIndex> and the PVID (default VLAN) or untagged
|
||||
port when using F<HP-VLAN>.
|
||||
|
||||
=item $hp->i_vlan_membership()
|
||||
|
||||
Returns reference to hash of arrays: key = C<ifIndex>, value = array of VLAN
|
||||
IDs. These are the VLANs which are members of the egress list for the port.
|
||||
It is the union of tagged, untagged, and auto ports.
|
||||
|
||||
Example:
|
||||
my $interfaces = $hp->interfaces();
|
||||
my $vlans = $hp->i_vlan_membership();
|
||||
|
||||
foreach my $iid (sort keys %$interfaces) {
|
||||
my $port = $interfaces->{$iid};
|
||||
my $vlan = join(',', sort(@{$vlans->{$iid}}));
|
||||
print "Port: $port VLAN: $vlan\n";
|
||||
}
|
||||
|
||||
=item $hp->v_index()
|
||||
|
||||
Returns VLAN IDs
|
||||
|
||||
=item $hp->v_name()
|
||||
|
||||
Returns VLAN names
|
||||
|
||||
=item $hp->bp_index()
|
||||
|
||||
Returns reference to hash of bridge port table entries map back to interface
|
||||
identifier (iid)
|
||||
|
||||
Returns (C<ifIndex>) for both key and value for 1600, 2424, 4000, and 8000
|
||||
models since they seem to have problems with F<BRIDGE-MIB>
|
||||
|
||||
=back
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::Layer2
|
||||
|
||||
See documentation in L<SNMP::Info::Layer2/"TABLE METHODS"> for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::MAU
|
||||
|
||||
See documentation in L<SNMP::Info::MAU/"TABLE METHODS"> for details.
|
||||
|
||||
=cut
|
||||
Reference in New Issue
Block a user