From f3a516b79df3e6d4d8dac3ebced520fcebb5324d Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Mon, 14 Aug 2023 22:15:44 +0200 Subject: [PATCH] [PR #7113/6a558734 backport][stable-7] Add support for Redfish PowerCycle reset type (#7115) Add support for Redfish PowerCycle reset type (#7113) * Add support for Redfish PowerCycle reset type * Add changelog frament (cherry picked from commit 6a558734f7fcb6b6c2414fa74686bf29922e37d9) Co-authored-by: Scott Seekamp --- changelogs/fragments/7113-redfish-utils-power-cycle.yml | 2 ++ plugins/module_utils/redfish_utils.py | 7 ++++++- plugins/modules/redfish_command.py | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/7113-redfish-utils-power-cycle.yml diff --git a/changelogs/fragments/7113-redfish-utils-power-cycle.yml b/changelogs/fragments/7113-redfish-utils-power-cycle.yml new file mode 100644 index 0000000000..22c95ce82b --- /dev/null +++ b/changelogs/fragments/7113-redfish-utils-power-cycle.yml @@ -0,0 +1,2 @@ +minor_changes: + - redfish_utils module utils - add support for ``PowerCycle`` reset type for ``redfish_command`` responses feature (https://github.com/ansible-collections/community.general/issues/7083). diff --git a/plugins/module_utils/redfish_utils.py b/plugins/module_utils/redfish_utils.py index 854c601bb4..16f0d58f0b 100644 --- a/plugins/module_utils/redfish_utils.py +++ b/plugins/module_utils/redfish_utils.py @@ -1074,7 +1074,12 @@ class RedfishUtils(object): # command should be PowerOn, PowerForceOff, etc. if not command.startswith('Power'): return {'ret': False, 'msg': 'Invalid Command (%s)' % command} - reset_type = command[5:] + + # Commands (except PowerCycle) will be stripped of the 'Power' prefix + if command == 'PowerCycle': + reset_type = command + else: + reset_type = command[5:] # map Reboot to a ResetType that does a reboot if reset_type == 'Reboot': diff --git a/plugins/modules/redfish_command.py b/plugins/modules/redfish_command.py index 0f888fb9f1..c908e9049a 100644 --- a/plugins/modules/redfish_command.py +++ b/plugins/modules/redfish_command.py @@ -747,7 +747,7 @@ from ansible.module_utils.common.text.converters import to_native # More will be added as module features are expanded CATEGORY_COMMANDS_ALL = { "Systems": ["PowerOn", "PowerForceOff", "PowerForceRestart", "PowerGracefulRestart", - "PowerGracefulShutdown", "PowerReboot", "SetOneTimeBoot", "EnableContinuousBootOverride", "DisableBootOverride", + "PowerGracefulShutdown", "PowerReboot", "PowerCycle", "SetOneTimeBoot", "EnableContinuousBootOverride", "DisableBootOverride", "IndicatorLedOn", "IndicatorLedOff", "IndicatorLedBlink", "VirtualMediaInsert", "VirtualMediaEject", "VerifyBiosAttributes"], "Chassis": ["IndicatorLedOn", "IndicatorLedOff", "IndicatorLedBlink"], "Accounts": ["AddUser", "EnableUser", "DeleteUser", "DisableUser",