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

[PR #7020/b46d5d81 backport][stable-7] redfish_utils: Add support for "nextLink" property tag pagination (#7026)

redfish_utils: Add support for "nextLink" property tag pagination (#7020)

* Add support for Redfish "nextLink" property tag pagination for
FirmwareInventory

* Add changelog fragment

* Fix indention

* Updated fragment per suggestion

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

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit b46d5d8197)

Co-authored-by: Scott Seekamp <sseekamp@coreweave.com>
This commit is contained in:
patchback[bot] 2023-07-28 21:30:40 +02:00 committed by GitHub
parent 200b858b36
commit 1dad95370e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 18 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- redfish_utils module utils - add support for following ``@odata.nextLink`` pagination in ``software_inventory`` responses feature (https://github.com/ansible-collections/community.general/pull/7020).

View file

@ -1499,17 +1499,24 @@ class RedfishUtils(object):
def _software_inventory(self, uri): def _software_inventory(self, uri):
result = {} result = {}
result['entries'] = []
while uri:
response = self.get_request(self.root_uri + uri) response = self.get_request(self.root_uri + uri)
if response['ret'] is False: if response['ret'] is False:
return response return response
result['ret'] = True result['ret'] = True
data = response['data']
result['entries'] = [] data = response['data']
if data.get('Members@odata.nextLink'):
uri = data.get('Members@odata.nextLink')
else:
uri = None
for member in data[u'Members']: for member in data[u'Members']:
uri = self.root_uri + member[u'@odata.id'] fw_uri = self.root_uri + member[u'@odata.id']
# Get details for each software or firmware member # Get details for each software or firmware member
response = self.get_request(uri) response = self.get_request(fw_uri)
if response['ret'] is False: if response['ret'] is False:
return response return response
result['ret'] = True result['ret'] = True
@ -1522,6 +1529,7 @@ class RedfishUtils(object):
if key in data: if key in data:
software[key] = data.get(key) software[key] = data.get(key)
result['entries'].append(software) result['entries'].append(software)
return result return result
def get_firmware_inventory(self): def get_firmware_inventory(self):