Skip to content

Commit

Permalink
Use get_snmp_session_for_profile() in SNMPHandler
Browse files Browse the repository at this point in the history
Lets the utility function set up the SNMP session for SNMPHandler based
management handlers in PortAdmin.
  • Loading branch information
lunkwill42 committed Nov 16, 2023
1 parent 5368290 commit d028681
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions python/nav/portadmin/snmp/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,8 @@ def _get_read_only_handle(self):
if not profile:
raise NoReadOnlyManagementProfileError

self.read_only_handle = Snmp.Snmp(
self.read_only_handle = get_snmp_session_for_profile(profile)(
host=self.netbox.ip,
community=profile.snmp_community,
version=profile.snmp_version,
retries=self.retries,
timeout=self.timeout,
)
Expand All @@ -206,10 +204,8 @@ def _get_read_write_handle(self):
"""
if self.read_write_handle is None:
profile = self.netbox.get_preferred_snmp_management_profile(writeable=True)
self.read_write_handle = Snmp.Snmp(
self.read_write_handle = get_snmp_session_for_profile(profile)(
host=self.netbox.ip,
community=profile.snmp_community,
version=profile.snmp_version,
retries=self.retries,
timeout=self.timeout,
)
Expand Down

0 comments on commit d028681

Please sign in to comment.