diff --git a/ironic_inspector/test/unit/test_process.py b/ironic_inspector/test/unit/test_process.py index af14e1d94..09027b668 100644 --- a/ironic_inspector/test/unit/test_process.py +++ b/ironic_inspector/test/unit/test_process.py @@ -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, diff --git a/ironic_inspector/utils.py b/ironic_inspector/utils.py index d5eeb3eb2..7c33cac03 100644 --- a/ironic_inspector/utils.py +++ b/ironic_inspector/utils.py @@ -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): diff --git a/releasenotes/notes/empty-ipmi-address-5b5ca186a066ed32.yaml b/releasenotes/notes/empty-ipmi-address-5b5ca186a066ed32.yaml new file mode 100644 index 000000000..32bb2ecd3 --- /dev/null +++ b/releasenotes/notes/empty-ipmi-address-5b5ca186a066ed32.yaml @@ -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.