From f52ca20ae8b60a1dd15df2b23f8f16c7d1e3561f Mon Sep 17 00:00:00 2001 From: Morten Brekkevold Date: Fri, 24 Nov 2023 13:23:39 +0100 Subject: [PATCH] Fix SNMP v1/v2c regression in async libraries The SNMPParameters class expects its SNMP version attribute to be an integer. However, some (or perhaps all) SNMPv1/v2c management profiles tend to store the version numbers as strings, for some reason. The net result is that the `as_agentproxy_args()` method would fail to provide a `community` argument to SNMP v1/v2 sessions because it was unable to compare an integer version number to a string. --- python/nav/ipdevpoll/snmp/common.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/nav/ipdevpoll/snmp/common.py b/python/nav/ipdevpoll/snmp/common.py index baf0b62cd6..795d399519 100644 --- a/python/nav/ipdevpoll/snmp/common.py +++ b/python/nav/ipdevpoll/snmp/common.py @@ -209,6 +209,8 @@ def factory( kwargs_out.update( {k: v for k, v in profile.configuration.items() if hasattr(cls, k)} ) + # Sometimes profiles store the version number as a string + kwargs_out["version"] = int(kwargs_out["version"]) else: _logger.debug("%r has no snmp profile", netbox) return None