Skip to content
Snippets Groups Projects
Commit f94d19f4 authored by Pelle Koster's avatar Pelle Koster
Browse files

Convert Nokia SNMP index to integer

parent 3e733987
No related branches found
No related tags found
1 merge request!36Convert Nokia SNMP index to integer
......@@ -154,7 +154,7 @@ def get_interfaces_state(state_doc):
for interface_ in interfaces:
details = {
"interface-name": interface_.find('s:interface-name', namespaces=NS).text,
"if-index": interface_.find('s:if-index', namespaces=NS).text,
"if-index": int(interface_.find('s:if-index', namespaces=NS).text),
"oper-state": interface_.find('s:oper-state', namespaces=NS).text,
}
ipv4 = interface_.find('s:ipv4', namespaces=NS)
......
......@@ -73,3 +73,18 @@ def test_get_interface_state():
expected_up_interfaces = {'system', 'lag-2.0', 'guy', 'exfo400-100', 'management'}
assert {k for k, v in interfaces.items() if
v['oper-state'] == 'up'} == expected_up_interfaces
def test_snmp_index():
interfaces = get_interfaces_state(state_doc)
expected = {
"system": 1,
"lag-1.0": 2,
"lag-2.0": 3,
"lag-3.0": 4,
"exfo400": 5,
"guy": 6,
"exfo400-100": 7,
"management": 1280,
}
assert {ifc["interface-name"]: ifc["if-index"] for ifc in interfaces} == expected
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment