From ad03a4c32d496347b31ec63f28babc5fdae8551c Mon Sep 17 00:00:00 2001 From: Dmitry Tantsur Date: Wed, 11 Sep 2024 10:01:57 +0200 Subject: [PATCH] Fix inspection if bmc_address or bmc_v6address is None IPA started sending None when the device is not found. Change-Id: Ibeef33ff9a0acdb7c605bc46ef9e5d203c7aaa6d --- ironic/api/controllers/v1/ramdisk.py | 4 ++-- .../tests/unit/api/controllers/v1/test_ramdisk.py | 13 +++++++++++++ .../notes/bmc-address-none-8214a3f7b67d6a0d.yaml | 5 +++++ 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/bmc-address-none-8214a3f7b67d6a0d.yaml diff --git a/ironic/api/controllers/v1/ramdisk.py b/ironic/api/controllers/v1/ramdisk.py index 967d6e3ea0..8ae9e1f1e2 100644 --- a/ironic/api/controllers/v1/ramdisk.py +++ b/ironic/api/controllers/v1/ramdisk.py @@ -292,8 +292,8 @@ DATA_VALIDATOR = args.schema({ 'inventory': { 'type': 'object', 'properties': { - 'bmc_address': {'type': 'string'}, - 'bmc_v6address': {'type': 'string'}, + 'bmc_address': {'type': ['string', 'null']}, + 'bmc_v6address': {'type': ['string', 'null']}, 'interfaces': { 'type': 'array', 'items': { diff --git a/ironic/tests/unit/api/controllers/v1/test_ramdisk.py b/ironic/tests/unit/api/controllers/v1/test_ramdisk.py index 303cd18221..5b19f43151 100644 --- a/ironic/tests/unit/api/controllers/v1/test_ramdisk.py +++ b/ironic/tests/unit/api/controllers/v1/test_ramdisk.py @@ -502,6 +502,19 @@ class TestContinueInspection(test_api_base.BaseApiTest): mock.ANY, mock.ANY, self.node.uuid, inventory=self.inventory, plugin_data={'test': 42}, topic='test-topic') + def test_bmc_address_as_none(self, mock_lookup, mock_continue): + mock_lookup.return_value = self.node + self.inventory['bmc_address'] = None + self.inventory['bmc_v6address'] = None + response = self.post_json('/continue_inspection', self.data) + self.assertEqual(http_client.ACCEPTED, response.status_int) + self.assertEqual({'uuid': self.node.uuid}, response.json) + mock_lookup.assert_called_once_with( + mock.ANY, self.addresses, [], node_uuid=None) + mock_continue.assert_called_once_with( + mock.ANY, mock.ANY, self.node.uuid, inventory=self.inventory, + plugin_data={'test': 42}, topic='test-topic') + @mock.patch.object(rpcapi.ConductorAPI, 'get_node_with_token', autospec=True) def test_new_api(self, mock_get_node, mock_lookup, mock_continue): diff --git a/releasenotes/notes/bmc-address-none-8214a3f7b67d6a0d.yaml b/releasenotes/notes/bmc-address-none-8214a3f7b67d6a0d.yaml new file mode 100644 index 0000000000..129d74b5a7 --- /dev/null +++ b/releasenotes/notes/bmc-address-none-8214a3f7b67d6a0d.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Fixes inspection failure when ``bmc_address`` or ``bmc_v6address`` is + ``null`` in the inventory received from the ramdisk.