Support for snmpforce_v1, snmpforce_v2, snmpforce_v3

This commit is contained in:
Oliver Gorwits
2014-01-08 05:37:44 +00:00
parent 0c1be4e900
commit f3f55748b5
4 changed files with 33 additions and 21 deletions

View File

@@ -388,7 +388,7 @@ of the device. The regex must match the complete value.
=head3 C<bulkwalk_repeaters>
Value: Numnber. Default: 20.
Value: Number. Default: 20.
Sets the Net-SNMP C<MaxRepeaters> value, which is used on C<BULKWALK>
operations. See L<SNMP> for more info.
@@ -409,6 +409,24 @@ Value: C<1|2|3>. Default: 3.
Highest version of the SNMP protocol used when connecting to devices. Use this
setting to disable SNMP v3 globally. Usually you don't need to configure this.
=head3 C<snmpforce_v1>
Value: List of Network Identifiers or Device Properties. Default: Empty List.
Forces matching devices to use SNMPv1.
=head3 C<snmpforce_v2>
Value: List of Network Identifiers or Device Properties. Default: Empty List.
Forces matching devices to use SNMPv2c.
=head3 C<snmpforce_v3>
Value: List of Network Identifiers or Device Properties. Default: Empty List.
Forces matching devices to use SNMPv3.
=head3 C<snmptimeout>
Value: Number. Default: 1000000.
@@ -874,18 +892,6 @@ C<portctl_timeout>
=item *
C<snmpforce_v1>
=item *
C<snmpforce_v2>
=item *
C<snmpforce_v3>
=item *
C<timeout>
=back

View File

@@ -101,7 +101,8 @@ sub check_acl {
=head2 check_no( $ip, $setting_name )
Given the IP address of a device, returns true if the configuration setting
C<$setting_name> matches that device, else returns false.
C<$setting_name> matches that device, else returns false. If the setting
is undefined or empty, then C<check_no> also returns false.
print "rejected!" if check_no($ip, 'discover_no');
@@ -133,15 +134,16 @@ sub check_no {
my ($ip, $setting_name) = @_;
my $config = setting($setting_name) || [];
return 0 unless scalar @$config;
return 0 if not scalar @$config;
return check_acl($ip, $config);
}
=head2 check_only( $ip, $setting_name )
Given the IP address of a device, returns false if the configuration setting
C<$setting_name> matches that device, else returns true.
Given the IP address of a device, returns true if the configuration setting
C<$setting_name> matches that device, else returns false. If the setting
is undefined or empty, then C<check_only> also returns true.
print "rejected!" unless check_only($ip, 'discover_only');
@@ -173,7 +175,7 @@ sub check_only {
my ($ip, $setting_name) = @_;
my $config = setting($setting_name) || [];
return 1 unless scalar @$config;
return 1 if not scalar @$config;
return check_acl($ip, $config);
}

View File

@@ -96,9 +96,12 @@ sub _snmp_connect_generic {
$snmp_args{AutoSpecity} = 1;
}
# TODO: add version force support
# use existing SNMP version or try 3, 2, 1
my @versions = reverse (1 .. (setting('snmpver') || 3));
# which SNMP versions to try and in what order
my @versions =
( check_no($device->ip, 'snmpforce_v3') ? (3)
: check_no($device->ip, 'snmpforce_v2') ? (2)
: check_no($device->ip, 'snmpforce_v1') ? (1)
: (reverse (1 .. (setting('snmpver') || 3))) );
# get the community string(s)
my @communities = _build_communities($device, $mode);