diff --git a/lib/ansible/module_utils/redfish_utils.py b/lib/ansible/module_utils/redfish_utils.py index 219cf9783f3..3e4abf56793 100644 --- a/lib/ansible/module_utils/redfish_utils.py +++ b/lib/ansible/module_utils/redfish_utils.py @@ -786,6 +786,39 @@ class RedfishUtils(object): def get_multi_boot_order(self): return self.aggregate(self.get_boot_order) + def get_boot_override(self, systems_uri): + result = {} + + properties = ["BootSourceOverrideEnabled", "BootSourceOverrideTarget", + "BootSourceOverrideMode", "UefiTargetBootSourceOverride", "BootSourceOverrideTarget@Redfish.AllowableValues"] + + response = self.get_request(self.root_uri + systems_uri) + if response['ret'] is False: + return response + result['ret'] = True + data = response['data'] + + if 'Boot' not in data: + return {'ret': False, 'msg': "Key Boot not found"} + + boot = data['Boot'] + + boot_overrides = {} + if "BootSourceOverrideEnabled" in boot: + if boot["BootSourceOverrideEnabled"] is not False: + for property in properties: + if property in boot: + if boot[property] is not None: + boot_overrides[property] = boot[property] + else: + return {'ret': False, 'msg': "No boot override is enabled."} + + result['entries'] = boot_overrides + return result + + def get_multi_boot_override(self): + return self.aggregate(self.get_boot_override) + def set_bios_default_settings(self): result = {} key = "Bios" @@ -1216,7 +1249,7 @@ class RedfishUtils(object): ret = inventory.pop('ret') and ret if 'entries' in inventory: entries.append(({'resource_uri': resource_uri}, - inventory['entries'])) + inventory['entries'])) return dict(ret=ret, entries=entries) def get_psu_inventory(self): diff --git a/lib/ansible/modules/remote_management/redfish/redfish_facts.py b/lib/ansible/modules/remote_management/redfish/redfish_facts.py index 28a9bb1fb97..d6935e84919 100644 --- a/lib/ansible/modules/remote_management/redfish/redfish_facts.py +++ b/lib/ansible/modules/remote_management/redfish/redfish_facts.py @@ -129,6 +129,14 @@ EXAMPLES = ''' username: "{{ username }}" password: "{{ password }}" + - name: Get boot override information + redfish_facts: + category: Systems + command: GetBootOverride + baseuri: "{{ baseuri }}" + username: "{{ username }}" + password: "{{ password }}" + - name: Get all information available in the Manager category redfish_facts: category: Manager @@ -169,7 +177,7 @@ CATEGORY_COMMANDS_ALL = { "Systems": ["GetSystemInventory", "GetPsuInventory", "GetCpuInventory", "GetMemoryInventory", "GetNicInventory", "GetStorageControllerInventory", "GetDiskInventory", - "GetBiosAttributes", "GetBootOrder"], + "GetBiosAttributes", "GetBootOrder", "GetBootOverride"], "Chassis": ["GetFanInventory", "GetPsuInventory", "GetChassisPower", "GetChassisThermals"], "Accounts": ["ListUsers"], "Update": ["GetFirmwareInventory", "GetFirmwareUpdateCapabilities"], @@ -267,6 +275,8 @@ def main(): result["bios_attribute"] = rf_utils.get_multi_bios_attributes() elif command == "GetBootOrder": result["boot_order"] = rf_utils.get_multi_boot_order() + elif command == "GetBootOverride": + result["boot_override"] = rf_utils.get_multi_boot_override() elif category == "Chassis": # execute only if we find Chassis resource