Skip to content

Commit

Permalink
[change] Use Trie instead of Dict in walk function
Browse files Browse the repository at this point in the history
  • Loading branch information
purhan committed Jul 29, 2021
1 parent 5dc3cc6 commit 15c779d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
4 changes: 1 addition & 3 deletions netengine/backends/snmp/airos.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import logging
from datetime import datetime

from pytrie import StringTrie as Trie

from netengine.exceptions import NetEngineError

from .base import SNMP
Expand Down Expand Up @@ -510,7 +508,7 @@ def resources_to_dict(self, snmpdump=None):

def to_dict(self, snmpdump=None, autowalk=True):
if autowalk:
snmpdump = Trie(self.walk('1.3.6'))
snmpdump = self.walk('1.3.6')
result = self._dict(
{
'type': 'DeviceMonitoring',
Expand Down
3 changes: 2 additions & 1 deletion netengine/backends/snmp/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

from netengine.backends import BaseBackend
from netengine.exceptions import NetEngineError
from pytrie import StringTrie

__all__ = ['SNMP']

Expand Down Expand Up @@ -96,7 +97,7 @@ def _oid(self, oid):
return str(oid)

def walk(self, oid):
result = dict()
result = StringTrie()
for (errorIndication, errorStatus, errorIndex, varBinds) in nextCmd(
SnmpEngine(),
self.community,
Expand Down
3 changes: 1 addition & 2 deletions netengine/backends/snmp/openwrt.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import pytz
from netaddr import EUI, mac_unix_expanded
from pytrie import StringTrie as Trie

from netengine.backends.snmp import SNMP
from netengine.exceptions import NetEngineError
Expand Down Expand Up @@ -606,7 +605,7 @@ def neighbors(self, snmpdump=None):

def to_dict(self, snmpdump=None, autowalk=True):
if autowalk:
snmpdump = Trie(self.walk('1.2'))
snmpdump = self.walk('1.2')
result = self._dict(
{
'type': 'DeviceMonitoring',
Expand Down

0 comments on commit 15c779d

Please sign in to comment.