mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Feat/add GetBootOverride to Systems category of redfish_facts (#54273)
* Add GetBootOverride as possible Systems command * Add conditional to call get_boot_override if command == GetBootOverride * Implement get_boot_override() in redfish_utils * Implement get_multi_boot_override() and modify get_boot_override() to support the multi wrapper * Update GetBootOverride to use get_multi_boot_override * Add example for new command in docstring * fix indent * Update lib/ansible/module_utils/redfish_utils.py Co-Authored-By: xmadsen <xander.madsen@gmail.com>
This commit is contained in:
parent
5309d6c131
commit
b108d01b0f
2 changed files with 45 additions and 2 deletions
|
@ -786,6 +786,39 @@ class RedfishUtils(object):
|
||||||
def get_multi_boot_order(self):
|
def get_multi_boot_order(self):
|
||||||
return self.aggregate(self.get_boot_order)
|
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):
|
def set_bios_default_settings(self):
|
||||||
result = {}
|
result = {}
|
||||||
key = "Bios"
|
key = "Bios"
|
||||||
|
|
|
@ -129,6 +129,14 @@ EXAMPLES = '''
|
||||||
username: "{{ username }}"
|
username: "{{ username }}"
|
||||||
password: "{{ password }}"
|
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
|
- name: Get all information available in the Manager category
|
||||||
redfish_facts:
|
redfish_facts:
|
||||||
category: Manager
|
category: Manager
|
||||||
|
@ -169,7 +177,7 @@ CATEGORY_COMMANDS_ALL = {
|
||||||
"Systems": ["GetSystemInventory", "GetPsuInventory", "GetCpuInventory",
|
"Systems": ["GetSystemInventory", "GetPsuInventory", "GetCpuInventory",
|
||||||
"GetMemoryInventory", "GetNicInventory",
|
"GetMemoryInventory", "GetNicInventory",
|
||||||
"GetStorageControllerInventory", "GetDiskInventory",
|
"GetStorageControllerInventory", "GetDiskInventory",
|
||||||
"GetBiosAttributes", "GetBootOrder"],
|
"GetBiosAttributes", "GetBootOrder", "GetBootOverride"],
|
||||||
"Chassis": ["GetFanInventory", "GetPsuInventory", "GetChassisPower", "GetChassisThermals"],
|
"Chassis": ["GetFanInventory", "GetPsuInventory", "GetChassisPower", "GetChassisThermals"],
|
||||||
"Accounts": ["ListUsers"],
|
"Accounts": ["ListUsers"],
|
||||||
"Update": ["GetFirmwareInventory", "GetFirmwareUpdateCapabilities"],
|
"Update": ["GetFirmwareInventory", "GetFirmwareUpdateCapabilities"],
|
||||||
|
@ -267,6 +275,8 @@ def main():
|
||||||
result["bios_attribute"] = rf_utils.get_multi_bios_attributes()
|
result["bios_attribute"] = rf_utils.get_multi_bios_attributes()
|
||||||
elif command == "GetBootOrder":
|
elif command == "GetBootOrder":
|
||||||
result["boot_order"] = rf_utils.get_multi_boot_order()
|
result["boot_order"] = rf_utils.get_multi_boot_order()
|
||||||
|
elif command == "GetBootOverride":
|
||||||
|
result["boot_override"] = rf_utils.get_multi_boot_override()
|
||||||
|
|
||||||
elif category == "Chassis":
|
elif category == "Chassis":
|
||||||
# execute only if we find Chassis resource
|
# execute only if we find Chassis resource
|
||||||
|
|
Loading…
Reference in a new issue