Merge "Inspection throws exception on CPU-less systems"

This commit is contained in:
Zuul 2025-05-19 17:38:00 +00:00 committed by Gerrit Code Review
commit bc6cd744f5
2 changed files with 17 additions and 1 deletions

View file

@ -297,7 +297,10 @@ class RedfishInspect(base.InspectInterface):
def _get_processor_info(self, task, system, inspected_properties,
inventory):
if system.processors is None:
# NOTE(JayF): Checking truthiness here is better than checking for None
# because if we have an empty list, we'll raise a
# ValueError.
if not system.processors:
return
cpu = {}

View file

@ -394,6 +394,19 @@ class RedfishInspectTestCase(db_base.DbTestCase):
self.context)
self.assertNotIn('interfaces', inventory['inventory'])
@mock.patch.object(redfish_utils, 'get_system', autospec=True)
def test_inspect_hardware_ignore_missing_cpus(
self, mock_get_system):
system_mock = self.init_system_mock(mock_get_system.return_value)
system_mock.processors = []
with task_manager.acquire(self.context, self.node.uuid,
shared=True) as task:
task.driver.inspect.inspect_hardware(task)
inventory = inspect_utils.get_inspection_data(task.node,
self.context)
self.assertNotIn('cpu', inventory['inventory'])
@mock.patch.object(redfish_utils, 'get_system', autospec=True)
def test_inspect_hardware_preserve_boot_mode(self, mock_get_system):
self.init_system_mock(mock_get_system.return_value)