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>pull/6804/head
parent
7b404fd45d
commit
22efbcc627
|
@ -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).
|
|
@ -897,13 +897,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:
|
||||||
|
@ -912,7 +912,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']
|
||||||
|
|
Loading…
Reference in New Issue