From ae8f547bc0a7142cfd7fb2ea2160852798f7dca8 Mon Sep 17 00:00:00 2001 From: Morten Brekkevold Date: Mon, 13 Nov 2023 11:20:07 +0100 Subject: [PATCH] Use get_snmp_session_for_profile() in SNMPHandler Lets the utility function set up the SNMP session for SNMPHandler based management handlers in PortAdmin. --- python/nav/portadmin/snmp/base.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/python/nav/portadmin/snmp/base.py b/python/nav/portadmin/snmp/base.py index 1ed3ae22de..c9186f622f 100644 --- a/python/nav/portadmin/snmp/base.py +++ b/python/nav/portadmin/snmp/base.py @@ -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, ) @@ -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, )