add GetSoftwareInventory command (#62811)
This commit is contained in:
parent
31f3a29613
commit
c9a669e42c
2 changed files with 44 additions and 11 deletions
|
@ -230,8 +230,11 @@ class RedfishUtils(object):
|
||||||
if response['ret'] is False:
|
if response['ret'] is False:
|
||||||
return response
|
return response
|
||||||
data = response['data']
|
data = response['data']
|
||||||
firmware_inventory = data['FirmwareInventory'][u'@odata.id']
|
self.firmware_uri = self.software_uri = None
|
||||||
self.firmware_uri = firmware_inventory
|
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}
|
return {'ret': True}
|
||||||
|
|
||||||
def _find_chassis_resource(self):
|
def _find_chassis_resource(self):
|
||||||
|
@ -1133,33 +1136,45 @@ class RedfishUtils(object):
|
||||||
return {'ret': "False", 'msg': "Key Actions not found."}
|
return {'ret': "False", 'msg': "Key Actions not found."}
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def get_firmware_inventory(self):
|
def _software_inventory(self, uri):
|
||||||
result = {}
|
result = {}
|
||||||
response = self.get_request(self.root_uri + self.firmware_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']
|
data = response['data']
|
||||||
|
|
||||||
result['entries'] = []
|
result['entries'] = []
|
||||||
for device in data[u'Members']:
|
for member in data[u'Members']:
|
||||||
uri = self.root_uri + device[u'@odata.id']
|
uri = self.root_uri + member[u'@odata.id']
|
||||||
# Get details for each device
|
# Get details for each software or firmware member
|
||||||
response = self.get_request(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']
|
||||||
firmware = {}
|
software = {}
|
||||||
# Get these standard properties if present
|
# Get these standard properties if present
|
||||||
for key in ['Name', 'Id', 'Status', 'Version', 'Updateable',
|
for key in ['Name', 'Id', 'Status', 'Version', 'Updateable',
|
||||||
'SoftwareId', 'LowestSupportedVersion', 'Manufacturer',
|
'SoftwareId', 'LowestSupportedVersion', 'Manufacturer',
|
||||||
'ReleaseDate']:
|
'ReleaseDate']:
|
||||||
if key in data:
|
if key in data:
|
||||||
firmware[key] = data.get(key)
|
software[key] = data.get(key)
|
||||||
result['entries'].append(firmware)
|
result['entries'].append(software)
|
||||||
return result
|
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):
|
def get_bios_attributes(self, systems_uri):
|
||||||
result = {}
|
result = {}
|
||||||
bios_attributes = {}
|
bios_attributes = {}
|
||||||
|
|
|
@ -206,6 +206,22 @@ EXAMPLES = '''
|
||||||
username: "{{ username }}"
|
username: "{{ username }}"
|
||||||
password: "{{ password }}"
|
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
|
- name: Get all information available in all categories
|
||||||
redfish_info:
|
redfish_info:
|
||||||
category: all
|
category: all
|
||||||
|
@ -234,7 +250,7 @@ CATEGORY_COMMANDS_ALL = {
|
||||||
"Chassis": ["GetFanInventory", "GetPsuInventory", "GetChassisPower", "GetChassisThermals", "GetChassisInventory"],
|
"Chassis": ["GetFanInventory", "GetPsuInventory", "GetChassisPower", "GetChassisThermals", "GetChassisInventory"],
|
||||||
"Accounts": ["ListUsers"],
|
"Accounts": ["ListUsers"],
|
||||||
"Sessions": ["GetSessions"],
|
"Sessions": ["GetSessions"],
|
||||||
"Update": ["GetFirmwareInventory", "GetFirmwareUpdateCapabilities"],
|
"Update": ["GetFirmwareInventory", "GetFirmwareUpdateCapabilities", "GetSoftwareInventory"],
|
||||||
"Manager": ["GetManagerNicInventory", "GetVirtualMedia", "GetLogs"],
|
"Manager": ["GetManagerNicInventory", "GetVirtualMedia", "GetLogs"],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,6 +390,8 @@ def main():
|
||||||
for command in command_list:
|
for command in command_list:
|
||||||
if command == "GetFirmwareInventory":
|
if command == "GetFirmwareInventory":
|
||||||
result["firmware"] = rf_utils.get_firmware_inventory()
|
result["firmware"] = rf_utils.get_firmware_inventory()
|
||||||
|
elif command == "GetSoftwareInventory":
|
||||||
|
result["software"] = rf_utils.get_software_inventory()
|
||||||
elif command == "GetFirmwareUpdateCapabilities":
|
elif command == "GetFirmwareUpdateCapabilities":
|
||||||
result["firmware_update_capabilities"] = rf_utils.get_firmware_update_capabilities()
|
result["firmware_update_capabilities"] = rf_utils.get_firmware_update_capabilities()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue