openwisp / netengine

Python abstraction layer for extracting information from network devices.
http://netengine.rtfd.org
Other
39 stars 17 forks source link

[bug] KeyError: '1' when calling to_dict() #64

Closed nemesifier closed 3 years ago

nemesifier commented 3 years ago

I'm getting this error while testing:

~/Code/openwisp/netengine/netengine/backends/snmp/openwrt.py in to_dict(self)
    529                 'general': {'uptime': self.uptime, "local_time": self.local_time},
    530                 'resources': self.resources_to_dict,
--> 531                 'interfaces': self.interfaces_to_dict,
    532                 'neighbors': self.neighbors,
    533             }

~/Code/openwisp/netengine/netengine/backends/snmp/openwrt.py in interfaces_to_dict(self)
    333             name = self.interfaces_MAC[i]['name']
    334             logger.info('... if_type ...')
--> 335             if_type = self.interfaces_type[i]['type']
    336             logger.info('... mac_address ...')
    337             mac_address = self.interfaces_MAC[i]['mac_address']

~/Code/openwisp/netengine/netengine/backends/snmp/openwrt.py in interfaces_type(self)
    279                     {
    280                         'name': self.get_value(starting + str(i)),
--> 281                         'type': types[self.get_value(types_oid + str(i))],
    282                     }
    283                 )

Any hint on how to debug?

purhan commented 3 years ago

@nemesisdesign This happened because I didn't consider all values for interface type. I have added more in https://github.com/openwisp/netengine/pull/62/commits/acafe93b3307f0a0a5b12f9c7463327716e61840 which should fix it. I wonder if a library exists for this purpose.