Skip to content

Commit

Permalink
Make naventity SNMPv3 compatible
Browse files Browse the repository at this point in the history
This gets the SNMP parameters for the AgentProxy constructor from the
new library functions from ipdevpoll, ensuring compatibility with
SNMPv3.
  • Loading branch information
lunkwill42 committed Nov 17, 2023
1 parent 7f4feb8 commit 6f11f95
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions bin/naventity
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ from nav.bootstrap import bootstrap_django
bootstrap_django(__file__)

from nav.util import is_valid_ip
from nav.ipdevpoll.snmp.common import snmp_parameter_factory, SnmpError
from nav.ipdevpoll.snmp.common import snmp_parameter_factory, SnmpError, SNMPParameters
from nav.ipdevpoll.snmp import AgentProxy, snmpprotocol
from nav.mibs.entity_mib import EntityMib
from nav.models.manage import Netbox
Expand Down Expand Up @@ -172,22 +172,13 @@ def device(devicestring):


def _create_agentproxy(netbox, portnumber):
profile = netbox.get_preferred_snmp_management_profile(writeable=False)
if (
not profile
or not hasattr(profile, "snmp_community")
or not hasattr(profile, "snmp_version")
):
params = SNMPParameters.factory(netbox)
if not params:
return

port = snmpprotocol.port()
agent = AgentProxy(
netbox.ip,
portnumber,
community=profile.snmp_community,
snmpVersion='v%s' % profile.snmp_version,
protocol=port.protocol,
snmp_parameters=snmp_parameter_factory(netbox),
netbox.ip, portnumber, protocol=port.protocol, snmp_parameters=params
)
try:
agent.open()
Expand Down

0 comments on commit 6f11f95

Please sign in to comment.