add GetSoftwareInventory command (#62811)

This commit is contained in:
Bill Dodd 2019-10-29 08:15:42 -05:00 committed by John R Barker
parent 31f3a29613
commit c9a669e42c
2 changed files with 44 additions and 11 deletions

View file

@ -230,8 +230,11 @@ class RedfishUtils(object):
if response['ret'] is False:
return response
data = response['data']
firmware_inventory = data['FirmwareInventory'][u'@odata.id']
self.firmware_uri = firmware_inventory
self.firmware_uri = self.software_uri = None
if 'FirmwareInventory' in data:
self.firmware_uri = data['FirmwareInventory'][u'@odata.id']
if 'SoftwareInventory' in data:
self.software_uri = data['SoftwareInventory'][u'@odata.id']
return {'ret': True}
def _find_chassis_resource(self):
@ -1133,33 +1136,45 @@ class RedfishUtils(object):
return {'ret': "False", 'msg': "Key Actions not found."}
return result
def get_firmware_inventory(self):
def _software_inventory(self, uri):
result = {}
response = self.get_request(self.root_uri + self.firmware_uri)
response = self.get_request(self.root_uri + uri)
if response['ret'] is False:
return response
result['ret'] = True
data = response['data']
result['entries'] = []
for device in data[u'Members']:
uri = self.root_uri + device[u'@odata.id']
# Get details for each device
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)
if response['ret'] is False:
return response
result['ret'] = True
data = response['data']
firmware = {}
software = {}
# Get these standard properties if present
for key in ['Name', 'Id', 'Status', 'Version', 'Updateable',
'SoftwareId', 'LowestSupportedVersion', 'Manufacturer',
'ReleaseDate']:
if key in data:
firmware[key] = data.get(key)
result['entries'].append(firmware)
software[key] = data.get(key)
result['entries'].append(software)
return result
def get_firmware_inventory(self):
if self.firmware_uri is None:
return {'ret': False, 'msg': 'No FirmwareInventory resource found'}
else:
return self._software_inventory(self.firmware_uri)
def get_software_inventory(self):
if self.software_uri is None:
return {'ret': False, 'msg': 'No SoftwareInventory resource found'}
else:
return self._software_inventory(self.software_uri)
def get_bios_attributes(self, systems_uri):
result = {}
bios_attributes = {}

View file

@ -206,6 +206,22 @@ EXAMPLES = '''
username: "{{ username }}"
password: "{{ password }}"
- name: Get firmware inventory
redfish_info:
category: Update
command: GetFirmwareInventory
baseuri: "{{ baseuri }}"
username: "{{ username }}"
password: "{{ password }}"
- name: Get software inventory
redfish_info:
category: Update
command: GetSoftwareInventory
baseuri: "{{ baseuri }}"
username: "{{ username }}"
password: "{{ password }}"
- name: Get all information available in all categories
redfish_info:
category: all
@ -234,7 +250,7 @@ CATEGORY_COMMANDS_ALL = {
"Chassis": ["GetFanInventory", "GetPsuInventory", "GetChassisPower", "GetChassisThermals", "GetChassisInventory"],
"Accounts": ["ListUsers"],
"Sessions": ["GetSessions"],
"Update": ["GetFirmwareInventory", "GetFirmwareUpdateCapabilities"],
"Update": ["GetFirmwareInventory", "GetFirmwareUpdateCapabilities", "GetSoftwareInventory"],
"Manager": ["GetManagerNicInventory", "GetVirtualMedia", "GetLogs"],
}
@ -374,6 +390,8 @@ def main():
for command in command_list:
if command == "GetFirmwareInventory":
result["firmware"] = rf_utils.get_firmware_inventory()
elif command == "GetSoftwareInventory":
result["software"] = rf_utils.get_software_inventory()
elif command == "GetFirmwareUpdateCapabilities":
result["firmware_update_capabilities"] = rf_utils.get_firmware_update_capabilities()