From c615ba4df2848ff4be5cdb30585fe7017f80d85d Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Mon, 6 Jan 2014 20:47:36 +0000 Subject: [PATCH] Ignore smmp_ver in DB when reconnecting to a device --- Netdisco/Changes | 1 + Netdisco/lib/App/Netdisco/Manual/Configuration.pod | 5 +++-- Netdisco/lib/App/Netdisco/Util/SNMP.pm | 10 +++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Netdisco/Changes b/Netdisco/Changes index a825be68..706d95fa 100644 --- a/Netdisco/Changes +++ b/Netdisco/Changes @@ -38,6 +38,7 @@ * Make "Not" option work for vlan number search in Device Ports * [#48] Fix for netmap links when domain_suffix is set (R. Kerr) * [#57] Port sort order for Extreme switches "1:10" format + * [#65] Ignore smmp_ver in DB when reconnecting to a device. 2.020002 - 2013-12-11 diff --git a/Netdisco/lib/App/Netdisco/Manual/Configuration.pod b/Netdisco/lib/App/Netdisco/Manual/Configuration.pod index 795c185d..a3c93bcb 100644 --- a/Netdisco/lib/App/Netdisco/Manual/Configuration.pod +++ b/Netdisco/lib/App/Netdisco/Manual/Configuration.pod @@ -404,9 +404,10 @@ Net-SNMP 5.3 or higher. =head3 C -Value: C<1|2|3>. Default: 2. +Value: C<1|2|3>. Default: 3. -Version of the SNMP protocol used when connecting to devices. +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 diff --git a/Netdisco/lib/App/Netdisco/Util/SNMP.pm b/Netdisco/lib/App/Netdisco/Util/SNMP.pm index 4dfc9dfc..1bfdd965 100644 --- a/Netdisco/lib/App/Netdisco/Util/SNMP.pm +++ b/Netdisco/lib/App/Netdisco/Util/SNMP.pm @@ -98,7 +98,7 @@ sub _snmp_connect_generic { # TODO: add version force support # use existing SNMP version or try 3, 2, 1 - my @versions = reverse (1 .. ($device->snmp_ver || setting('snmpver') || 3)); + my @versions = reverse (1 .. (setting('snmpver') || 3)); # get the community string(s) my @communities = _build_communities($device, $mode); @@ -169,6 +169,10 @@ sub _try_read { and $info->class ); + $device->in_storage + ? $device->update({snmp_ver => $info->snmp_ver}) + : $device->set_column(snmp_ver => $info->snmp_ver); + if ($comm->{community}) { $device->in_storage ? $device->update({snmp_comm => $comm->{community}}) @@ -189,6 +193,10 @@ sub _try_write { $info->set_location($loc) or return undef; return undef unless ($loc eq $info->load_location); + $device->in_storage + ? $device->update({snmp_ver => $info->snmp_ver}) + : $device->set_column(snmp_ver => $info->snmp_ver); + # one of these two cols must be set $device->update_or_create_related('community', { ($comm->{tag} ? (snmp_auth_tag => $comm->{tag}) : ()),