1
0
Fork 0
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:
Xander Madsen 2019-05-02 09:08:16 -04:00 committed by John R Barker
parent 5309d6c131
commit b108d01b0f
2 changed files with 45 additions and 2 deletions

View file

@ -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):

View file

@ -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