Allow missing `local_gb` property

Failure to detect ``local_gb`` fails the Redfish inspection.
But ideally it shouldn't fail, for instance the node can be a
disk-less node.

Allow Redfish inspect operation now to ignore missing ``local_gb``
property and set it to 0 in such cases.

Change-Id: I96fa83b81372333e626cca0e64fefcd0aeabe031
Story: 2004622
Task: 28542
This commit is contained in:
Debayan Ray 2019-01-03 03:56:54 +00:00
parent 831b6ff16f
commit b8e720e51f
3 changed files with 31 additions and 15 deletions

View File

@ -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

View File

@ -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)

View File

@ -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)