Normalize MAC OctetString to fix InvalidMAC exception

This patch adds a step of MAC OctetString normalization to fix
InvalidMAC exception in iRMC inspection module.

Closes-Bug: #1564190
Change-Id: Ic2a5aaf2beadf06d69864ac7ea0d7a9aadebdc83
This commit is contained in:
Naohiro Tamura 2016-03-31 01:01:17 +09:00
parent 998af9a303
commit df06a848f1
3 changed files with 8 additions and 4 deletions

View File

@ -99,7 +99,8 @@ def _get_mac_addresses(node):
d_info['irmc_snmp_security'])
node_classes = snmp_client.get_next(NODE_CLASS_OID)
mac_addresses = snmp_client.get_next(MAC_ADDRESS_OID)
mac_addresses = [':'.join(['%02x' % ord(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)
if c == NODE_CLASS_OID_VALUE['primary']]

View File

@ -49,9 +49,9 @@ class IRMCInspectInternalMethodsTestCase(db_base.DbTestCase):
def test__get_mac_addresses(self, snmpclient_mock):
snmpclient_mock.return_value = mock.Mock(
**{'get_next.side_effect': [[2, 2, 7],
['aa:aa:aa:aa:aa:aa',
'bb:bb:bb:bb:bb:bb',
'cc:cc:cc:cc:cc:cc']]})
['\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']
with task_manager.acquire(self.context, self.node.uuid,
shared=True) as task:

View File

@ -0,0 +1,3 @@
---
fixes:
- This fixes InvalidMAC exception of iRMC out-of-band inspection.