diff --git a/lib/ansible/module_utils/redfish_utils.py b/lib/ansible/module_utils/redfish_utils.py index 00e2f610eef..083b4c3c4c1 100644 --- a/lib/ansible/module_utils/redfish_utils.py +++ b/lib/ansible/module_utils/redfish_utils.py @@ -630,6 +630,35 @@ class RedfishUtils(object): return response 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): result = {} response = self.get_request(self.root_uri + self.firmware_uri) @@ -727,16 +756,14 @@ class RedfishUtils(object): boot_options_dict = {} for member in members: if '@odata.id' not in member: - return {'ret': False, - 'msg': "@odata.id not found in BootOptions"} + return {'ret': False, 'msg': "@odata.id not found in BootOptions"} boot_option_uri = member['@odata.id'] response = self.get_request(self.root_uri + boot_option_uri) if response['ret'] is False: return response data = response['data'] if 'BootOptionReference' not in data: - return {'ret': False, - 'msg': "BootOptionReference not found in BootOption"} + return {'ret': False, 'msg': "BootOptionReference not found in BootOption"} boot_option_ref = data['BootOptionReference'] # fetch the props to display for this boot device diff --git a/lib/ansible/modules/remote_management/redfish/redfish_facts.py b/lib/ansible/modules/remote_management/redfish/redfish_facts.py index a8c9faefed7..8a8ae59346f 100644 --- a/lib/ansible/modules/remote_management/redfish/redfish_facts.py +++ b/lib/ansible/modules/remote_management/redfish/redfish_facts.py @@ -137,6 +137,14 @@ EXAMPLES = ''' username: "{{ username }}" 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 redfish_facts: category: all @@ -164,7 +172,7 @@ CATEGORY_COMMANDS_ALL = { "GetBiosAttributes", "GetBootOrder"], "Chassis": ["GetFanInventory", "GetPsuInventory", "GetChassisThermals"], "Accounts": ["ListUsers"], - "Update": ["GetFirmwareInventory"], + "Update": ["GetFirmwareInventory", "GetFirmwareUpdateCapabilities"], "Manager": ["GetManagerNicInventory", "GetLogs"], } @@ -293,6 +301,8 @@ def main(): for command in command_list: if command == "GetFirmwareInventory": result["firmware"] = rf_utils.get_firmware_inventory() + elif command == "GetFirmwareUpdateCapabilities": + result["firmware_update_capabilities"] = rf_utils.get_firmware_update_capabilities() elif category == "Manager": # execute only if we find a Manager service resource