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:
parent
5d7899b341
commit
b46d5d8197
2 changed files with 28 additions and 18 deletions
2
changelogs/fragments/7020-redfish-utils-pagination.yml
Normal file
2
changelogs/fragments/7020-redfish-utils-pagination.yml
Normal 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).
|
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue