Fix inspection if bmc_address or bmc_v6address is None

IPA started sending None when the device is not found.

Change-Id: Ibeef33ff9a0acdb7c605bc46ef9e5d203c7aaa6d
(cherry picked from commit ad03a4c32d)
This commit is contained in:
Dmitry Tantsur 2024-09-11 10:01:57 +02:00
parent d8440aac9e
commit 19de7ae2f4
No known key found for this signature in database
GPG Key ID: 315B2AF9FD216C60
3 changed files with 20 additions and 2 deletions

View File

@ -275,8 +275,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': {

View File

@ -460,6 +460,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):

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Fixes inspection failure when ``bmc_address`` or ``bmc_v6address`` is
``null`` in the inventory received from the ramdisk.