diff --git a/inventory_provider/nokia.py b/inventory_provider/nokia.py index 528a0ac9f4de50bba4ecc6d4ea1f349dfa2d178b..54693ee56e8940b7b43d56343b714791a7d2a7ef 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 a50587656ba0eb3d97fa2db2bb237722163b78b2..630bcdf0c929ed0a92af076ec11e887ad1813b7b 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 215d0069b0471840ef19d6a91e1e3b940a58d3cd..661f4a39a969ee2fccbf778710bc467abea6a5ba 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"],