Skip to content

Commit

Permalink
[change] Use one query for neighbors and their states
Browse files Browse the repository at this point in the history
  • Loading branch information
purhan committed Jul 7, 2021
1 parent acafe93 commit 34f05c9
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions netengine/backends/snmp/openwrt.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,11 +505,19 @@ def neighbors(self):
'7': 'INCOMPLETE',
}

# TODO: find a way to extract IP address from the OID
neighbors = self.next('1.3.6.1.2.1.4.35.1.4')[3]
neighbor_states = self.next('1.3.6.1.2.1.4.35.1.7')[3]
neighbors_oid = '1.3.6.1.2.1.4.35.1.4'
neighbor_states_oid = '1.3.6.1.2.1.4.35.1.7'
neighbor_info = self.next('1.3.6.1.2.1.4.35.1')[3]
neighbors = []
neighbor_states = []
result = []

for oid in neighbor_info:
if neighbors_oid in str(oid[0][0]):
neighbors.append(oid)
elif neighbor_states_oid in str(oid[0][0]):
neighbor_states.append(oid)

for index, neighbor in enumerate(neighbors):
try:
oid = neighbor[0][0].getOid()
Expand Down

0 comments on commit 34f05c9

Please sign in to comment.