From 481fc48e515292a48e12951be047e382ce00934b Mon Sep 17 00:00:00 2001 From: Mike Raineri Date: Fri, 22 Oct 2021 01:29:26 -0400 Subject: [PATCH] Redfish: Do not set the boot source override mode if not provided by the user (#3581) * Redfish: Do not set the boot source override mode if not provided by the user Signed-off-by: Mike Raineri * Corrected changelog file extension Signed-off-by: Mike Raineri * Update changelogs/fragments/3509-redfish_utils-SetOneTimeBoot-mode-fix.yml Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein --- .../3509-redfish_utils-SetOneTimeBoot-mode-fix.yml | 2 ++ plugins/module_utils/redfish_utils.py | 9 ++++----- 2 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/3509-redfish_utils-SetOneTimeBoot-mode-fix.yml diff --git a/changelogs/fragments/3509-redfish_utils-SetOneTimeBoot-mode-fix.yml b/changelogs/fragments/3509-redfish_utils-SetOneTimeBoot-mode-fix.yml new file mode 100644 index 0000000000..3c1ce33513 --- /dev/null +++ b/changelogs/fragments/3509-redfish_utils-SetOneTimeBoot-mode-fix.yml @@ -0,0 +1,2 @@ +bugfixes: + - redfish_utils module utils - do not attempt to change the boot source override mode if not specified by the user (https://github.com/ansible-collections/community.general/issues/3509/). diff --git a/plugins/module_utils/redfish_utils.py b/plugins/module_utils/redfish_utils.py index 32a16932cf..c2f17e03fb 100644 --- a/plugins/module_utils/redfish_utils.py +++ b/plugins/module_utils/redfish_utils.py @@ -1605,9 +1605,6 @@ class RedfishUtils(object): 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': payload = { 'Boot': { @@ -1643,16 +1640,18 @@ class RedfishUtils(object): } } else: - if cur_enabled == override_enabled and target == bootdevice and cur_override_mode == boot_override_mode: + if (cur_enabled == override_enabled and target == bootdevice and + (cur_override_mode == boot_override_mode or not boot_override_mode)): # If properties are already set, no changes needed return {'ret': True, 'changed': False} payload = { 'Boot': { 'BootSourceOverrideEnabled': override_enabled, - 'BootSourceOverrideMode': boot_override_mode, 'BootSourceOverrideTarget': bootdevice } } + if boot_override_mode: + payload['Boot']['BootSourceOverrideMode'] = boot_override_mode response = self.patch_request(self.root_uri + self.systems_uri, payload) if response['ret'] is False: