SNMP::Info::Layer3::Foundry - SNMP Interface to Foundry Network Devices


SNMP-Info documentation Contained in the SNMP-Info distribution.

Index


Code Index:

NAME

Top

SNMP::Info::Layer3::Foundry - SNMP Interface to Foundry Network Devices

AUTHOR

Top

Max Baker

SYNOPSIS

Top

 # Let SNMP::Info determine the correct subclass for you. 
 my $foundry = new SNMP::Info(
                          AutoSpecify => 1,
                          Debug       => 1,
                          DestHost    => 'myswitch',
                          Community   => 'public',
                          Version     => 1
                        ) 
    or die "Can't connect to DestHost.\n";

 my $class = $foundry->class();

 print "SNMP::Info determined this device to fall under subclass : $class\n";

DESCRIPTION

Top

Abstraction subclass for Foundry Networks devices.

For speed or debugging purposes you can call the subclass directly, but not after determining a more specific class using the method above.

 my $foundry = new SNMP::Info::Layer3::Foundry(...);

Inherited Classes

SNMP::Info::Layer3;
SNMP::Info::FDP;
SNMP::Info::LLDP;

Required MIBs

FOUNDRY-SN-ROOT-MIB
FOUNDRY-SN-AGENT-MIB
FOUNDRY-SN-SWITCH-GROUP-MIB
Inherited Classes' MIBs

See "Required MIBs" in SNMP::Info::Layer3 for its own MIB requirements.

See "Required MIBs" in SNMP::Info::FDP for its own MIB requirements.

See "Required MIBs" in SNMP::Info::LLDP for its own MIB requirements.

GLOBALS

Top

These are methods that return scalar value from SNMP

$foundry->model()

Returns model type. Checks $foundry->id() against the FOUNDRY-SN-ROOT-MIB and removes 'sn'. EdgeIron models determined through ENTITY-MIB.

$foundry->vendor()

Returns 'foundry'

$foundry->os()

Returns 'foundry'

$foundry->os_ver()

Returns the software version

$foundry->mac()

Returns MAC Address of root port.

(ifPhysAddress.1)

$foundry->chassis()

Returns Chassis type.

(entPhysicalDescr.1)

$foundry->serial()

Returns serial number of device.

$foundry->temp()

Returns the chassis temperature

(snChasActualTemperature)

$foundry->ps1_type()

Returns the Description for the power supply

(snChasPwrSupplyDescription.1)

$foundry->ps1_status()

Returns the status of the power supply.

(snChasPwrSupplyOperStatus.1)

$foundry->fan()

Returns the status of the chassis fan.

(snChasFanOperStatus.1)

Global Methods imported from SNMP::Info::Layer3

See documentation in "GLOBALS" in SNMP::Info::Layer3 for details.

Global Methods imported from SNMP::Info::FDP

See documentation in "GLOBALS" in SNMP::Info::FDP for details.

Global Methods imported from SNMP::Info::LLDP

See documentation in "GLOBALS" in SNMP::Info::LLDP for details.

TABLE METHODS

Top

These are methods that return tables of information in the form of a reference to a hash.

Overrides

$foundry->interfaces()

Returns reference to hash of interface names to iids.

$foundry->i_ignore()

Returns reference to hash of interfaces to be ignored.

Ignores interfaces with descriptions of tunnel,loopback,null

$foundry->i_duplex()

Returns reference to hash of interface link duplex status.

Crosses $foundry->sw_duplex() with $foundry->sw_index()

$foundry->stp_p_state()

"The port's current state as defined by application of the Spanning Tree Protocol.

Skipped if device is an EdgeIron 24G due to reports of hangs.

(dot1dStpPortState)

Foundry Switch Port Information Table (snSwPortIfTable)

$foundry->sw_index()

Returns reference to hash. Maps Table to Interface IID.

(snSwPortIfIndex)

$foundry->sw_duplex()

Returns reference to hash. Current duplex status for switch ports.

(snSwPortInfoChnMode)

$foundry->sw_type()

Returns reference to hash. Current Port Type .

(snSwPortInfoMediaType)

$foundry->sw_speed()

Returns reference to hash. Current Port Speed.

(snSwPortInfoSpeed)

Topology information

Based upon the software version devices may support Foundry Discovery Protocol (FDP) and Link Layer Discovery Protocol (LLDP). These methods will query both and return the combination of all information. As a result, there may be identical topology information returned from the two protocols causing duplicate entries. It is the calling program's responsibility to identify any duplicate entries and remove duplicates if necessary.

$foundry->hasCDP()

Returns true if the device is running either FDP or LLDP.

$foundry->c_if()

Returns reference to hash. Key: iid Value: local device port (interfaces)

$foundry->c_ip()

Returns reference to hash. Key: iid Value: remote IPv4 address

If multiple entries exist with the same local port, c_if(), with the same IPv4 address, c_ip(), it may be a duplicate entry.

If multiple entries exist with the same local port, c_if(), with different IPv4 addresses, c_ip(), there is either a non-FDP/LLDP device in between two or more devices or multiple devices which are not directly connected.

Use the data from the Layer2 Topology Table below to dig deeper.

$foundry->c_port()

Returns reference to hash. Key: iid Value: remote port (interfaces)

$foundry->c_id()

Returns reference to hash. Key: iid Value: string value used to identify the chassis component associated with the remote system.

$foundry->c_platform()

Returns reference to hash. Key: iid Value: Remote Device Type

Table Methods imported from SNMP::Info::Layer3

See documentation in "TABLE METHODS" in SNMP::Info::Layer3 for details.

Table Methods imported from SNMP::Info::FDP

See documentation in "TABLE METHODS" in SNMP::Info::FDP for details.

Table Methods imported from SNMP::Info::LLDP

See documentation in "TABLE METHODS" in SNMP::Info::LLDP for details.


SNMP-Info documentation Contained in the SNMP-Info distribution.

# SNMP::Info::Layer3::Foundry - SNMP Interface to Foundry devices
# $Id$
#
# 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::Layer3::Foundry;

use strict;
use Exporter;
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::EXPORT_OK = qw//;

use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/;

$VERSION = '2.05';

%MIBS = (
    %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',
);

%GLOBALS = (
    %SNMP::Info::Layer3::GLOBALS,
    %SNMP::Info::LLDP::GLOBALS,
    %SNMP::Info::FDP::GLOBALS,
    'mac'        => 'ifPhysAddress.1',
    'chassis'    => 'entPhysicalDescr.1',
    'temp'       => 'snChasActualTemperature',
    'ps1_type'   => 'snChasPwrSupplyDescription.1',
    'ps1_status' => 'snChasPwrSupplyOperStatus.1',
    'fan'        => 'snChasFanOperStatus.1',

);

%FUNCS = (
    %SNMP::Info::Layer3::FUNCS,
    %SNMP::Info::LLDP::FUNCS,
    %SNMP::Info::FDP::FUNCS,

    # FOUNDRY-SN-SWITCH-GROUP-MIB
    # snSwPortInfoTable - Switch Port Information Group
    'sw_index'  => 'snSwPortIfIndex',
    'sw_duplex' => 'snSwPortInfoChnMode',
    'sw_type'   => 'snSwPortInfoMediaType',
    'sw_speed'  => 'snSwPortInfoSpeed',
);

%MUNGE = (
    %SNMP::Info::Layer3::MUNGE, %SNMP::Info::LLDP::MUNGE,
    %SNMP::Info::FDP::MUNGE,
);

sub i_ignore {
    my $foundry = shift;
    my $partial = shift;

    my $interfaces = $foundry->interfaces($partial) || {};

    my %i_ignore;
    foreach my $if ( keys %$interfaces ) {
        if ( $interfaces->{$if} =~ /(tunnel|loopback|\blo\b|lb|null)/i ) {
            $i_ignore{$if}++;
        }
    }
    return \%i_ignore;
}

sub i_duplex {
    my $foundry = shift;
    my $partial = shift;

    my $sw_index  = $foundry->sw_index($partial);
    my $sw_duplex = $foundry->sw_duplex($partial);

    unless ( defined $sw_index and defined $sw_duplex ) {
        return $foundry->SUPER::i_duplex();
    }

    my %i_duplex;
    foreach my $sw_port ( keys %$sw_duplex ) {
        my $iid    = $sw_index->{$sw_port};
        my $duplex = $sw_duplex->{$sw_port};
        next if $duplex =~ /none/i;
        $i_duplex{$iid} = 'half' if $duplex =~ /half/i;
        $i_duplex{$iid} = 'full' if $duplex =~ /full/i;
    }
    return \%i_duplex;
}

sub model {
    my $foundry = shift;
    my $id      = $foundry->id();
    my $model   = &SNMP::translateObj($id);

    # EdgeIron
    if ( $id =~ /\.1991\.1\.[45]\./ ) {

        my $e_name = $foundry->e_name();

        # Find entity table entry for "unit.1"
        my $unit_iid = undef;
        foreach my $e ( keys %$e_name ) {
            my $name = $e_name->{$e} || '';
            $unit_iid = $e if $name eq 'unit.1';
        }

        # Find Model Name
        my $e_model = $foundry->e_model();
        if ( defined $e_model->{$unit_iid} ) {
            return $e_model->{$unit_iid};
        }
    }

    return $id unless defined $model;

    $model =~ s/^sn//;

    return $model;
}

sub os {
    return 'foundry';
}

sub vendor {
    return 'foundry';
}

sub os_ver {
    my $foundry = shift;

    return $foundry->snAgImgVer() if ( defined $foundry->snAgImgVer() );

    # Some older ones don't have this value,so we cull it from the description
    my $descr = $foundry->description();
    if ( $descr =~ m/Version (\d\S*)/ ) {
        return $1;
    }

    # EdgeIron
    my $e_name = $foundry->e_name();

    # find entity table entry for "stackmanaget.1"
    my $unit_iid = undef;
    foreach my $e ( keys %$e_name ) {
        my $name = $e_name->{$e} || '';
        $unit_iid = $e if $name eq 'stackmanaget.1';
    }

    if ( defined $unit_iid ) {

        # Find Model Name
        my $e_fwver = $foundry->e_fwver();
        if ( defined $e_fwver->{$unit_iid} ) {
            return $e_fwver->{$unit_iid};
        }
    }

    # Last resort
    return $foundry->SUPER::os_ver();

}

sub serial {
    my $foundry = shift;

    # Return chassis serial number if available
    return $foundry->snChasSerNum() if ( $foundry->snChasSerNum() );

    # If no chassis serial use first module serial
    my $mod_serials = $foundry->snAgentConfigModuleSerialNumber();

    foreach my $mod ( sort keys %$mod_serials ) {
        my $serial = $mod_serials->{$mod} || '';
        next unless defined $serial;
        return $serial;
    }

    # EdgeIron
    my $e_name = $foundry->e_name();

    # find entity table entry for "unit.1"
    my $unit_iid = undef;
    foreach my $e ( keys %$e_name ) {
        my $name = $e_name->{$e} || '';
        $unit_iid = $e if $name eq 'unit.1';
    }

    if ( defined $unit_iid ) {

        # Look up serial of found entry.
        my $e_serial = $foundry->e_serial();
        return $e_serial->{$unit_iid} if defined $e_serial->{$unit_iid};
    }

    # Last resort
    return $foundry->SUPER::serial();
}

sub interfaces {
    my $foundry = shift;
    my $partial = shift;

    my $i_descr = $foundry->i_description($partial) || {};
    my $i_name  = $foundry->i_name($partial)        || {};

    # Use ifName for EdgeIrons else use ifDescr
    foreach my $iid ( keys %$i_name ) {
        my $name = $i_name->{$iid};
        next unless defined $name;
        $i_descr->{$iid} = $name
            if $name =~ /^port\d+/i;
    }

    return $i_descr;
}

# Reported hangs on a EdgeIron 24G
sub stp_p_state {
    my $foundry = shift;
    my $partial = shift;

    my $descr = $foundry->description();
    if ( $descr =~ m/\bEdgeIron 24G\b/ ) {
        return;
    }

    return $foundry->SUPER::stp_p_state($partial) || {};

}

#  Use FDP and/or LLDP

sub hasCDP {
    my $foundry = shift;

    return $foundry->hasLLDP() || $foundry->SUPER::hasCDP();
}

sub c_ip {
    my $foundry = shift;
    my $partial = shift;

    my $cdp  = $foundry->SUPER::c_ip($partial) || {};
    my $lldp = $foundry->lldp_ip($partial)     || {};

    my %c_ip;
    foreach my $iid ( keys %$cdp ) {
        my $ip = $cdp->{$iid};
        next unless defined $ip;

        $c_ip{$iid} = $ip;
    }

    foreach my $iid ( keys %$lldp ) {
        my $ip = $lldp->{$iid};
        next unless defined $ip;

        $c_ip{$iid} = $ip;
    }
    return \%c_ip;
}

sub c_if {
    my $foundry = shift;
    my $partial = shift;

    my $lldp = $foundry->lldp_if($partial)     || {};
    my $cdp  = $foundry->SUPER::c_if($partial) || {};

    my %c_if;
    foreach my $iid ( keys %$cdp ) {
        my $if = $cdp->{$iid};
        next unless defined $if;

        $c_if{$iid} = $if;
    }

    foreach my $iid ( keys %$lldp ) {
        my $if = $lldp->{$iid};
        next unless defined $if;

        $c_if{$iid} = $if;
    }
    return \%c_if;
}

sub c_port {
    my $foundry = shift;
    my $partial = shift;

    my $lldp = $foundry->lldp_port($partial)     || {};
    my $cdp  = $foundry->SUPER::c_port($partial) || {};

    my %c_port;
    foreach my $iid ( keys %$cdp ) {
        my $port = $cdp->{$iid};
        next unless defined $port;

        $c_port{$iid} = $port;
    }

    foreach my $iid ( keys %$lldp ) {
        my $port = $lldp->{$iid};
        next unless defined $port;

        $c_port{$iid} = $port;
    }
    return \%c_port;
}

sub c_id {
    my $foundry = shift;
    my $partial = shift;

    my $lldp = $foundry->lldp_id($partial)     || {};
    my $cdp  = $foundry->SUPER::c_id($partial) || {};

    my %c_id;
    foreach my $iid ( keys %$cdp ) {
        my $id = $cdp->{$iid};
        next unless defined $id;

        $c_id{$iid} = $id;
    }

    foreach my $iid ( keys %$lldp ) {
        my $id = $lldp->{$iid};
        next unless defined $id;

        $c_id{$iid} = $id;
    }
    return \%c_id;
}

sub c_platform {
    my $foundry = shift;
    my $partial = shift;

    my $lldp = $foundry->lldp_rem_sysdesc($partial)  || {};
    my $cdp  = $foundry->SUPER::c_platform($partial) || {};

    my %c_platform;
    foreach my $iid ( keys %$cdp ) {
        my $platform = $cdp->{$iid};
        next unless defined $platform;

        $c_platform{$iid} = $platform;
    }

    foreach my $iid ( keys %$lldp ) {
        my $platform = $lldp->{$iid};
        next unless defined $platform;

        $c_platform{$iid} = $platform;
    }
    return \%c_platform;
}

1;
__END__