Fix missing node facts with BIFROST_INVENTORY_SOURCE=ironic

In Ussuri and earlier releases, the Bifrost custom inventory returns all
node fields as facts. Currently, most of these are returned as null.
This happened following the switch to openstacksdk. The plugin checks
for the presence of a properties field, and gets detailed node
information if it is missing. This worked with shade, but with
openstacksdk, the returned node object has most fields present but set
to null.

One of the most obvious consequences is that provisioning fails, since
the 'Deploy to hardware - Using custom instance_info.' task tries to use
the instance_info value of null.

This change fixes the issue by removing the check and always getting the
detailed node information.

Change-Id: Ia87c8332994f3b0f037ada953a299987bba246e5
Story: 2008394
Task: 41321
This commit is contained in:
Mark Goddard 2020-11-26 15:34:01 +00:00
parent b5e21287a5
commit 71e26d1728
3 changed files with 36 additions and 14 deletions

View File

@ -231,8 +231,7 @@ def _process_sdk(groups, hostvars):
node_names = node_names.split(',')
for machine in machines:
if 'properties' not in machine:
machine = cloud.get_machine(machine['uuid'])
machine = cloud.get_machine(machine['uuid'])
if machine['name'] is None:
name = machine['uuid']
else:

View File

@ -44,18 +44,26 @@ class TestBifrostInventoryUnit(base.TestCase):
mock_cloud = mock_sdk.return_value
mock_cloud.list_machines.return_value = [
{
'driver_info': {
'ipmi_address': '1.2.3.4',
},
'driver_info': None,
'links': [],
'name': 'node1',
'ports': [],
'properties': {
'cpus': 42,
},
'properties': None,
'uuid': 'f3fbf7c6-b4e9-4dd2-8ca0-c74a50f8be45',
},
]
mock_cloud.get_machine.return_value = {
'driver_info': {
'ipmi_address': '1.2.3.4',
},
'links': [],
'name': 'node1',
'ports': [],
'properties': {
'cpus': 42,
},
'uuid': 'f3fbf7c6-b4e9-4dd2-8ca0-c74a50f8be45',
}
mock_cloud.list_nics_for_machine.return_value = [
{
'address': '00:11:22:33:44:55',
@ -94,18 +102,26 @@ class TestBifrostInventoryUnit(base.TestCase):
mock_cloud = mock_sdk.return_value
mock_cloud.list_machines.return_value = [
{
'driver_info': {
'ipmi_address': '1.2.3.4',
},
'driver_info': None,
'links': [],
'name': 'node1',
'ports': [],
'properties': {
'cpus': 42,
},
'properties': None,
'uuid': 'f3fbf7c6-b4e9-4dd2-8ca0-c74a50f8be45',
},
]
mock_cloud.get_machine.return_value = {
'driver_info': {
'ipmi_address': '1.2.3.4',
},
'links': [],
'name': 'node1',
'ports': [],
'properties': {
'cpus': 42,
},
'uuid': 'f3fbf7c6-b4e9-4dd2-8ca0-c74a50f8be45',
}
mock_cloud.list_nics_for_machine.return_value = [
{
'address': '00:11:22:33:44:55',

View File

@ -0,0 +1,7 @@
---
fixes:
- |
Fixes an issue with the Bifrost inventory plugin when used with
``BIFROST_INVENTORY_SOURCE=ironic``. All node fields are now returned as
facts, as in Ussuri and earlier releases. See `story 2008394
<https://storyboard.openstack.org/#!/story/2008394>`__ for details.