From 2ad638ecb9a745e5107c771661a8dd5f4c628418 Mon Sep 17 00:00:00 2001 From: Morten Brekkevold Date: Mon, 13 Nov 2023 11:14:11 +0100 Subject: [PATCH] Trust get_preferred_snmp_management_profile Netbox.get_preferred_snmp_manage_profile() should be trusted to return a proper SNMP profile. I see no reason to guard against faulty return values like this. --- python/nav/portadmin/snmp/base.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/python/nav/portadmin/snmp/base.py b/python/nav/portadmin/snmp/base.py index dcb550defb..1ed3ae22de 100644 --- a/python/nav/portadmin/snmp/base.py +++ b/python/nav/portadmin/snmp/base.py @@ -21,6 +21,7 @@ from typing import Dict, Sequence, List, Any from nav import Snmp +from nav.Snmp.profile import get_snmp_session_for_profile from nav.Snmp import safestring, OID from nav.Snmp.errors import ( UnsupportedSnmpVersionError, @@ -174,10 +175,6 @@ def _get_read_only_handle(self): if not profile: raise NoReadOnlyManagementProfileError - if not hasattr(profile, "snmp_community") or not hasattr( - profile, "snmp_version" - ): - raise InvalidManagementProfileError self.read_only_handle = Snmp.Snmp( host=self.netbox.ip,