Add GetSupportedFirmwareUpdateMethods to redfish_facts/Update commands (#54268)
* Add GetSupportedFirmwareUpdateMethods to update category commands list * Add condition when command == GetSupportedFirmwareUpdateMethods to call the forthcoming rf_utils function get_supported_firmware_update_methods * Implement get_supporte_firmware_update_methods() in redfish_utils * rename command to GetFirmwareUpdateCapabilities * rename comand get_firmware_update_capabilities() * Rename command get_firmware_update_capabilities() * Group update protocols by the type of Action they are associated with. * remove trailing whitespace * Use safer method to get 'title' for each action type and its allowablevalues * Add example to docstring for using GetFirmwareUpdateCapabilities * fix line too long * fix line too long and trailing whitespace * Update redfish_utils.py * remove trailing whitespace * fix overindent * Use self.update_uri instead of hard-coding '/redfish/v1' in get_firmware_update_capabilities()
This commit is contained in:
parent
1aec39a2d7
commit
8cfc9e6d22
2 changed files with 42 additions and 5 deletions
|
@ -630,6 +630,35 @@ class RedfishUtils(object):
|
||||||
return response
|
return response
|
||||||
return {'ret': True}
|
return {'ret': True}
|
||||||
|
|
||||||
|
def get_firmware_update_capabilities(self):
|
||||||
|
result = {}
|
||||||
|
response = self.get_request(self.root_uri + self.update_uri)
|
||||||
|
if response['ret'] is False:
|
||||||
|
return response
|
||||||
|
|
||||||
|
result['ret'] = True
|
||||||
|
|
||||||
|
result['entries'] = {}
|
||||||
|
|
||||||
|
data = response['data']
|
||||||
|
|
||||||
|
if "Actions" in data:
|
||||||
|
actions = data['Actions']
|
||||||
|
if len(actions) > 0:
|
||||||
|
for key in actions.keys():
|
||||||
|
action = actions.get(key)
|
||||||
|
if 'title' in action:
|
||||||
|
title = action['title']
|
||||||
|
else:
|
||||||
|
title = key
|
||||||
|
result['entries'][title] = action.get('TransferProtocol@Redfish.AllowableValues',
|
||||||
|
["Key TransferProtocol@Redfish.AllowableValues not found"])
|
||||||
|
else:
|
||||||
|
return {'ret': "False", 'msg': "Actions list is empty."}
|
||||||
|
else:
|
||||||
|
return {'ret': "False", 'msg': "Key Actions not found."}
|
||||||
|
return result
|
||||||
|
|
||||||
def get_firmware_inventory(self):
|
def get_firmware_inventory(self):
|
||||||
result = {}
|
result = {}
|
||||||
response = self.get_request(self.root_uri + self.firmware_uri)
|
response = self.get_request(self.root_uri + self.firmware_uri)
|
||||||
|
@ -727,16 +756,14 @@ class RedfishUtils(object):
|
||||||
boot_options_dict = {}
|
boot_options_dict = {}
|
||||||
for member in members:
|
for member in members:
|
||||||
if '@odata.id' not in member:
|
if '@odata.id' not in member:
|
||||||
return {'ret': False,
|
return {'ret': False, 'msg': "@odata.id not found in BootOptions"}
|
||||||
'msg': "@odata.id not found in BootOptions"}
|
|
||||||
boot_option_uri = member['@odata.id']
|
boot_option_uri = member['@odata.id']
|
||||||
response = self.get_request(self.root_uri + boot_option_uri)
|
response = self.get_request(self.root_uri + boot_option_uri)
|
||||||
if response['ret'] is False:
|
if response['ret'] is False:
|
||||||
return response
|
return response
|
||||||
data = response['data']
|
data = response['data']
|
||||||
if 'BootOptionReference' not in data:
|
if 'BootOptionReference' not in data:
|
||||||
return {'ret': False,
|
return {'ret': False, 'msg': "BootOptionReference not found in BootOption"}
|
||||||
'msg': "BootOptionReference not found in BootOption"}
|
|
||||||
boot_option_ref = data['BootOptionReference']
|
boot_option_ref = data['BootOptionReference']
|
||||||
|
|
||||||
# fetch the props to display for this boot device
|
# fetch the props to display for this boot device
|
||||||
|
|
|
@ -137,6 +137,14 @@ EXAMPLES = '''
|
||||||
username: "{{ username }}"
|
username: "{{ username }}"
|
||||||
password: "{{ password }}"
|
password: "{{ password }}"
|
||||||
|
|
||||||
|
- name: Get firmware update capability information
|
||||||
|
redfish_facts:
|
||||||
|
category: Update
|
||||||
|
command: GetFirmwareUpdateCapabilities
|
||||||
|
baseuri: "{{ baseuri }}"
|
||||||
|
username: "{{ username }}"
|
||||||
|
password: "{{ password }}"
|
||||||
|
|
||||||
- name: Get all information available in all categories
|
- name: Get all information available in all categories
|
||||||
redfish_facts:
|
redfish_facts:
|
||||||
category: all
|
category: all
|
||||||
|
@ -164,7 +172,7 @@ CATEGORY_COMMANDS_ALL = {
|
||||||
"GetBiosAttributes", "GetBootOrder"],
|
"GetBiosAttributes", "GetBootOrder"],
|
||||||
"Chassis": ["GetFanInventory", "GetPsuInventory", "GetChassisThermals"],
|
"Chassis": ["GetFanInventory", "GetPsuInventory", "GetChassisThermals"],
|
||||||
"Accounts": ["ListUsers"],
|
"Accounts": ["ListUsers"],
|
||||||
"Update": ["GetFirmwareInventory"],
|
"Update": ["GetFirmwareInventory", "GetFirmwareUpdateCapabilities"],
|
||||||
"Manager": ["GetManagerNicInventory", "GetLogs"],
|
"Manager": ["GetManagerNicInventory", "GetLogs"],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,6 +301,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 == "GetFirmwareUpdateCapabilities":
|
||||||
|
result["firmware_update_capabilities"] = rf_utils.get_firmware_update_capabilities()
|
||||||
|
|
||||||
elif category == "Manager":
|
elif category == "Manager":
|
||||||
# execute only if we find a Manager service resource
|
# execute only if we find a Manager service resource
|
||||||
|
|
Loading…
Reference in a new issue