Enterasys-NetSight
view release on metacpan or search on metacpan
lib/Enterasys/NetSight.pm view on Meta::CPAN
package Enterasys::NetSight;
{
$Enterasys::NetSight::VERSION = '1.2';
}
use strict;
use SOAP::Lite;
use Socket;
use Carp;
# On some systems Crypt::SSLeay tries to use IO::Socket::SSL and breaks,
# This forces it to use Net::SSL just in case.
$ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS}="Net::SSL";
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0;
$ENV{https_proxy}="";
sub new
{
my ($class, $args)=@_;
my $self=
{
host => _resolv($args->{host}) || undef,
port => $args->{port} || 8443,
user => $args->{user} || undef,
pass => $args->{pass} || undef,
};
if(!$self->{host})
{ carp("You must specify a host for new method") && return undef }
elsif(!$self->{user})
{ carp("You must specify a user for new method") && return undef }
elsif(!$self->{pass})
{ carp("You must specify a password for new method") && return undef }
$self->{proxy}="https://".$self->{user}.":".$self->{pass}."@".$self->{host}.":".$self->{port}."/axis/services/NetSightDeviceWebService";
$self->{uri}="http://ws.web.server.netsight.enterasys.com";
$self->{soap}=SOAP::Lite->new(
uri => $self->{uri},
proxy => $self->{proxy},
);
# Try one API-Call to check if the API responds properly. On errors
# (wrong username or password, etc.) the SOAP-Module prints the
# API-Errorcode and exits the process.
$self->{soap}->isIpV6Enabled();
return bless($self, $class);
}
# Shortcut methods for getting and parsing method returns
sub getAllDevices
{
# Returns a hash table with IP Addresses for keys
# and a hash reference value containing device information
# associated with the IP address
my ($self)=@_;
my %devices=();
my $call=$self->{soap}->getAllDevices;
if($call->fault)
{ carp($call->faultstring) && return undef }
# Grab IP out of each WsDeviceListResult
while(my($key,$value)=each($call->result->{data} || return undef))
{ $devices{$value->{ip}}=$value }
return \%devices;
}
sub getDevice
{
( run in 1.795 second using v1.01-cache-2.11-cpan-39bf76dae61 )