diff --git a/doc/source/admin/drivers/redfish.rst b/doc/source/admin/drivers/redfish.rst index af5c185c38..e1d72bc2e5 100644 --- a/doc/source/admin/drivers/redfish.rst +++ b/doc/source/admin/drivers/redfish.rst @@ -128,6 +128,12 @@ into the introspection ramdisk. Redfish specification. Not all Redfish-compliant BMCs might serve the required information, in which case bare metal node inspection will fail. +.. note:: + + The ``local_gb`` property cannot always be discovered, for example, when a + node does not have local storage or the Redfish implementation does not + support the required schema. In this case the property will be set to 0. + .. _Redfish: http://redfish.dmtf.org/ .. _Sushy: https://git.openstack.org/cgit/openstack/sushy .. _TLS: https://en.wikipedia.org/wiki/Transport_Layer_Security diff --git a/ironic/drivers/modules/redfish/inspect.py b/ironic/drivers/modules/redfish/inspect.py index 9d6e6658ec..a9f625a5ad 100644 --- a/ironic/drivers/modules/redfish/inspect.py +++ b/ironic/drivers/modules/redfish/inspect.py @@ -115,6 +115,8 @@ class RedfishInspect(base.InspectInterface): simple_storage_size = 0 try: + LOG.debug("Attempting to discover system simple storage size for " + "node %(node)s", {'node': task.node.uuid}) if (system.simple_storage and system.simple_storage.disks_sizes_bytes): simple_storage_size = [ @@ -132,6 +134,8 @@ class RedfishInspect(base.InspectInterface): storage_size = 0 try: + LOG.debug("Attempting to discover system storage volume size for " + "node %(node)s", {'node': task.node.uuid}) if system.storage and system.storage.volumes_sizes_bytes: storage_size = [ size for size in system.storage.volumes_sizes_bytes @@ -145,6 +149,23 @@ class RedfishInspect(base.InspectInterface): "for node %(node)s: %(err)s", {'node': task.node.uuid, 'err': ex}) + try: + if not storage_size: + LOG.debug("Attempting to discover system storage drive size " + "for node %(node)s", {'node': task.node.uuid}) + if system.storage and system.storage.drives_sizes_bytes: + storage_size = [ + size for size in system.storage.drives_sizes_bytes + if size >= 4 * units.Gi + ] or [0] + + storage_size = storage_size[0] + + except sushy.exceptions.SushyError as ex: + LOG.debug("No storage drive information discovered " + "for node %(node)s: %(err)s", {'node': task.node.uuid, + 'err': ex}) + # NOTE(etingof): pick the smallest disk larger than 4G among available if simple_storage_size and storage_size: local_gb = min(simple_storage_size, storage_size) @@ -161,10 +182,11 @@ class RedfishInspect(base.InspectInterface): if local_gb: inspected_properties['local_gb'] = str(local_gb) - else: LOG.warning("Could not provide a valid storage size configured " - "for node %(node)s", {'node': task.node.uuid}) + "for node %(node)s. Assuming this is a disk-less node", + {'node': task.node.uuid}) + inspected_properties['local_gb'] = '0' valid_keys = self.ESSENTIAL_PROPERTIES missing_keys = valid_keys - set(inspected_properties) diff --git a/ironic/tests/unit/drivers/modules/redfish/test_inspect.py b/ironic/tests/unit/drivers/modules/redfish/test_inspect.py index 283cb13b39..af90ba3f1e 100644 --- a/ironic/tests/unit/drivers/modules/redfish/test_inspect.py +++ b/ironic/tests/unit/drivers/modules/redfish/test_inspect.py @@ -123,18 +123,6 @@ class RedfishInspectTestCase(db_base.DbTestCase): task.driver.inspect.inspect_hardware(task) self.assertEqual(expected_properties, task.node.properties) - @mock.patch.object(redfish_utils, 'get_system', autospec=True) - def test_inspect_hardware_fail_missing_local_gb(self, mock_get_system): - system_mock = self.init_system_mock(mock_get_system.return_value) - system_mock.simple_storage.disks_sizes_bytes = None - system_mock.storage.volumes_sizes_bytes = None - - with task_manager.acquire(self.context, self.node.uuid, - shared=True) as task: - task.node.properties.pop('local_gb') - self.assertRaises(exception.HardwareInspectionFailure, - task.driver.inspect.inspect_hardware, task) - @mock.patch.object(redfish_utils, 'get_system', autospec=True) def test_inspect_hardware_ignore_missing_local_gb(self, mock_get_system): system_mock = self.init_system_mock(mock_get_system.return_value) @@ -145,7 +133,7 @@ class RedfishInspectTestCase(db_base.DbTestCase): shared=True) as task: expected_properties = { 'cpu_arch': 'mips', 'cpus': '8', - 'local_gb': '10', 'memory_mb': '2048' + 'local_gb': '0', 'memory_mb': '2048' } task.driver.inspect.inspect_hardware(task) self.assertEqual(expected_properties, task.node.properties)