Treat 0.0.0.0 and '' as missing BMC address

It became apparent in https://review.openstack.org/#/c/480679/ that these are
correct values for ipmitool to return.

Change-Id: Ied18a81dc899d8fc5290a2756f412e5075e923c4
This commit is contained in:
Dmitry Tantsur 2017-08-10 10:33:58 +02:00
parent 28da7b6745
commit 2a4c9d800f
3 changed files with 24 additions and 2 deletions

View File

@ -101,6 +101,17 @@ class TestProcess(BaseProcessTest):
self.process_mock.assert_called_once_with(self.node_info, self.node,
self.data)
def test_ipmi_not_detected(self):
self.inventory['bmc_address'] = '0.0.0.0'
process.process(self.data)
self.find_mock.assert_called_once_with(bmc_address=None, mac=mock.ANY)
actual_macs = self.find_mock.call_args[1]['mac']
self.assertEqual(sorted(self.all_macs), sorted(actual_macs))
self.cli.node.get.assert_called_once_with(self.uuid)
self.process_mock.assert_called_once_with(self.node_info, self.node,
self.data)
def test_not_found_in_cache(self):
self.find_mock.side_effect = utils.Error('not found')
self.assertRaisesRegex(utils.Error,

View File

@ -32,9 +32,15 @@ _EXECUTOR = None
def get_ipmi_address_from_data(introspection_data):
try:
return introspection_data['inventory']['bmc_address']
result = introspection_data['inventory']['bmc_address']
except KeyError:
return introspection_data.get('ipmi_address')
result = introspection_data.get('ipmi_address')
if result in ('', '0.0.0.0'):
# ipmitool can return these values, if it does not know the address
return None
else:
return result
def get_pxe_mac(introspection_data):

View File

@ -0,0 +1,5 @@
---
fixes:
- |
``0.0.0.0`` and an empty string in the ``bmc_address`` inventory field
are now correctly treated as missing BMC address.