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

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>
This commit is contained in:
Scott Seekamp 2023-07-28 13:01:10 -06:00 committed by GitHub
parent 5d7899b341
commit b46d5d8197
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):
result = {}
response = self.get_request(self.root_uri + uri)
if response['ret'] is False:
return response
result['ret'] = True
data = response['data']
result['entries'] = []
for member in data[u'Members']:
uri = self.root_uri + member[u'@odata.id']
# Get details for each software or firmware member
response = self.get_request(uri)
while uri:
response = self.get_request(self.root_uri + 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)
if data.get('Members@odata.nextLink'):
uri = data.get('Members@odata.nextLink')
else:
uri = None
for member in data[u'Members']:
fw_uri = self.root_uri + member[u'@odata.id']
# 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
def get_firmware_inventory(self):