Merge "Treat 0.0.0.0 and '' as missing BMC address"

This commit is contained in:
Jenkins 2017-08-10 16:51:42 +00:00 committed by Gerrit Code Review
commit e4b14f1a76
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.