Fix inspection if bmc_address or bmc_v6address is None

IPA started sending None when the device is not found.

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

View File

@ -292,8 +292,8 @@ DATA_VALIDATOR = args.schema({
'inventory': { 'inventory': {
'type': 'object', 'type': 'object',
'properties': { 'properties': {
'bmc_address': {'type': 'string'}, 'bmc_address': {'type': ['string', 'null']},
'bmc_v6address': {'type': 'string'}, 'bmc_v6address': {'type': ['string', 'null']},
'interfaces': { 'interfaces': {
'type': 'array', 'type': 'array',
'items': { 'items': {

View File

@ -502,6 +502,19 @@ class TestContinueInspection(test_api_base.BaseApiTest):
mock.ANY, mock.ANY, self.node.uuid, inventory=self.inventory, mock.ANY, mock.ANY, self.node.uuid, inventory=self.inventory,
plugin_data={'test': 42}, topic='test-topic') 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', @mock.patch.object(rpcapi.ConductorAPI, 'get_node_with_token',
autospec=True) autospec=True)
def test_new_api(self, mock_get_node, mock_lookup, mock_continue): 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.