Enterasys-NetSight

 view release on metacpan or  search on metacpan

lib/Enterasys/NetSight.pm  view on Meta::CPAN


	my $call=$self->{soap}->getDeviceByIpAddressEx($args->{host}) || return undef;

	if($call->fault) 
		{ carp($call->faultstring) && return undef }

	return $call->result->{data};
}
sub getSnmp
{
	# Returns a hash reference with SNMP credentials
	# The format of this hash can be used to create a 
	# new SNMP::Session with the Net-SNMP module

	my ($self, $args)=@_;
	my (%snmp, %temp)=();

	if(!defined $args->{host})
		{ carp("You must specify a host for getSnmp method") && return undef }
	if(defined $args->{level} && $args->{level} ne "su" && $args->{level} ne "rw" && $args->{level} ne "ro")
		{ carp("Invalid privilege level specified. Valid options are su, rw, or ro") && return undef }

lib/Enterasys/NetSight.pm  view on Meta::CPAN

			{ $snmp{Community}=$temp{ro} }
		else
			{ return undef }
	}

	return \%snmp;
}
sub getAuth
{
	# Runs the 'exportDevices' method if $self->{devices} hash ref is undefined
	# and uses that to parse Cli credentials for all other calls.
	my ($self, $args)=@_;

	if(!defined $args->{host})
		{ carp("You must specify a host for getAuth method") && return undef }
	if($args->{refresh})
		{ $self->{devices}=undef }
	if(!defined $self->{devices})
		{ $self->{devices}={exportDevices($self)}};

	$args->{host}=_resolv($args->{host});

lib/Enterasys/NetSight.pm  view on Meta::CPAN

	my $device=$self->{devices}->{$args->{host}};

	$creds{host}=$device->{dev} || return undef;
	$creds{user}=$device->{cliUsername};
	$creds{pass}=$device->{cliLogin};
	
	return \%creds;
}
sub exportDevices
{
	# Gets credentials for all devices in NetSight as an NGF string and
	# parses it into a hash table
	my ($self)=@_;
	my %table=();

	my $call=$self->{soap}->exportDevicesAsNgf;

	if($call->fault)
		{ carp($call->faultstring) && return undef }

	foreach my $line(split("\n",$call->result))

lib/Enterasys/NetSight.pm  view on Meta::CPAN

	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=SNMP::Session->new(%{$netsight->getSnmp({host=>$ip})});

lib/Enterasys/NetSight.pm  view on Meta::CPAN

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.

=over

=item host

IP address or hostname of a target device.

=item 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.

=back

=item 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 memo...

=over

=item host

IP address or hostname of a target device.

=item refresh

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

lib/Enterasys/NetSight.pm  view on Meta::CPAN

=back

=item 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.

=item 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.

=item addAuth()

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

=over

=item username

lib/Enterasys/NetSight.pm  view on Meta::CPAN

=item name

Name for the profile.

=item snmpVersion

Integer specifying SNMP version 1, 2, or 3.

=item read

SNMP read configuration credentials name as created by addSnmp.

=item write

SNMP write configuration credentials name as created by addSnmp.

=item maxAccess

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

=item auth

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

=back

=item addDevice()

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

=over

=item ipAddress

lib/Enterasys/NetSight.pm  view on Meta::CPAN

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 ...

=item nickName

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

=back

=item updateAuth()

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

=over

=item username

Username for telnet/SSH access.

=item description

Textual description of the profile (64 char limit).

lib/Enterasys/NetSight.pm  view on Meta::CPAN

Password to enable configuration mode.

=item type

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

=back

=item updateSnmp()

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

=over

=item name

Name for the credential set.

=item communityName

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

lib/Enterasys/NetSight.pm  view on Meta::CPAN

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

=over

=item name

Name for the profile.

=item read

SNMP read configuration credentials name as created by addSnmp.

=item write

SNMP write configuration credentials name as created by addSnmp.

=item maxAccess

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

=item authCredName

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

=back

=item ipV6Enabled()

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

=item netSnmpEnabled()

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



( run in 0.221 second using v1.01-cache-2.11-cpan-4d50c553e7e )