Skip to content

Commit

Permalink
Use SNMP profiles' own snmp_version property
Browse files Browse the repository at this point in the history
`ManagementProfile.snmp_version` already does the heavy lifting for
us when it comes to parse the SNMP version value of an SNMP profile,
so let's use that instead to avoid issues like the one described in
#2767
  • Loading branch information
lunkwill42 committed Nov 27, 2023
1 parent 05f5e4c commit feaecfa
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions python/nav/ipdevpoll/snmp/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,11 @@ def factory(
if netbox:
profile = netbox.get_preferred_snmp_management_profile()
if profile:
if profile.protocol == profile.PROTOCOL_SNMPV3:
kwargs["version"] = 3
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"])
# Let profile object parse its own version to an int
kwargs_out["version"] = profile.snmp_version
else:
_logger.debug("%r has no snmp profile", netbox)
return None
Expand Down

0 comments on commit feaecfa

Please sign in to comment.