From 6d06f09e8920c135eb783bf523fb944197d0796e Mon Sep 17 00:00:00 2001 From: Sam Betts Date: Wed, 16 Sep 2015 15:06:47 +0100 Subject: [PATCH] Ignore IPMI Address for IPMI Bridged nodes When a node is behind an IPMI bridge the IPMI address stored in ironic is not a trust worthy identifier for recognising a node returning its introspection data, as it can be the same or multiple nodes. It will also cause unique constraint errors as the database will not allow multiple bmc_address attribute entries with the same value. This patch adds detection for ipmi bridging to the get_ipmi_address function, so if ipmi bridging is enabled then it returns None, and the node is added without any bmc_address listed. Change-Id: I09d17dffcde0f4a023bb03e1bce88bcf725cdf0a Closes-Bug: #1488501 --- ironic_inspector/test/test_utils.py | 6 ++++++ ironic_inspector/utils.py | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/ironic_inspector/test/test_utils.py b/ironic_inspector/test/test_utils.py index 614c2e353..1bd2376a7 100644 --- a/ironic_inspector/test/test_utils.py +++ b/ironic_inspector/test/test_utils.py @@ -171,6 +171,12 @@ class TestGetIpmiAddress(base.BaseTest): ip = utils.get_ipmi_address(node) self.assertEqual(ip, '192.168.1.1') + def test_ipmi_bridging_enabled(self): + node = mock.Mock(spec=['driver_info', 'uuid'], + driver_info={'ipmi_address': 'www.example.com', + 'ipmi_bridging': 'single'}) + self.assertIsNone(utils.get_ipmi_address(node)) + class TestCapabilities(unittest.TestCase): diff --git a/ironic_inspector/utils.py b/ironic_inspector/utils.py index f8a2f6feb..ca1f424d7 100644 --- a/ironic_inspector/utils.py +++ b/ironic_inspector/utils.py @@ -157,6 +157,10 @@ def get_auth_strategy(): def get_ipmi_address(node): ipmi_fields = ['ipmi_address'] + CONF.ipmi_address_fields + # NOTE(sambetts): IPMI Address is useless to us if bridging is enabled so + # just ignore it and return None + if node.driver_info.get("ipmi_bridging", "no") != "no": + return for name in ipmi_fields: value = node.driver_info.get(name) if value: