summaryrefslogtreecommitdiff
path: root/ironic/drivers/modules/snmp.py
diff options
context:
space:
mode:
authorHironori Shiina <shiina.hironori@jp.fujitsu.com>2018-07-23 00:16:53 +0900
committerHironori Shiina <shiina.hironori@jp.fujitsu.com>2018-07-24 15:35:10 +0900
commitca6f28957164643d471d6556e2d01a849899bc22 (patch)
tree8f80f3f926f0791cb88fdca07434433104f819cc /ironic/drivers/modules/snmp.py
parente19efd8ca563579dc2f45ea9dd3653c6017ee0fd (diff)
downloadironic-ca6f28957164643d471d6556e2d01a849899bc22.tar.gz
snmp: Keep get_next method backward-compatible
get_next() method used to get values under scope of a given OID before high-level API was introduced. This patch makes this method work as before since iRMC inspection depends on this behavior. Change-Id: I3b5abc2e7df9283086265df090f23890a409bc1d
Diffstat (limited to 'ironic/drivers/modules/snmp.py')
-rw-r--r--ironic/drivers/modules/snmp.py31
1 files changed, 19 insertions, 12 deletions
diff --git a/ironic/drivers/modules/snmp.py b/ironic/drivers/modules/snmp.py
index ee9bda1cc..895b94de1 100644
--- a/ironic/drivers/modules/snmp.py
+++ b/ironic/drivers/modules/snmp.py
@@ -320,25 +320,32 @@ class SNMPClient(object):
self._get_auth(),
self._get_transport(),
self._get_context(),
- snmp.ObjectType(snmp.ObjectIdentity(oid)))
+ snmp.ObjectType(snmp.ObjectIdentity(oid)),
+ lexicographicMode=False)
except snmp_error.PySnmpError as e:
raise exception.SNMPFailure(operation="GET_NEXT", error=e)
- (error_indication, error_status, error_index,
- var_bind_table) = next(snmp_gen)
+ vals = []
+ for (error_indication, error_status, error_index,
+ var_binds) in snmp_gen:
- if error_indication:
- # SNMP engine-level error.
- raise exception.SNMPFailure(operation="GET_NEXT",
- error=error_indication)
+ if error_indication:
+ # SNMP engine-level error.
+ raise exception.SNMPFailure(operation="GET_NEXT",
+ error=error_indication)
- if error_status:
- # SNMP PDU error.
- raise exception.SNMPFailure(operation="GET_NEXT",
- error=error_status.prettyPrint())
+ if error_status:
+ # SNMP PDU error.
+ raise exception.SNMPFailure(operation="GET_NEXT",
+ error=error_status.prettyPrint())
+
+ # this is not a table, but a table row
+ # e.g. 1-D array of tuples
+ _name, value = var_binds[0]
+ vals.append(value)
- return [val for row in var_bind_table for name, val in row]
+ return vals
def set(self, oid, value):
"""Use PySNMP to perform an SNMP SET operation on a single object.