accept hashref or bare list to new()
This commit is contained in:
@@ -57,14 +57,16 @@ list any missing functionality (such as neighbor discovery tables).
|
|||||||
|
|
||||||
use SNMP::Info;
|
use SNMP::Info;
|
||||||
|
|
||||||
my $info = new SNMP::Info(
|
my $info = SNMP::Info->new({
|
||||||
# Auto Discover more specific Device Class
|
# Auto Discover your Device Class (Cisco, Juniper, etc ...)
|
||||||
AutoSpecify => 1,
|
AutoSpecify => 1,
|
||||||
Debug => 1,
|
Debug => 1,
|
||||||
|
|
||||||
# The rest is passed to SNMP::Session
|
# The rest is passed to SNMP::Session
|
||||||
DestHost => 'router',
|
DestHost => 'router',
|
||||||
Community => 'public',
|
Community => 'public',
|
||||||
Version => 2
|
Version => 2
|
||||||
|
|
||||||
# Parameter reference for SNMPv3
|
# Parameter reference for SNMPv3
|
||||||
# Version => 3
|
# Version => 3
|
||||||
# SecLevel => 'authPriv', # authPriv|authNoPriv|noAuthNoPriv
|
# SecLevel => 'authPriv', # authPriv|authNoPriv|noAuthNoPriv
|
||||||
@@ -73,7 +75,7 @@ list any missing functionality (such as neighbor discovery tables).
|
|||||||
# AuthPass => 'authp4ss',
|
# AuthPass => 'authp4ss',
|
||||||
# PrivProto => 'DES', # DES|AES
|
# PrivProto => 'DES', # DES|AES
|
||||||
# PrivPass => 'pr1vp4ss',
|
# PrivPass => 'pr1vp4ss',
|
||||||
);
|
});
|
||||||
|
|
||||||
my $err = $info->error();
|
my $err = $info->error();
|
||||||
die $err if defined $err;
|
die $err if defined $err;
|
||||||
@@ -1209,18 +1211,24 @@ on the Netdisco README!
|
|||||||
|
|
||||||
Creates a new object and connects via SNMP::Session.
|
Creates a new object and connects via SNMP::Session.
|
||||||
|
|
||||||
my $info = new SNMP::Info( 'Debug' => 1,
|
Always returns an SNMP::Info instance, and you should always check for
|
||||||
'AutoSpecify' => 1,
|
error() as in SYNOPSIS above to be sure of success.
|
||||||
'BigInt' => 1,
|
|
||||||
'BulkWalk' => 1,
|
Will take a bare list of key/value options but we recommend a HASH ref
|
||||||
'BulkRepeaters' => 20,
|
as in the example below and SYNOPSIS, to catch syntax errors.
|
||||||
'IgnoreNetSNMPConf' => 1,
|
|
||||||
'LoopDetect' => 1,
|
my $info = SNMP::Info->({ 'Debug' => 1,
|
||||||
'DestHost' => 'myrouter',
|
'AutoSpecify' => 1,
|
||||||
'Community' => 'public',
|
'BigInt' => 1,
|
||||||
'Version' => 2,
|
'BulkWalk' => 1,
|
||||||
'MibDirs' => ['dir1','dir2','dir3'],
|
'BulkRepeaters' => 20,
|
||||||
) or die;
|
'LoopDetect' => 1,
|
||||||
|
'IgnoreNetSNMPConf' => 1,
|
||||||
|
'DestHost' => 'myrouter',
|
||||||
|
'Community' => 'public',
|
||||||
|
'Version' => 2,
|
||||||
|
'MibDirs' => ['dir1','dir2','dir3'],
|
||||||
|
});
|
||||||
|
|
||||||
SNMP::Info Specific Arguments :
|
SNMP::Info Specific Arguments :
|
||||||
|
|
||||||
@@ -1359,7 +1367,7 @@ then fallback to version 1.
|
|||||||
sub new {
|
sub new {
|
||||||
my $proto = shift;
|
my $proto = shift;
|
||||||
my $class = ref($proto) || $proto;
|
my $class = ref($proto) || $proto;
|
||||||
my %args = @_;
|
my %args = (ref $_[0] ? %{ $_[0] } : @_);
|
||||||
my %sess_args = %args;
|
my %sess_args = %args;
|
||||||
my $new_obj = {};
|
my $new_obj = {};
|
||||||
bless $new_obj, $class;
|
bless $new_obj, $class;
|
||||||
|
|||||||
Reference in New Issue
Block a user