Skip to content

Commit

Permalink
Use get_snmp_session_for_profile() in Arnold
Browse files Browse the repository at this point in the history
Arnold mostly uses PortAdmin management handlers, except for when
changing the ifAdminStatus value of a port.

This lets the get_snmp_session_for_profile() utility function set up
these SNMP sessions instead, so that even SNMPv3 sessions will be
supported.
  • Loading branch information
lunkwill42 committed Nov 13, 2023
1 parent b9fa1ce commit f5b22a3
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions python/nav/arnold.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from nav.Snmp.errors import AgentError
import nav.bitvector
import nav.buildconf
from nav.Snmp.profile import get_snmp_session_for_profile
from nav.config import find_config_file
from nav.errors import GeneralException
from nav.models.arnold import Identity, Event
Expand Down Expand Up @@ -464,11 +465,7 @@ def change_port_status(action, identity):
if not profile:
raise NoReadWriteManagementProfileError

agent = nav.Snmp.Snmp(
host=netbox.ip,
community=profile.snmp_community,
version=profile.snmp_version,
)
agent = get_snmp_session_for_profile(profile)(host=netbox.ip)

# Disable or enable based on input
try:
Expand Down

0 comments on commit f5b22a3

Please sign in to comment.