Enterasys::NetSight - Provides an abstraction layer between SOAP::Lite and the Netsight Device WebService.
version 1.0
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}) };
See OF-Connect-WebServices.pdf for details about API calls and complex data types referenced in this doc.
Returns a new Enterasys::Netsight object or undef if invalid parameters were specified.
IP address or hostname of the NetSight server.
Username with API access.
Password for the user.
Optional port, defaults to NetSight's default port 8443.
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.
IP address or hostname of a target device.
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.
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.
Exports devices from the NetSight server and stores an updated copy in memory when set true.
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.
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.
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.
Add telnet/SSH authentication credential. Returns undef on error or a NsWsResult object indicating success.
Username for telnet/SSH access.
Textual description of the profile (64 char limit).
Login password for a telnet/SSH session.
Password to access enable mode.
Password to enable configuration mode.
Type of protocol to use for CLI access, either telnet/SSH.
Add SNMP authentication credential. Returns undef on error or a NsWsResult object indicating success.
Name for the credential set.
Integer specifying SNMP version 1, 2, or 3.
Community name if SNMP v1/2c is being used.
Username if SNMP v3 is being used.
Authentication password if SNMPv3 is being used.
Authentication type if SNMPv3 is being used, either MD5 or SHA1.
SNMPv3 privacy password if SNMPv3 is being used.
Privacy type if SNMPv3 is being used, either DES or AES.
Add an access profile. Returns undef on error or a NsWsResult object indicating success.
Name for the profile.
SNMP read configuration credentials name as created by addSnmp.
SNMP write configuration credentials name as created by addSnmp.
Credentials configuration to use maximum access mode to the device. Name as created by addSnmp.
Telnet/SSH authentication credentials used in this profile. Name as created by addAuth.
Add a device to the NetSight database. Returns undef on error or a NsWsResult object indicating success.
IP address of the device to add.
Name of the access profile used to poll the device.
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.
Common name to use for the device. Empty for no name.
Update existing telnet/SSH credentials. Returns undef on error or a NsWsResult object indicating success.
Update existing SNMP credentials. Returns undef on error or a NsWsResult object indicating success.
Authentication type if SNMPv3 is being used.
Update existing access profile. Returns undef on error or a NsWsResult object indicating success.
Returns 1 if NetSight is configured for IPv6, 0 if not, undef on error. Shortcut for $netsight->{soap}->isNetSnmpEnabled.
Returns 1 if NetSight is using the Net-SNMP stack, 0 if not, undef on error. Shortcut for $netsight->{soap}->netSnmpEnabled.
Chris Handwerker <chandwer@enterasys.com>
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.
To install Enterasys::NetSight, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Enterasys::NetSight
CPAN shell
perl -MCPAN -e shell install Enterasys::NetSight
For more information on module installation, please visit the detailed CPAN module installation guide.