snmp: make oid value retrieval more solid

There's no need to try to convert before ignoring.

Change-Id: Ie9dcb63c43e7d69ce25aff62a2575b89f26ffca5
This commit is contained in:
Julien Danjou 2018-05-02 16:24:30 +02:00
parent 500e34019f
commit 7de90448e6
1 changed files with 5 additions and 7 deletions

View File

@ -195,14 +195,12 @@ class SNMPInspector(base.Inspector):
def get_oid_value(oid_cache, oid_def, suffix='', host=None):
oid, converter = oid_def
value = oid_cache[oid + suffix]
if isinstance(value, rfc1905.NoSuchObject):
LOG.debug("OID %s%s has no value" % (
oid, " on %s" % host.hostname if host else ""))
return None
if converter:
try:
value = converter(value)
except ValueError:
if isinstance(value, rfc1905.NoSuchObject):
LOG.debug("OID %s%s has no value" % (
oid, " on %s" % host.hostname if host else ""))
return None
value = converter(value)
return value
@classmethod