The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Enterasys::NetSight - Provides an abstraction layer between SOAP::Lite and the Netsight Device WebService.

VERSION

version 1.0

SYNOPSIS

        use Enterasys::NetSight;
        use Data::Dumper;

        my $netsight = Enterasys::NetSight->new({
                                host    => $ip,
                                port    => $port,
                                user    => $username,
                                pass    => $password,
                        }) or die $!;

This module provides wrapper methods for raw API method calls. These methods typically parse the response and return a perl friedly hash table.

You can make any raw API call through the SOAP::Lite object accessable with $netsight->{soap}. For example the following would print a NetSight Generated Format string containing SNMP credentials,

        print $netsight->{soap}->getSnmpCredentialAsNgf($ip)->result(),"\n";

However using the getSnmp wrapper method will parse the NGF string into a hash table,

        print Dumper { $netsight->getSnmp({host=>$ip}) };

Used with the perl SNMP module you can use the return of that method to create a new SNMP session object,

        my $session = new SNMP::Session($netsight->getSnmp({host=>$ip}));

Which you could then use to query a mib,

        print $session->get('sysDescr.0');

More examples

Building a profile up

        $netsight->addAuth({
                type            => 'SSH',
                description     => 'cli',
                username        => 'foo',
                loginPassword   => 'password'
        });
        
        $netsight->addSnmp({
                name            => 'readonly',
                snmpVersion     => '3',
                userName        => 'ro',
                authPassword    => 'foo',
                authType        => 'SHA1'
        });
        
        $netsight->addSnmp({
                name            => 'readwrite',
                snmpVersion     => '3',
                userName        => 'rw',
                authPassword    => 'bar',
                authType        => 'SHA1'
        });
        
        $netsight->addProfile({
                name            => 'foo',
                snmpVersion     => '3',
                read            => 'readonly',
                write           => 'readwrite',
                maxAccess       => 'readwrite',
                auth            => 'cli'
        });
        
        $netsight->addDevice({
                ipAddress       => '127.0.0.1',
                profileName     => 'TestDevice',
                nickName        => 'Testing'
        });

Getting info about a profile

        print Dumper { $netsight->getAuth({host=>127.0.0.1, refresh=>1}) };
        print Dumper { $netsight->getSnmp({host=>'127.0.0.1', level=> ro}) };
        print Dumper { $netsight->getDevice({host=>$ip}) };

METHODS

See OF-Connect-WebServices.pdf for details about API calls and complex data types referenced in this doc.

new()

Returns a new Enterasys::Netsight object or undef if invalid parameters were specified.

host

IP address or hostname of the NetSight server.

user

Username with API access.

pass

Password for the user.

port

Optional port, defaults to NetSight's default port 8443.

getSnmp()

Returns a hash table which can be passed as an argument to make a new SNMP::Session with the perl SNMP module. Returns undef if no SNMP creds found.

host

IP address or hostname of a target device.

level

Optional, defaults to highest privilage level available. Options are su, rw, ro (super user, read/write, read only). If specified privilage does not exist method returns undef. This parameter is ignored if the device has SNMP v3 credentials.

getAuth()

Returns a hash table containing CLI credentials: host, user, and pass. Because there is no API call to get a single CLI cred, similar to getSnmpCredentialAsNgf, this method runs the "exportDevices" method once and keeps the device information in memory.

host

IP address or hostname of a target device.

refresh

Exports devices from the NetSight server and stores an updated copy in memory when set true.

getDevice()

Returns a WsDevice hash table containing device information. Shortcut for $netsight->{soap}->getDeviceByIpAddressEx($ip)->result()->{data}. This method will check the return status for errors. Returns undef if no device details found.

host

IP address or hostname of a target device.

getAllDevices()

Returns a hash table with device IP address keys and hash reference values pointing to a WsDevice table containing device information. Returns undef on error.

exportDevices()

Returns a hash table with device IP address keys and a hash reference to a table containing both SNMP and/or CLI credentials. This method parses the NetSight Generated Format (NGF) strings returned from the 'exportDevicesAsNgf' API call. Returns undef on error.

addAuth()

Add telnet/SSH authentication credential. Returns undef on error or a NsWsResult object indicating success.

username

Username for telnet/SSH access.

description

Textual description of the profile (64 char limit).

loginPassword

Login password for a telnet/SSH session.

enablePassword

Password to access enable mode.

configurationPassword

Password to enable configuration mode.

type

Type of protocol to use for CLI access, either telnet/SSH.

addSnmp()

Add SNMP authentication credential. Returns undef on error or a NsWsResult object indicating success.

name

Name for the credential set.

snmpVersion

Integer specifying SNMP version 1, 2, or 3.

communityName

Community name if SNMP v1/2c is being used.

userName

Username if SNMP v3 is being used.

authPassword

Authentication password if SNMPv3 is being used.

authType

Authentication type if SNMPv3 is being used, either MD5 or SHA1.

privPassword

SNMPv3 privacy password if SNMPv3 is being used.

privType

Privacy type if SNMPv3 is being used, either DES or AES.

addProfile()

Add an access profile. Returns undef on error or a NsWsResult object indicating success.

name

Name for the profile.

snmpVersion

Integer specifying SNMP version 1, 2, or 3.

read

SNMP read configuration credentials name as created by addSnmp.

write

SNMP write configuration credentials name as created by addSnmp.

maxAccess

Credentials configuration to use maximum access mode to the device. Name as created by addSnmp.

auth

Telnet/SSH authentication credentials used in this profile. Name as created by addAuth.

addDevice()

Add a device to the NetSight database. Returns undef on error or a NsWsResult object indicating success.

ipAddress

IP address of the device to add.

profileName

Name of the access profile used to poll the device.

snmpContext

An SNMP context is a collection of MIB objects, often associated with a network entity. The SNMP context lets you access a subset of MIB objects related to that context. Console lets you specify a SNMP Context for both SNMPv1/v2 and SNMPv3. Or empty for no Context.

nickName

Common name to use for the device. Empty for no name.

updateAuth()

Update existing telnet/SSH credentials. Returns undef on error or a NsWsResult object indicating success.

username

Username for telnet/SSH access.

description

Textual description of the profile (64 char limit).

loginPassword

Login password for a telnet/SSH session.

enablePassword

Password to access enable mode.

configurationPassword

Password to enable configuration mode.

type

Type of protocol to use for CLI access, either telnet/SSH.

updateSnmp()

Update existing SNMP credentials. Returns undef on error or a NsWsResult object indicating success.

name

Name for the credential set.

communityName

Community name if SNMP v1/2c is being used.

userName

Username if SNMP v3 is being used.

authPassword

Authentication type if SNMPv3 is being used.

authType

Authentication type if SNMPv3 is being used, either MD5 or SHA1.

privPassword

SNMPv3 privacy password if SNMPv3 is being used.

privType

Privacy type if SNMPv3 is being used, either DES or AES.

updateProfile()

Update existing access profile. Returns undef on error or a NsWsResult object indicating success.

name

Name for the profile.

read

SNMP read configuration credentials name as created by addSnmp.

write

SNMP write configuration credentials name as created by addSnmp.

maxAccess

Credentials configuration to use maximum access mode to the device. Name as created by addSnmp.

authCredName

Telnet/SSH authentication credentials used in this profile. Name as created by addAuth.

ipV6Enabled()

Returns 1 if NetSight is configured for IPv6, 0 if not, undef on error. Shortcut for $netsight->{soap}->isNetSnmpEnabled.

netSnmpEnabled()

Returns 1 if NetSight is using the Net-SNMP stack, 0 if not, undef on error. Shortcut for $netsight->{soap}->netSnmpEnabled.

AUTHOR

Chris Handwerker <chandwer@enterasys.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Chris Handwerker.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.