Fix Redfish request collecting storage drives

Fix the Redfish request payload collecting physical storage drives

Change-Id: I3b735709aa2f65b606a0747a2edf98f50af39f87
This commit is contained in:
Mahnoor Asghar 2023-11-27 18:36:51 +01:00
parent 281cebedd6
commit facd862a31
3 changed files with 68 additions and 97 deletions

View File

@ -623,10 +623,8 @@ def _construct_volume_payload(
'RAIDType': RAID_LEVELS[raid_level]['raid_type'],
'CapacityBytes': size_bytes}
if physical_disks:
payload['Links'] = {
"Drives": [{"@odata.id": _drive_path(storage, d)} for d in
payload['Drives'] = [{"@odata.id": _drive_path(storage, d)} for d in
physical_disks]
}
LOG.debug('Payload for RAID logical disk creation on node %(node_uuid)s: '
'%(payload)r', {'node': node.uuid, 'payload': payload})
return payload

View File

@ -255,14 +255,12 @@ class RedfishRAIDTestCase(db_base.DbTestCase):
'VolumeType': 'StripedWithParity',
'RAIDType': 'RAID5',
'CapacityBytes': 107374182400,
'Links': {
'Drives': [
{'@odata.id': pre + self.drive_id1},
{'@odata.id': pre + self.drive_id2},
{'@odata.id': pre + self.drive_id3}
]
}
}
self.mock_storage.volumes.create.assert_called_once_with(
expected_payload, apply_time=None
)
@ -320,14 +318,12 @@ class RedfishRAIDTestCase(db_base.DbTestCase):
'VolumeType': 'StripedWithParity',
'RAIDType': 'RAID5',
'CapacityBytes': 107374182400,
'Links': {
'Drives': [
{'@odata.id': pre + self.drive_id1},
{'@odata.id': pre + self.drive_id2},
{'@odata.id': pre + self.drive_id3}
]
}
}
self.mock_storage.volumes.create.assert_called_once_with(
expected_payload, apply_time=sushy.APPLY_TIME_IMMEDIATE)
mock_set_async_step_flags.assert_called_once_with(
@ -392,14 +388,12 @@ class RedfishRAIDTestCase(db_base.DbTestCase):
'VolumeType': 'StripedWithParity',
'RAIDType': 'RAID5',
'CapacityBytes': 107374182400,
'Links': {
'Drives': [
{'@odata.id': pre + self.drive_id1},
{'@odata.id': pre + self.drive_id2},
{'@odata.id': pre + self.drive_id3}
]
}
}
self.mock_storage.volumes.create.assert_called_once_with(
expected_payload, apply_time=sushy.APPLY_TIME_ON_RESET)
mock_set_async_step_flags.assert_called_once_with(
@ -467,26 +461,22 @@ class RedfishRAIDTestCase(db_base.DbTestCase):
'VolumeType': 'StripedWithParity',
'RAIDType': 'RAID5',
'CapacityBytes': 107374182400,
'Links': {
'Drives': [
{'@odata.id': pre + self.drive_id5},
{'@odata.id': pre + self.drive_id6},
{'@odata.id': pre + self.drive_id7}
]
}
}
expected_payload2 = {
'Encrypted': False,
'VolumeType': 'Mirrored',
'RAIDType': 'RAID1',
'CapacityBytes': 536870912000,
'Links': {
'Drives': [
{'@odata.id': pre + self.drive_id1},
{'@odata.id': pre + self.drive_id2}
]
}
}
self.assertEqual(
self.mock_storage.volumes.create.call_count, 2)
self.mock_storage.volumes.create.assert_any_call(
@ -561,13 +551,11 @@ class RedfishRAIDTestCase(db_base.DbTestCase):
'VolumeType': 'Mirrored',
'RAIDType': 'RAID1',
'CapacityBytes': 536870912000,
'Links': {
'Drives': [
{'@odata.id': pre + self.drive_id1},
{'@odata.id': pre + self.drive_id2}
]
}
}
expected_raid_configs = {
'operation': 'create',
'pending': {'RAID controller 1': [
@ -636,14 +624,12 @@ class RedfishRAIDTestCase(db_base.DbTestCase):
'VolumeType': 'StripedWithParity',
'RAIDType': 'RAID5',
'CapacityBytes': 107374182400,
'Links': {
'Drives': [
{'@odata.id': pre + self.drive_id1},
{'@odata.id': pre + self.drive_id2},
{'@odata.id': pre + self.drive_id3}
]
}
}
self.mock_storage.volumes.create.assert_called_once_with(
expected_payload, apply_time=None
)
@ -729,7 +715,6 @@ class RedfishRAIDTestCase(db_base.DbTestCase):
'VolumeType': 'SpannedMirrors',
'RAIDType': 'RAID10',
'CapacityBytes': 53687091200,
'Links': {
'Drives': [
{'@odata.id': pre + self.drive_id1},
{'@odata.id': pre + self.drive_id2},
@ -737,20 +722,17 @@ class RedfishRAIDTestCase(db_base.DbTestCase):
{'@odata.id': pre + self.drive_id4}
]
}
}
expected_payload2 = {
'Encrypted': False,
'VolumeType': 'StripedWithParity',
'RAIDType': 'RAID5',
'CapacityBytes': 107374182400,
'Links': {
'Drives': [
{'@odata.id': pre + self.drive_id2},
{'@odata.id': pre + self.drive_id3},
{'@odata.id': pre + self.drive_id4}
]
}
}
self.assertEqual(
self.mock_storage.volumes.create.call_count, 2)
self.mock_storage.volumes.create.assert_any_call(
@ -857,24 +839,20 @@ class RedfishRAIDTestCase(db_base.DbTestCase):
'VolumeType': 'Mirrored',
'RAIDType': 'RAID1',
'CapacityBytes': 107374182400,
'Links': {
'Drives': [
{'@odata.id': pre + self.drive_id1},
{'@odata.id': pre + self.drive_id2}
]
}
}
expected_payload2 = {
'Encrypted': False,
'VolumeType': 'NonRedundant',
'RAIDType': 'RAID0',
'CapacityBytes': 536870912000,
'Links': {
'Drives': [
{'@odata.id': pre + self.drive_id3}
]
}
}
self.assertEqual(
self.mock_storage.volumes.create.call_count, 2)
self.mock_storage.volumes.create.assert_any_call(
@ -980,26 +958,22 @@ class RedfishRAIDTestCase(db_base.DbTestCase):
'VolumeType': 'StripedWithParity',
'RAIDType': 'RAID5',
'CapacityBytes': 107374182400,
'Links': {
'Drives': [
{'@odata.id': pre + self.drive_id5},
{'@odata.id': pre + self.drive_id6},
{'@odata.id': pre + self.drive_id7}
]
}
}
expected_payload2 = {
'Encrypted': False,
'VolumeType': 'Mirrored',
'RAIDType': 'RAID1',
'CapacityBytes': 536870912000,
'Links': {
'Drives': [
{'@odata.id': pre + self.drive_id1},
{'@odata.id': pre + self.drive_id2}
]
}
}
self.assertEqual(
self.mock_storage.volumes.create.call_count, 2)
self.mock_storage.volumes.create.assert_any_call(
@ -1152,13 +1126,7 @@ class RedfishRAIDTestCase(db_base.DbTestCase):
'VolumeType': 'Mirrored',
'RAIDType': 'RAID1',
'CapacityBytes': capacity_bytes,
'Links': {
'Drives': [
{
'@odata.id': pre + drive_id
}
]
}
'Drives': [{'@odata.id': pre + drive_id}]
}
with task_manager.acquire(self.context, self.node.uuid,
shared=True) as task:

View File

@ -0,0 +1,5 @@
---
fixes:
- Fixes the payload format required to query physical storage drives
using redfish, when configuring RAID using redfish.