diff --git a/changelogs/fragments/6719-redfish-utils-fix-for-get-volume-inventory.yml b/changelogs/fragments/6719-redfish-utils-fix-for-get-volume-inventory.yml new file mode 100644 index 0000000000..2bca19faf1 --- /dev/null +++ b/changelogs/fragments/6719-redfish-utils-fix-for-get-volume-inventory.yml @@ -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). diff --git a/plugins/module_utils/redfish_utils.py b/plugins/module_utils/redfish_utils.py index 027ce56308..ffcb739bd6 100644 --- a/plugins/module_utils/redfish_utils.py +++ b/plugins/module_utils/redfish_utils.py @@ -897,13 +897,13 @@ class RedfishUtils(object): if data.get('Members'): for controller in data[u'Members']: controller_list.append(controller[u'@odata.id']) - for c in controller_list: + for idx, c in enumerate(controller_list): uri = self.root_uri + c response = self.get_request(uri) if response['ret'] is False: return response data = response['data'] - controller_name = 'Controller 1' + controller_name = 'Controller %s' % str(idx) if 'StorageControllers' in data: sc = data['StorageControllers'] if sc: @@ -912,7 +912,26 @@ class RedfishUtils(object): else: sc_id = sc[0].get('Id', '1') 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_list = [] if 'Volumes' in data: # Get a list of all volumes and build respective URIs volumes_uri = data[u'Volumes'][u'@odata.id']