mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
redfish_command: allow setting the BootSourceOverrideMode property (#3135)
* For #3134 Expose BootOverrideMode parameter to redfish_command to allow setting by user during run. * Fix trailing whitespace * Add changelog fragment to contribution. * Update changelogs/fragments/3135-add-redfish_command-bootoverridemode.yaml Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/redfish_command.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/redfish_command.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/redfish_command.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/redfish_command.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update changelogs/fragments/3135-add-redfish_command-bootoverridemode.yaml Co-authored-by: Felix Fontein <felix@fontein.de> Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
f2df1a7581
commit
75688cb632
3 changed files with 28 additions and 2 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
minor_changes:
|
||||||
|
- redfish_command - add ``boot_override_mode`` argument to BootSourceOverride commands (https://github.com/ansible-collections/community.general/issues/3134).
|
|
@ -1565,6 +1565,7 @@ class RedfishUtils(object):
|
||||||
uefi_target = boot_opts.get('uefi_target')
|
uefi_target = boot_opts.get('uefi_target')
|
||||||
boot_next = boot_opts.get('boot_next')
|
boot_next = boot_opts.get('boot_next')
|
||||||
override_enabled = boot_opts.get('override_enabled')
|
override_enabled = boot_opts.get('override_enabled')
|
||||||
|
boot_override_mode = boot_opts.get('boot_override_mode')
|
||||||
|
|
||||||
if not bootdevice and override_enabled != 'Disabled':
|
if not bootdevice and override_enabled != 'Disabled':
|
||||||
return {'ret': False,
|
return {'ret': False,
|
||||||
|
@ -1596,6 +1597,10 @@ class RedfishUtils(object):
|
||||||
target = boot.get('BootSourceOverrideTarget')
|
target = boot.get('BootSourceOverrideTarget')
|
||||||
cur_uefi_target = boot.get('UefiTargetBootSourceOverride')
|
cur_uefi_target = boot.get('UefiTargetBootSourceOverride')
|
||||||
cur_boot_next = boot.get('BootNext')
|
cur_boot_next = boot.get('BootNext')
|
||||||
|
cur_override_mode = boot.get('BootSourceOverrideMode')
|
||||||
|
|
||||||
|
if not boot_override_mode:
|
||||||
|
boot_override_mode = cur_override_mode
|
||||||
|
|
||||||
if override_enabled == 'Disabled':
|
if override_enabled == 'Disabled':
|
||||||
payload = {
|
payload = {
|
||||||
|
@ -1632,12 +1637,13 @@ class RedfishUtils(object):
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
if cur_enabled == override_enabled and target == bootdevice:
|
if cur_enabled == override_enabled and target == bootdevice and cur_override_mode == boot_override_mode:
|
||||||
# If properties are already set, no changes needed
|
# If properties are already set, no changes needed
|
||||||
return {'ret': True, 'changed': False}
|
return {'ret': True, 'changed': False}
|
||||||
payload = {
|
payload = {
|
||||||
'Boot': {
|
'Boot': {
|
||||||
'BootSourceOverrideEnabled': override_enabled,
|
'BootSourceOverrideEnabled': override_enabled,
|
||||||
|
'BootSourceOverrideMode': boot_override_mode,
|
||||||
'BootSourceOverrideTarget': bootdevice
|
'BootSourceOverrideTarget': bootdevice
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,6 +86,12 @@ options:
|
||||||
- Timeout in seconds for URL requests to OOB controller
|
- Timeout in seconds for URL requests to OOB controller
|
||||||
default: 10
|
default: 10
|
||||||
type: int
|
type: int
|
||||||
|
boot_override_mode:
|
||||||
|
description:
|
||||||
|
- Boot mode when using an override.
|
||||||
|
type: str
|
||||||
|
choices: [ Legacy, UEFI ]
|
||||||
|
version_added: 3.5.0
|
||||||
uefi_target:
|
uefi_target:
|
||||||
required: false
|
required: false
|
||||||
description:
|
description:
|
||||||
|
@ -287,6 +293,16 @@ EXAMPLES = '''
|
||||||
username: "{{ username }}"
|
username: "{{ username }}"
|
||||||
password: "{{ password }}"
|
password: "{{ password }}"
|
||||||
|
|
||||||
|
- name: Set one-time boot to BiosSetup
|
||||||
|
community.general.redfish_command:
|
||||||
|
category: Systems
|
||||||
|
command: SetOneTimeBoot
|
||||||
|
bootnext: BiosSetup
|
||||||
|
boot_override_mode: Legacy
|
||||||
|
baseuri: "{{ baseuri }}"
|
||||||
|
username: "{{ username }}"
|
||||||
|
password: "{{ password }}"
|
||||||
|
|
||||||
- name: Disable persistent boot device override
|
- name: Disable persistent boot device override
|
||||||
community.general.redfish_command:
|
community.general.redfish_command:
|
||||||
category: Systems
|
category: Systems
|
||||||
|
@ -591,6 +607,7 @@ def main():
|
||||||
timeout=dict(type='int', default=10),
|
timeout=dict(type='int', default=10),
|
||||||
uefi_target=dict(),
|
uefi_target=dict(),
|
||||||
boot_next=dict(),
|
boot_next=dict(),
|
||||||
|
boot_override_mode=dict(choices=['Legacy', 'UEFI']),
|
||||||
resource_id=dict(),
|
resource_id=dict(),
|
||||||
update_image_uri=dict(),
|
update_image_uri=dict(),
|
||||||
update_protocol=dict(),
|
update_protocol=dict(),
|
||||||
|
@ -662,7 +679,8 @@ def main():
|
||||||
boot_opts = {
|
boot_opts = {
|
||||||
'bootdevice': module.params['bootdevice'],
|
'bootdevice': module.params['bootdevice'],
|
||||||
'uefi_target': module.params['uefi_target'],
|
'uefi_target': module.params['uefi_target'],
|
||||||
'boot_next': module.params['boot_next']
|
'boot_next': module.params['boot_next'],
|
||||||
|
'boot_override_mode': module.params['boot_override_mode'],
|
||||||
}
|
}
|
||||||
|
|
||||||
# VirtualMedia options
|
# VirtualMedia options
|
||||||
|
|
Loading…
Reference in a new issue