From 0977152b397f665443c941cb6bb1e254f6947cb6 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Thu, 30 Jun 2022 21:01:52 +0200 Subject: [PATCH] Fix GetChassisPower when multiple chassis are present (#4902) (#4915) * Fix GetChassisPower when multiple chassis are present When multiple chassis are present, and one or more of those chassis do _not_ report power information, the GetChassisPower command will fail. To address that, only report a failure if _all_ of the Chassis objects lack power power reporting functionality. Fixes #4901 * Update changelogs/fragments/4901-fix-redfish-chassispower.yml Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein (cherry picked from commit f60d12cf2d8361e487fee7ab260fca6b66f957a7) Co-authored-by: Jacob Yundt --- .../fragments/4901-fix-redfish-chassispower.yml | 2 ++ plugins/module_utils/redfish_utils.py | 11 +++++------ 2 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 changelogs/fragments/4901-fix-redfish-chassispower.yml diff --git a/changelogs/fragments/4901-fix-redfish-chassispower.yml b/changelogs/fragments/4901-fix-redfish-chassispower.yml new file mode 100644 index 0000000000..71a8b321eb --- /dev/null +++ b/changelogs/fragments/4901-fix-redfish-chassispower.yml @@ -0,0 +1,2 @@ +bugfixes: + - redfish_info - fix to ``GetChassisPower`` to correctly report power information when multiple chassis exist, but not all chassis report power information (https://github.com/ansible-collections/community.general/issues/4901). diff --git a/plugins/module_utils/redfish_utils.py b/plugins/module_utils/redfish_utils.py index 927ce231e6..814eef9199 100644 --- a/plugins/module_utils/redfish_utils.py +++ b/plugins/module_utils/redfish_utils.py @@ -1888,14 +1888,13 @@ class RedfishUtils(object): for property in properties: if property in data: chassis_power_result[property] = data[property] - else: - return {'ret': False, 'msg': 'Key PowerControl not found.'} chassis_power_results.append(chassis_power_result) - else: - return {'ret': False, 'msg': 'Key Power not found.'} - result['entries'] = chassis_power_results - return result + if len(chassis_power_results) > 0: + result['entries'] = chassis_power_results + return result + else: + return {'ret': False, 'msg': 'Power information not found.'} def get_chassis_thermals(self): result = {}