From 2f961fc3e5e34ceab8713eec4c2ceaec84da0391 Mon Sep 17 00:00:00 2001 From: Richard Pioso Date: Thu, 19 Dec 2019 18:52:16 -0500 Subject: [PATCH] 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 9d01756833ec97a05f301a4fa1e8b2511d7c5c74) --- ...device-capacity-bytes-null-0672eed36d9da70a.yaml | 11 +++++++++++ sushy/resources/system/simple_storage.py | 3 ++- .../unit/resources/system/test_simple_storage.py | 13 +++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/fix-simple-storage-device-capacity-bytes-null-0672eed36d9da70a.yaml diff --git a/releasenotes/notes/fix-simple-storage-device-capacity-bytes-null-0672eed36d9da70a.yaml b/releasenotes/notes/fix-simple-storage-device-capacity-bytes-null-0672eed36d9da70a.yaml new file mode 100644 index 00000000..59176091 --- /dev/null +++ b/releasenotes/notes/fix-simple-storage-device-capacity-bytes-null-0672eed36d9da70a.yaml @@ -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 + `_. + + [1] https://redfish.dmtf.org/schemas/SimpleStorage.v1_2_3.json \ No newline at end of file diff --git a/sushy/resources/system/simple_storage.py b/sushy/resources/system/simple_storage.py index 3045fd99..2abbc28d 100644 --- a/sushy/resources/system/simple_storage.py +++ b/sushy/resources/system/simple_storage.py @@ -73,7 +73,8 @@ class SimpleStorageCollection(base.ResourceCollectionBase): return sorted(device.capacity_bytes for simpl_stor in self.get_members() 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 def max_size_bytes(self): diff --git a/sushy/tests/unit/resources/system/test_simple_storage.py b/sushy/tests/unit/resources/system/test_simple_storage.py index 171df812..a4a25f98 100644 --- a/sushy/tests/unit/resources/system/test_simple_storage.py +++ b/sushy/tests/unit/resources/system/test_simple_storage.py @@ -102,6 +102,19 @@ class SimpleStorageCollectionTestCase(base.TestCase): self.assertEqual([4000000000000, 8000000000000], 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): self.conn.get.return_value.json.reset_mock()