diff options
author | Zuul <zuul@review.opendev.org> | 2020-09-30 09:06:34 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2020-09-30 09:06:34 +0000 |
commit | 672c61938ed23ea54afcebca8e032d01edb5f665 (patch) | |
tree | fae5ac1bfed30dcb54ab4b92e7714b4d3d6c734e | |
parent | 1f2b0b6bcd9fe89e894426fb942924d00d5a1201 (diff) | |
parent | 0e399f750ad88823c4d8c6355b70f23d98797ee8 (diff) | |
download | ironic-672c61938ed23ea54afcebca8e032d01edb5f665.tar.gz |
Merge "Fix handling OctetString for pysnmp"
-rw-r--r-- | ironic/drivers/modules/irmc/inspect.py | 2 | ||||
-rw-r--r-- | ironic/tests/unit/drivers/modules/irmc/test_inspect.py | 23 | ||||
-rw-r--r-- | lower-constraints.txt | 1 | ||||
-rw-r--r-- | releasenotes/notes/fix-irmc-inspection-c9ae3864a96b2588.yaml | 4 | ||||
-rw-r--r-- | test-requirements.txt | 1 |
5 files changed, 25 insertions, 6 deletions
diff --git a/ironic/drivers/modules/irmc/inspect.py b/ironic/drivers/modules/irmc/inspect.py index 5d438a6c8..4204ac95b 100644 --- a/ironic/drivers/modules/irmc/inspect.py +++ b/ironic/drivers/modules/irmc/inspect.py @@ -110,7 +110,7 @@ def _get_mac_addresses(node): d_info['irmc_snmp_security']) node_classes = snmp_client.get_next(NODE_CLASS_OID) - mac_addresses = [':'.join(['%02x' % ord(x) for x in mac]) + mac_addresses = [':'.join(['%02x' % x for x in mac]) for mac in snmp_client.get_next(MAC_ADDRESS_OID)] return [a for c, a in zip(node_classes, mac_addresses) diff --git a/ironic/tests/unit/drivers/modules/irmc/test_inspect.py b/ironic/tests/unit/drivers/modules/irmc/test_inspect.py index 0a6eeb399..9eb8dbb85 100644 --- a/ironic/tests/unit/drivers/modules/irmc/test_inspect.py +++ b/ironic/tests/unit/drivers/modules/irmc/test_inspect.py @@ -18,6 +18,8 @@ Test class for iRMC Inspection Driver from unittest import mock +from pysnmp.proto import rfc1902 + from ironic.common import exception from ironic.common import states from ironic.common import utils @@ -38,12 +40,23 @@ class IRMCInspectInternalMethodsTestCase(test_common.BaseIRMCTest): @mock.patch('ironic.drivers.modules.irmc.inspect.snmp.SNMPClient', spec_set=True, autospec=True) def test__get_mac_addresses(self, snmpclient_mock): + + # NOTE(yushiro): In pysnmp 4.4.12, SNMPClient returns following type: + # node classes: pysnmp.proto.rfc1902.Integer32 + # mac addresses: pysnmp.proto.rfc1902.OctetString snmpclient_mock.return_value = mock.Mock( - **{'get_next.side_effect': [[2, 2, 7], - ['\xaa\xaa\xaa\xaa\xaa\xaa', - '\xbb\xbb\xbb\xbb\xbb\xbb', - '\xcc\xcc\xcc\xcc\xcc\xcc']]}) - inspected_macs = ['aa:aa:aa:aa:aa:aa', 'bb:bb:bb:bb:bb:bb'] + **{'get_next.side_effect': [ + [ + rfc1902.Integer32(2), + rfc1902.Integer32(2), + rfc1902.Integer32(7) + ], [ + rfc1902.OctetString('\x90\x1b\x0e\xa5\x70\x37'), + rfc1902.OctetString('\x90\x1b\x0e\xa5\x70\x38'), + rfc1902.OctetString('\x90\x1b\x0e\xa5\x70\x39') + ]]} + ) + inspected_macs = ['90:1b:0e:a5:70:37', '90:1b:0e:a5:70:38'] with task_manager.acquire(self.context, self.node.uuid, shared=True) as task: result = irmc_inspect._get_mac_addresses(task.node) diff --git a/lower-constraints.txt b/lower-constraints.txt index 3d89103c0..b0c82690c 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -95,6 +95,7 @@ pyOpenSSL==19.1.0 pyparsing==2.4.7 pyperclip==1.8.0 pysendfile==2.0.0 +pysnmp==4.4.12 python-cinderclient==3.3.0 python-dateutil==2.8.1 python-editor==1.0.4 diff --git a/releasenotes/notes/fix-irmc-inspection-c9ae3864a96b2588.yaml b/releasenotes/notes/fix-irmc-inspection-c9ae3864a96b2588.yaml new file mode 100644 index 000000000..e3e717b2a --- /dev/null +++ b/releasenotes/notes/fix-irmc-inspection-c9ae3864a96b2588.yaml @@ -0,0 +1,4 @@ +--- +fixes: + - | + Fixed iRMC inspection for getting MAC address.
\ No newline at end of file diff --git a/test-requirements.txt b/test-requirements.txt index bb792c420..fb628fe40 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -16,6 +16,7 @@ testtools>=2.2.0 # MIT WebTest>=2.0.27 # MIT bashate>=0.5.1 # Apache-2.0 pycodestyle>=2.0.0,<2.6.0 # MIT +pysnmp>=4.4.12 flake8-import-order>=0.17.1 # LGPLv3 Pygments>=2.2.0 # BSD bandit!=1.6.0,>=1.1.0,<2.0.0 # Apache-2.0 |