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,29 +1499,37 @@ class RedfishUtils(object):
def _software_inventory(self, uri): def _software_inventory(self, uri):
result = {} result = {}
response = self.get_request(self.root_uri + uri)
if response['ret'] is False:
return response
result['ret'] = True
data = response['data']
result['entries'] = [] result['entries'] = []
for member in data[u'Members']:
uri = self.root_uri + member[u'@odata.id'] while uri:
# Get details for each software or firmware member response = self.get_request(self.root_uri + uri)
response = self.get_request(uri)
if response['ret'] is False: if response['ret'] is False:
return response return response
result['ret'] = True result['ret'] = True
data = response['data'] data = response['data']
software = {} if data.get('Members@odata.nextLink'):
# Get these standard properties if present uri = data.get('Members@odata.nextLink')
for key in ['Name', 'Id', 'Status', 'Version', 'Updateable', else:
'SoftwareId', 'LowestSupportedVersion', 'Manufacturer', uri = None
'ReleaseDate']:
if key in data: for member in data[u'Members']:
software[key] = data.get(key) fw_uri = self.root_uri + member[u'@odata.id']
result['entries'].append(software) # Get details for each software or firmware member
response = self.get_request(fw_uri)
if response['ret'] is False:
return response
result['ret'] = True
data = response['data']
software = {}
# Get these standard properties if present
for key in ['Name', 'Id', 'Status', 'Version', 'Updateable',
'SoftwareId', 'LowestSupportedVersion', 'Manufacturer',
'ReleaseDate']:
if key in data:
software[key] = data.get(key)
result['entries'].append(software)
return result return result
def get_firmware_inventory(self): def get_firmware_inventory(self):