From fbba09b7480900395c685c20eaf4bf0c31fb18e9 Mon Sep 17 00:00:00 2001
From: Robert Latta <robert.latta@geant.org>
Date: Fri, 28 Mar 2025 10:58:45 +0000
Subject: [PATCH] updated snmp info to include oids as a list. RE DBOARD3-1152

---
 inventory_provider/nokia.py           | 10 +++++++---
 inventory_provider/snmp.py            | 17 +++++++++++++++--
 test/per_router/test_snmp_handling.py |  2 +-
 3 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/inventory_provider/nokia.py b/inventory_provider/nokia.py
index 528a0ac..54693ee 100644
--- a/inventory_provider/nokia.py
+++ b/inventory_provider/nokia.py
@@ -225,7 +225,7 @@ def _default_snmp_interface_info(interface_, name_field, communities):
     return {
         'name': interface_[name_field],
         'index': index,
-        'oid': f'{snmp.IF_OPER_STATUS}.{index}',
+        'oids': [f'{snmp.IF_ADMIN_STATUS}.{index}'],
         'communities': communities
     }
 
@@ -256,7 +256,9 @@ def get_services_snmp_info(service_elements, interface_state_elements, communiti
         yield {
             'name': interface_info['interface-name'],
             'index': interface_info['if-index'],
-            'oid': f'{snmp.NOKIA_IES_IF_OPER_STATUS}.{interface_info["service-id"]}.{interface_info["if-index"]}',
+            'oids': [
+                f'{snmp.NOKIA_IES_IF_OPER_STATUS}.{interface_info["service-id"]}.{interface_info["if-index"]}'
+            ],
             'communities': communities
         }
 
@@ -294,7 +296,9 @@ def get_epipe_services_snmp_info(netconf_doc, communities):
         yield {
             'name': service['sap-id'],
             'index': -1,
-            'oid': f'{snmp.NOKIA_SVC_OPER_STATUS}.{service["service-id"]}',
+            'oids': [
+                f'{snmp.NOKIA_SVC_OPER_STATUS}.{service["service-id"]}'
+            ],
             'communities': communities
         }
 
diff --git a/inventory_provider/snmp.py b/inventory_provider/snmp.py
index a505876..630bcdf 100644
--- a/inventory_provider/snmp.py
+++ b/inventory_provider/snmp.py
@@ -11,6 +11,9 @@ from pysnmp.error import PySnmpError
 # from pysnmp.smi import view, rfc1902
 
 
+# IF-MIB::ifAdminStatus
+IF_ADMIN_STATUS = '1.3.6.1.2.1.2.2.1.7'
+
 # IF-MIB::ifOperStatus
 IF_OPER_STATUS = '1.3.6.1.2.1.2.2.1.8'
 
@@ -21,9 +24,15 @@ JNX_BGP_M2_PEER_STATE = '1.3.6.1.4.1.2636.5.1.1.2.1.1.1.2'
 # tBgpPeerNgOperLastState
 NOKIA_BGP_PEER_STATE = '1.3.6.1.4.1.6527.3.1.2.14.4.8.1.11'
 
+# TIMETRA-SERV-MIB::svcAdminStatus
+NOKIA_SVC_ADMIN_STATUS = '1.3.6.1.4.1.6527.3.1.2.4.2.2.1.8'
+
 # TIMETRA-SERV-MIB::svcOperStatus
 NOKIA_SVC_OPER_STATUS = '1.3.6.1.4.1.6527.3.1.2.4.2.2.1.9'
 
+# TIMETRA-SERV-MIB::iesIfAdminStatus
+NOKIA_IES_IF_ADMIN_STATUS = '1.3.6.1.4.1.6527.3.1.2.4.2.5.1.5'
+
 # TIMETRA-SERV-MIB::iesIfOperStatus
 NOKIA_IES_IF_OPER_STATUS = '1.3.6.1.4.1.6527.3.1.2.4.2.5.1.6'
 
@@ -159,10 +168,14 @@ def _get_router_snmp_indexes(hostname, community):
     for ifc in walk(hostname, community, RFC1213_MIB_IFDESC):
         m = re.match(r'.*\.(\d+)$', ifc['oid'])
         assert m, f'sanity failure parsing oid: {ifc["oid"]}'
+        index = int(m.group(1))
         yield {
             'name': ifc['value'],
-            'index': int(m.group(1)),
-            'oid': ifc['oid'],
+            'index': index,
+            'oids': [
+                f'{IF_ADMIN_STATUS}.{index}',
+                ifc['oid'],
+            ],
             'community': community
         }
 
diff --git a/test/per_router/test_snmp_handling.py b/test/per_router/test_snmp_handling.py
index 215d006..661f4a3 100644
--- a/test/per_router/test_snmp_handling.py
+++ b/test/per_router/test_snmp_handling.py
@@ -68,7 +68,7 @@ def test_snmp_interfaces_juniper(mocker, netconf_doc):
             "properties": {
                 "name": {"type": "string"},
                 "index": {"type": "integer"},
-                "oid": {"type": "string"},
+                "oids": {"type": "array", "items": {"type": "string"}},
                 "community": {"type": "string"}
             },
             "required": ["name", "index", "community"],
-- 
GitLab