Merge "Do not rely on the older ipmi_address field on lookup"

This commit is contained in:
Jenkins 2017-09-08 10:04:18 +00:00 committed by Gerrit Code Review
commit a530a02e1e
4 changed files with 24 additions and 4 deletions

View File

@ -222,9 +222,9 @@ class ValidateInterfacesHook(base.ProcessingHook):
"""Validate information about network interfaces."""
bmc_address = utils.get_ipmi_address_from_data(introspection_data)
if bmc_address:
introspection_data['ipmi_address'] = bmc_address
else:
# Overwrite the old ipmi_address field to avoid inconsistency
introspection_data['ipmi_address'] = bmc_address
if not bmc_address:
LOG.debug('No BMC address provided in introspection data, '
'assuming virtual environment', data=introspection_data)

View File

@ -83,7 +83,7 @@ def _store_logs(introspection_data, node_info):
def _find_node_info(introspection_data, failures):
try:
return node_cache.find_node(
bmc_address=introspection_data.get('ipmi_address'),
bmc_address=utils.get_ipmi_address_from_data(introspection_data),
mac=utils.get_valid_macs(introspection_data))
except utils.NotFoundInCacheError as exc:
not_found_hook = plugins_base.node_not_found_hook_manager()

View File

@ -112,6 +112,18 @@ class TestProcess(BaseProcessTest):
self.process_mock.assert_called_once_with(self.node_info, self.node,
self.data)
def test_ipmi_not_detected_with_old_field(self):
self.inventory['bmc_address'] = '0.0.0.0'
self.data['ipmi_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

@ -0,0 +1,8 @@
---
fixes:
- |
The older ``ipmi_address`` field in the introspection data no longer has
priority over the newer ``bmc_address`` inventory field during lookup.
This fixes lookup based on MAC addresses, when the BMC address is reported
as ``0.0.0.0`` for any reason (see `bug 1714944
<https://bugs.launchpad.net/ironic-python-agent/+bug/1714944>`_).