Repository: ansible-collections/community.general

Issue:
GetChassisPower fails to report power information when multiple chassis are present
### Summary

The `GetChassisPower` command in `redfish_info` will fail to report power for _all_ chassis if:
- multiple chassis are present
- at least one chassis does not report power information

We are encountering this on servers that have backplanes which report as a "Chassis" (but do not report power information).

### Issue Type

Bug Report

### Component Name

redfish_info

### Ansible Version

```console (paste below)
ansible 2.10.7
  config file = None
  configured module search path = ['/home/jyundt/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/jyundt/git/firmware_updater/venv/lib/python3.8/site-packages/ansible
  executable location = /home/jyundt/git/firmware_updater/venv/bin/ansible
  python version = 3.8.10 (default, Mar 15 2022, 12:22:08) [GCC 9.4.0]

```


### Community.general Version

```console (paste below)

# /home/jyundt/git/firmware_updater/venv/lib/python3.8/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 1.3.6  

# /home/jyundt/ansible/ansible_collections
Collection        Version
----------------- -------
community.general 5.3.0  

```


### Configuration

_No response_

### OS / Environment

_No response_

### Steps to Reproduce

<!--- Paste example playbooks or commands between quotes below -->
Sample playbook
```
---
- hosts: all
  gather_facts: false
  vars:
    bmc_username: root
    bmc_password: hunter2
    default_uri_timeout: 50
    default_uri_retries: 5
  tasks:
  - name: Gather initial BMC lan infomration
    command: ipmitool lan print
    register: ipmitool_output
    changed_when: ipmitool_output.rc != 0
    become: true

  - name: Set BMC IP address as fact
    set_fact:
      bmc_address: "{{ ipmitool_output.stdout | regex_search('IP Address\\s+:\\s+(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})', '\\1')
                                              | first }}"

  - name: Get Chassis Power
    community.general.redfish_info:
      category: Chassis
      command: GetChassisPower
      baseuri: "{{ bmc_address }}"
      username: "{{ bmc_username }}"
      password: "{{ bmc_password }}"
      timeout: "{{ default_uri_timeout }}"
    retries: "{{ default_uri_retries }}"
    register: redfish_chassis_power

  - debug:
      var: redfish_chassis_power


```
Results in:

```
PLAY [all] **********************************************************************************************************************************************************************************

TASK [Gather initial BMC lan infomration] ***************************************************************************************************************************************************
ok: [s2r8node79]

TASK [Set BMC IP address as fact] ***********************************************************************************************************************************************************
ok: [s2r8node79]

TASK [Get Chassis Power] ********************************************************************************************************************************************************************
ok: [s2r8node79]

TASK [debug] ********************************************************************************************************************************************************************************
ok: [s2r8node79] => {
    "redfish_chassis_power": {
        "changed": false,
        "failed": false,
        "redfish_facts": {
            "chassis_power": {
                "msg": "Key Power not found.",
                "ret": false
            }
        }
    }
}
```
Sample Server:

```
jyundt@prod-jump04:~$ curl -skL -u root:$BMC_PASSWORD https://10.208.9.24/redfish/v1/Chassis | jq '.'
{
  "@odata.type": "#ChassisCollection.ChassisCollection",
  "@odata.id": "/redfish/v1/Chassis",
  "Id": "Chassis",
  "Name": "Chassis Collection",
  "Members": [
    {
      "@odata.id": "/redfish/v1/Chassis/1"
    },
    {
      "@odata.id": "/redfish/v1/Chassis/NVMeSSD.0.Group.0.StorageBackplane"
    }
  ],
  "Members@odata.count": 2
}
jyundt@prod-jump04:~$ curl -skL -u root:$BMC_PASSWORD https://10.208.9.24/redfish/v1/Chassis/1/ | jq '.Power'
{
  "@odata.id": "/redfish/v1/Chassis/1/Power"
}
jyundt@prod-jump04:~$ curl -skL -u root:$BMC_PASSWORD https://10.208.9.24/redfish/v1/Chassis/NVMeSSD.0.Group.0.StorageBackplane | jq '.Power'
null
jyundt@prod-jump04:~$
```


### Expected Results

I would expect the Chassis Power to report correctly for this server and skip the backplane / Chassis that does not have Power data.

### Actual Results

```console (paste below)

```


### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct


Discussion:
Files identified in the description:
* [`plugins/modules/remote_management/redfish/redfish_info.py`](https://github.com/ansible-collections/community.general/blob/main/plugins/modules/remote_management/redfish/redfish_info.py)

If these files are incorrect, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/devel/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @bhavya06 @mraineri @rajeevkallur @renxulei @tomasg2012 @xmadsen
[click here for bot help](https://github.com/ansible/ansibullbot/blob/devel/ISSUE_HELP.md)
<!--- boilerplate: notify --->

Resolving patch:
diff --git a/plugins/module_utils/redfish_utils.py b/plugins/module_utils/redfish_utils.py
--- a/plugins/module_utils/redfish_utils.py
+++ b/plugins/module_utils/redfish_utils.py
@@ -1883,14 +1883,13 @@ def get_chassis_power(self):
                         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 = {}


Test patch: