From ea822c7bdd9cbeccc4541c2f95280442c6f213ab Mon Sep 17 00:00:00 2001 From: Scott Seekamp Date: Fri, 16 Jul 2021 11:02:34 -0600 Subject: [PATCH] Redfish Bootoverride Disable behaves incorrectly (#3006) * https://github.com/ansible-collections/community.general/issues/3005 Bypass the boot device argument check when the command is: DisableBootOverride as it isn't needed to perform this operation. * Add changelog fragment --- ...dfish_command-bootoverride-argument-check.yaml | 3 +++ plugins/module_utils/redfish_utils.py | 15 ++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 changelogs/fragments/3006-redfish_command-bootoverride-argument-check.yaml diff --git a/changelogs/fragments/3006-redfish_command-bootoverride-argument-check.yaml b/changelogs/fragments/3006-redfish_command-bootoverride-argument-check.yaml new file mode 100644 index 0000000000..680d3dea83 --- /dev/null +++ b/changelogs/fragments/3006-redfish_command-bootoverride-argument-check.yaml @@ -0,0 +1,3 @@ +bugfixes: + - redfish_command - fix extraneous error caused by missing ``bootdevice`` argument + when using the ``DisableBootOverride`` sub-command (https://github.com/ansible-collections/community.general/issues/3005). diff --git a/plugins/module_utils/redfish_utils.py b/plugins/module_utils/redfish_utils.py index c39c02a42e..8d293f0056 100644 --- a/plugins/module_utils/redfish_utils.py +++ b/plugins/module_utils/redfish_utils.py @@ -1582,13 +1582,14 @@ class RedfishUtils(object): boot = data[key] - annotation = 'BootSourceOverrideTarget@Redfish.AllowableValues' - if annotation in boot: - allowable_values = boot[annotation] - if isinstance(allowable_values, list) and bootdevice not in allowable_values: - return {'ret': False, - 'msg': "Boot device %s not in list of allowable values (%s)" % - (bootdevice, allowable_values)} + if override_enabled != 'Disabled': + annotation = 'BootSourceOverrideTarget@Redfish.AllowableValues' + if annotation in boot: + allowable_values = boot[annotation] + if isinstance(allowable_values, list) and bootdevice not in allowable_values: + return {'ret': False, + 'msg': "Boot device %s not in list of allowable values (%s)" % + (bootdevice, allowable_values)} # read existing values cur_enabled = boot.get('BootSourceOverrideEnabled')