Skip to content

Commit 34f05c9

Browse files
committed
[change] Use one query for neighbors and their states
1 parent acafe93 commit 34f05c9

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

netengine/backends/snmp/openwrt.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -505,11 +505,19 @@ def neighbors(self):
505505
'7': 'INCOMPLETE',
506506
}
507507

508-
# TODO: find a way to extract IP address from the OID
509-
neighbors = self.next('1.3.6.1.2.1.4.35.1.4')[3]
510-
neighbor_states = self.next('1.3.6.1.2.1.4.35.1.7')[3]
508+
neighbors_oid = '1.3.6.1.2.1.4.35.1.4'
509+
neighbor_states_oid = '1.3.6.1.2.1.4.35.1.7'
510+
neighbor_info = self.next('1.3.6.1.2.1.4.35.1')[3]
511+
neighbors = []
512+
neighbor_states = []
511513
result = []
512514

515+
for oid in neighbor_info:
516+
if neighbors_oid in str(oid[0][0]):
517+
neighbors.append(oid)
518+
elif neighbor_states_oid in str(oid[0][0]):
519+
neighbor_states.append(oid)
520+
513521
for index, neighbor in enumerate(neighbors):
514522
try:
515523
oid = neighbor[0][0].getOid()

0 commit comments

Comments
 (0)