From 46f1962ea1be79f0b4bba9167de3c306446289db Mon Sep 17 00:00:00 2001
From: Takashi Kajinami <kajinamit@oss.nttdata.com>
Date: Fri, 27 Sep 2024 11:34:33 +0900
Subject: [PATCH] Drop logic for pysnmp < 5

According to the driver-requirements.txt, nironic requires pysnmp >= 5
now, so this logic is just useless.

Change-Id: Iea843689ebf04fa0539c0ff2c783c18131646dff
---
 ironic/drivers/modules/snmp.py | 34 ++++++----------------------------
 1 file changed, 6 insertions(+), 28 deletions(-)

diff --git a/ironic/drivers/modules/snmp.py b/ironic/drivers/modules/snmp.py
index 435d24b789..98d8d424c7 100644
--- a/ironic/drivers/modules/snmp.py
+++ b/ironic/drivers/modules/snmp.py
@@ -46,46 +46,24 @@ if pysnmp:
     snmp_auth_protocols = {
         'md5': snmp.usmHMACMD5AuthProtocol,
         'sha': snmp.usmHMACSHAAuthProtocol,
+        'sha224': snmp.usmHMAC128SHA224AuthProtocol,
+        'sha256': snmp.usmHMAC192SHA256AuthProtocol,
+        'sha384': snmp.usmHMAC256SHA384AuthProtocol,
+        'sha512': snmp.usmHMAC384SHA512AuthProtocol,
         'none': snmp.usmNoAuthProtocol,
     }
 
-    # available since pysnmp 4.4.1
-    try:
-        snmp_auth_protocols.update(
-            {
-                'sha224': snmp.usmHMAC128SHA224AuthProtocol,
-                'sha256': snmp.usmHMAC192SHA256AuthProtocol,
-                'sha384': snmp.usmHMAC256SHA384AuthProtocol,
-                'sha512': snmp.usmHMAC384SHA512AuthProtocol,
-
-            }
-        )
-
-    except AttributeError:
-        pass
-
     snmp_priv_protocols = {
         'des': snmp.usmDESPrivProtocol,
         '3des': snmp.usm3DESEDEPrivProtocol,
         'aes': snmp.usmAesCfb128Protocol,
         'aes192': snmp.usmAesCfb192Protocol,
         'aes256': snmp.usmAesCfb256Protocol,
+        'aes192blmt': snmp.usmAesBlumenthalCfb192Protocol,
+        'aes256blmt': snmp.usmAesBlumenthalCfb256Protocol,
         'none': snmp.usmNoPrivProtocol,
     }
 
-    # available since pysnmp 4.4.3
-    try:
-        snmp_priv_protocols.update(
-            {
-                'aes192blmt': snmp.usmAesBlumenthalCfb192Protocol,
-                'aes256blmt': snmp.usmAesBlumenthalCfb256Protocol,
-
-            }
-        )
-
-    except AttributeError:
-        pass
-
 else:
     snmp = None
     snmp_error = None