SSC.disks_sizes_bytes handle CapacityBytes is None

In the open ocean, a Redfish service can return a SimpleStorage resource
containing a Device property with its CapacityBytes property set to
null. According to the Distributed Management Task Force (DMTF) schema
for SimpleStorage, the type of CapacityBytes can be either integer or
null [1].

The Dell integrated Dell Remote Access Controller (iDRAC) 9 running
Lifecycle Controller firmware version 3.30.30.30 returns that for a Dell
EMC PowerEdge R740xd containing a Dell HBA 330 12Gbps SAS Host Bus
Adapter Controller (non-RAID), MiniCard (HBA 330 Mini) [2]. The HBA 330
Mini firmware version is 16.17.00.03.

The same was observed against an R740xd running Lifecycle Controller
firmware version 3.34.34.34.

This changes the SimpleStorageCollection.disks_size_bytes property to
process only Disks with CapacityByes not set to None.

[1] https://redfish.dmtf.org/schemas/SimpleStorage.v1_2_3.json
[2] http://eavesdrop.openstack.org/irclogs/%23openstack-ironic/%23openstack-ironic.2019-12-11.log.html#t2019-12-11T07:24:17

Change-Id: I57a0074a7f6c4495e7c73a00c87675ea87fdb6e8
Story: 2006918
Task: 37567
(cherry picked from commit 9d01756833)
This commit is contained in:
Richard Pioso 2019-12-19 18:52:16 -05:00
parent 6ae277339f
commit 2f961fc3e5
3 changed files with 26 additions and 1 deletions

View File

@ -0,0 +1,11 @@
---
fixes:
- |
Fixes bug in ``SimpleStorageCollection.disks_sizes_bytes`` which assumed
the type of a disk's ``CapacityBytes`` property is ``integer``. According
to the Distributed Management Task Force (DMTF) Redfish standard schema
[1], it can be ``null``, which is converted to ``None`` in Python. For
more information, see `story 2006918
<https://storyboard.openstack.org/#!/story/2006918>`_.
[1] https://redfish.dmtf.org/schemas/SimpleStorage.v1_2_3.json

View File

@ -73,7 +73,8 @@ class SimpleStorageCollection(base.ResourceCollectionBase):
return sorted(device.capacity_bytes return sorted(device.capacity_bytes
for simpl_stor in self.get_members() for simpl_stor in self.get_members()
for device in simpl_stor.devices for device in simpl_stor.devices
if device.status.state == res_cons.STATE_ENABLED) if (device.status.state == res_cons.STATE_ENABLED
and device.capacity_bytes is not None))
@property @property
def max_size_bytes(self): def max_size_bytes(self):

View File

@ -102,6 +102,19 @@ class SimpleStorageCollectionTestCase(base.TestCase):
self.assertEqual([4000000000000, 8000000000000], self.assertEqual([4000000000000, 8000000000000],
self.simpl_stor_col.disks_sizes_bytes) self.simpl_stor_col.disks_sizes_bytes)
def test_disks_sizes_bytes_capacity_bytes_none(self):
self.conn.get.return_value.json.reset_mock()
with open('sushy/tests/unit/json_samples/'
'simple_storage.json') as f:
json_doc = json.load(f)
json_doc['Devices'][0]['CapacityBytes'] = None
self.conn.get.return_value.json.return_value = json_doc
self.assertEqual([4000000000000],
self.simpl_stor_col.disks_sizes_bytes)
def test_max_size_bytes(self): def test_max_size_bytes(self):
self.conn.get.return_value.json.reset_mock() self.conn.get.return_value.json.reset_mock()