1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

[PR #6719/22efbcc6 backport][stable-6] Fixing bug in get_volume_inventory (#6791)

Fixing bug in get_volume_inventory (#6719)

* Fixing bug in get_volume_inventory

* Adding changelog fragment

* sanity fix

* Update changelogs/fragments/6719-redfish-utils-fix-for-get-volume-inventory.yml

Agreed

Co-authored-by: Felix Fontein <felix@fontein.de>

* Updating changelog fragment

* Update changelogs/fragments/6719-redfish-utils-fix-for-get-volume-inventory.yml

Agreed

Co-authored-by: Felix Fontein <felix@fontein.de>

* Updating changes as per PR comments

* PR comment changes

---------

Co-authored-by: Kushal <t-s.kushal@hpe.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 22efbcc627)

Co-authored-by: TSKushal <44438079+TSKushal@users.noreply.github.com>
This commit is contained in:
patchback[bot] 2023-06-27 07:08:11 +02:00 committed by GitHub
parent d7efa7eb13
commit d03abae7a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 2 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- redfish_info - fix for ``GetVolumeInventory``, Controller name was getting populated incorrectly and duplicates were seen in the volumes retrieved (https://github.com/ansible-collections/community.general/pull/6719).

View file

@ -832,13 +832,13 @@ class RedfishUtils(object):
if data.get('Members'): if data.get('Members'):
for controller in data[u'Members']: for controller in data[u'Members']:
controller_list.append(controller[u'@odata.id']) controller_list.append(controller[u'@odata.id'])
for c in controller_list: for idx, c in enumerate(controller_list):
uri = self.root_uri + c uri = self.root_uri + c
response = self.get_request(uri) response = self.get_request(uri)
if response['ret'] is False: if response['ret'] is False:
return response return response
data = response['data'] data = response['data']
controller_name = 'Controller 1' controller_name = 'Controller %s' % str(idx)
if 'StorageControllers' in data: if 'StorageControllers' in data:
sc = data['StorageControllers'] sc = data['StorageControllers']
if sc: if sc:
@ -847,7 +847,26 @@ class RedfishUtils(object):
else: else:
sc_id = sc[0].get('Id', '1') sc_id = sc[0].get('Id', '1')
controller_name = 'Controller %s' % sc_id controller_name = 'Controller %s' % sc_id
elif 'Controllers' in data:
response = self.get_request(self.root_uri + data['Controllers'][u'@odata.id'])
if response['ret'] is False:
return response
data = response['data']
if data.get('Members') and data['Members']:
response = self.get_request(self.root_uri + data['Members'][0][u'@odata.id'])
if response['ret'] is False:
return response
data = response['data']
if data:
if 'Name' in data:
controller_name = data['Name']
else:
controller_id = data.get('Id', '1')
controller_name = 'Controller %s' % controller_id
volume_results = [] volume_results = []
volume_list = []
if 'Volumes' in data: if 'Volumes' in data:
# Get a list of all volumes and build respective URIs # Get a list of all volumes and build respective URIs
volumes_uri = data[u'Volumes'][u'@odata.id'] volumes_uri = data[u'Volumes'][u'@odata.id']