From 976d2acf5fbc38ab66f5271034b318ee642ec1eb Mon Sep 17 00:00:00 2001 From: Bill Dodd Date: Wed, 27 May 2020 14:24:10 -0500 Subject: [PATCH] Add RAIDType properties to storage resources Recent versions of the Redfish specification added a RAIDType property to the Volume resource and a SupportedRAIDTypes property to the Storage resource. This patch adds those properties to the sushy resource models. Change-Id: I1e77561fcb0d85bbee80457fbb053d866838c243 Story: 2003514 Task: 36274 --- ...raid-type-properties-2090da5bea37c660.yaml | 5 ++ sushy/resources/system/storage/constants.py | 76 +++++++++++++++++++ sushy/resources/system/storage/mappings.py | 19 +++++ sushy/resources/system/storage/storage.py | 5 ++ sushy/resources/system/storage/volume.py | 3 + sushy/tests/unit/json_samples/storage.json | 4 + sushy/tests/unit/json_samples/volume4.json | 1 + .../resources/system/storage/test_storage.py | 2 + .../resources/system/storage/test_volume.py | 2 + 9 files changed, 117 insertions(+) create mode 100644 releasenotes/notes/add-raid-type-properties-2090da5bea37c660.yaml diff --git a/releasenotes/notes/add-raid-type-properties-2090da5bea37c660.yaml b/releasenotes/notes/add-raid-type-properties-2090da5bea37c660.yaml new file mode 100644 index 00000000..7ebf2ee5 --- /dev/null +++ b/releasenotes/notes/add-raid-type-properties-2090da5bea37c660.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Add RAIDType property to the Volume resource and SupportedRAIDTypes + property to the Storage resource. diff --git a/sushy/resources/system/storage/constants.py b/sushy/resources/system/storage/constants.py index 92b9c9c4..e896a4a3 100644 --- a/sushy/resources/system/storage/constants.py +++ b/sushy/resources/system/storage/constants.py @@ -39,3 +39,79 @@ VOLUME_TYPE_SPANNED_MIRRORS = 'spannedmirrors' VOLUME_TYPE_SPANNED_STRIPES_WITH_PARITY = 'spannedstripeswithparity' """The volume is a spanned set of devices which uses parity to retain redundant information.""" + +# RAIDType Types +RAID_TYPE_RAID0 = 'RAID0' +"""A placement policy where consecutive logical blocks of data are uniformly +distributed across a set of independent storage devices without offering any +form of redundancy.""" + +RAID_TYPE_RAID1 = 'RAID1' +"""A placement policy where each logical block of data is stored on more than +one independent storage device.""" + +RAID_TYPE_RAID3 = 'RAID3' +"""A placement policy using parity-based protection where logical bytes of +data are uniformly distributed across a set of independent storage devices and +where the parity is stored on a dedicated independent storage device.""" + +RAID_TYPE_RAID4 = 'RAID4' +"""A placement policy using parity-based protection where logical blocks of +data are uniformly distributed across a set of independent storage devices and +where the parity is stored on a dedicated independent storage device.""" + +RAID_TYPE_RAID5 = 'RAID5' +"""A placement policy using parity-based protection for storing stripes of 'n' +logical blocks of data and one logical block of parity across a set of 'n+1' +independent storage devices where the parity and data blocks are interleaved +across the storage devices.""" + +RAID_TYPE_RAID6 = 'RAID6' +"""A placement policy using parity-based protection for storing stripes of 'n' +logical blocks of data and two logical blocks of independent parity across a +set of 'n+2' independent storage devices where the parity and data blocks are +interleaved across the storage devices.""" + +RAID_TYPE_RAID10 = 'RAID10' +"""A placement policy that creates a striped device (RAID 0) over a set of +mirrored devices (RAID 1).""" + +RAID_TYPE_RAID01 = 'RAID01' +"""A data placement policy that creates a mirrored device (RAID 1) over a set +of striped devices (RAID 0).""" + +RAID_TYPE_RAID6TP = 'RAID6TP' +"""A placement policy that uses parity-based protection for storing stripes of +'n' logical blocks of data and three logical blocks of independent parity +across a set of 'n+3' independent storage devices where the parity and data +blocks are interleaved across the storage devices.""" + +RAID_TYPE_RAID1E = 'RAID1E' +"""A placement policy that uses a form of mirroring implemented over a set of +independent storage devices where logical blocks are duplicated on a pair of +independent storage devices so that data is uniformly distributed across the +storage devices.""" + +RAID_TYPE_RAID50 = 'RAID50' +"""A placement policy that uses a RAID 0 stripe set over two or more RAID 5 +sets of independent storage devices.""" + +RAID_TYPE_RAID60 = 'RAID60' +"""A placement policy that uses a RAID 0 stripe set over two or more RAID 6 +sets of independent storage devices.""" + +RAID_TYPE_RAID00 = 'RAID00' +"""A placement policy that creates a RAID 0 stripe set over two or more RAID 0 +sets.""" + +RAID_TYPE_RAID10E = 'RAID10E' +"""A placement policy that uses a RAID 0 stripe set over two or more RAID 10 +sets.""" + +RAID_TYPE_RAID1Triple = 'RAID1Triple' +"""A placement policy where each logical block of data is mirrored three times +across a set of three independent storage devices.""" + +RAID_TYPE_RAID10Triple = 'RAID10Triple' +"""A placement policy that uses a striped device (RAID 0) over a set of triple +mirrored devices (RAID 1Triple).""" diff --git a/sushy/resources/system/storage/mappings.py b/sushy/resources/system/storage/mappings.py index 462f9a7f..8fec80d1 100644 --- a/sushy/resources/system/storage/mappings.py +++ b/sushy/resources/system/storage/mappings.py @@ -31,3 +31,22 @@ VOLUME_TYPE_TYPE_MAP = { 'SpannedStripesWithParity': store_cons.VOLUME_TYPE_SPANNED_STRIPES_WITH_PARITY } + +RAID_TYPE_TYPE_MAP = { + 'RAID0': store_cons.RAID_TYPE_RAID0, + 'RAID1': store_cons.RAID_TYPE_RAID1, + 'RAID3': store_cons.RAID_TYPE_RAID3, + 'RAID4': store_cons.RAID_TYPE_RAID4, + 'RAID5': store_cons.RAID_TYPE_RAID5, + 'RAID6': store_cons.RAID_TYPE_RAID6, + 'RAID10': store_cons.RAID_TYPE_RAID10, + 'RAID01': store_cons.RAID_TYPE_RAID01, + 'RAID6TP': store_cons.RAID_TYPE_RAID6TP, + 'RAID1E': store_cons.RAID_TYPE_RAID1E, + 'RAID50': store_cons.RAID_TYPE_RAID50, + 'RAID60': store_cons.RAID_TYPE_RAID60, + 'RAID00': store_cons.RAID_TYPE_RAID00, + 'RAID10E': store_cons.RAID_TYPE_RAID10E, + 'RAID1Triple': store_cons.RAID_TYPE_RAID1Triple, + 'RAID10Triple': store_cons.RAID_TYPE_RAID10Triple, +} diff --git a/sushy/resources/system/storage/storage.py b/sushy/resources/system/storage/storage.py index 4f42103a..f658437a 100644 --- a/sushy/resources/system/storage/storage.py +++ b/sushy/resources/system/storage/storage.py @@ -19,6 +19,7 @@ from sushy.resources import base from sushy.resources import common from sushy.resources import mappings as res_maps from sushy.resources.system.storage import drive +from sushy.resources.system.storage import mappings from sushy.resources.system.storage import volume from sushy import utils @@ -52,6 +53,10 @@ class StorageControllersListField(base.ListField): res_maps.PROTOCOL_TYPE_VALUE_MAP) """The protocols which the controller can use tocommunicate with devices""" + raid_types = base.MappedListField('SupportedRAIDTypes', + mappings.RAID_TYPE_TYPE_MAP) + """The set of RAID types supported by the storage controller.""" + class Storage(base.ResourceBase): """This class represents the storage subsystem resources. diff --git a/sushy/resources/system/storage/volume.py b/sushy/resources/system/storage/volume.py index 36b0693a..af2ec1eb 100644 --- a/sushy/resources/system/storage/volume.py +++ b/sushy/resources/system/storage/volume.py @@ -44,6 +44,9 @@ class Volume(base.ResourceBase): store_maps.VOLUME_TYPE_TYPE_MAP) """The type of this volume.""" + raid_type = base.MappedField('RAIDType', store_maps.RAID_TYPE_TYPE_MAP) + """The RAID type of this volume.""" + encrypted = base.Field('Encrypted', adapter=bool) """Is this Volume encrypted.""" diff --git a/sushy/tests/unit/json_samples/storage.json b/sushy/tests/unit/json_samples/storage.json index b9cbe915..d3a63228 100644 --- a/sushy/tests/unit/json_samples/storage.json +++ b/sushy/tests/unit/json_samples/storage.json @@ -39,6 +39,10 @@ "SupportedDeviceProtocols": [ "SAS", "SATA" + ], + "SupportedRAIDTypes": [ + "RAID0", + "RAID1" ] } ], diff --git a/sushy/tests/unit/json_samples/volume4.json b/sushy/tests/unit/json_samples/volume4.json index 0d76a623..e5c5be40 100644 --- a/sushy/tests/unit/json_samples/volume4.json +++ b/sushy/tests/unit/json_samples/volume4.json @@ -9,6 +9,7 @@ }, "Encrypted": false, "VolumeType": "Mirrored", + "RAIDType": "RAID1", "CapacityBytes": 107374182400, "Identifiers": [ { diff --git a/sushy/tests/unit/resources/system/storage/test_storage.py b/sushy/tests/unit/resources/system/storage/test_storage.py index 00eb28b5..365dc80c 100644 --- a/sushy/tests/unit/resources/system/storage/test_storage.py +++ b/sushy/tests/unit/resources/system/storage/test_storage.py @@ -128,6 +128,8 @@ class StorageTestCase(base.TestCase): controller.controller_protocols) self.assertEqual([sushy.PROTOCOL_TYPE_SAS, sushy.PROTOCOL_TYPE_SATA], controller.device_protocols) + self.assertEqual([sushy.RAID_TYPE_RAID0, sushy.RAID_TYPE_RAID1], + controller.raid_types) def test_drives_after_refresh(self): self.storage.refresh() diff --git a/sushy/tests/unit/resources/system/storage/test_volume.py b/sushy/tests/unit/resources/system/storage/test_volume.py index 1c0de832..da1d4cde 100644 --- a/sushy/tests/unit/resources/system/storage/test_volume.py +++ b/sushy/tests/unit/resources/system/storage/test_volume.py @@ -179,6 +179,7 @@ class VolumeCollectionTestCase(base.TestCase): payload = { 'Name': 'My Volume 4', 'VolumeType': 'Mirrored', + 'RAIDType': 'RAID1', 'CapacityBytes': 107374182400 } with open('sushy/tests/unit/json_samples/volume4.json') as f: @@ -197,3 +198,4 @@ class VolumeCollectionTestCase(base.TestCase): self.assertEqual('My Volume 4', new_vol.name) self.assertEqual(107374182400, new_vol.capacity_bytes) self.assertEqual(sushy.VOLUME_TYPE_MIRRORED, new_vol.volume_type) + self.assertEqual(sushy.RAID_TYPE_RAID1, new_vol.raid_type)