Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PR #7952/dd7c3ad1 backport][stable-7] Fix errors in hpe specific get methods #8021

Conversation

patchback[bot]
Copy link

@patchback patchback bot commented Feb 24, 2024

This is a backport of PR #7952 as merged into main (dd7c3ad).

SUMMARY

While using the redfish_info module against some HPE hardware I encountered a variety of uncaught exceptions. After tracing it back I found these two methods to be the culprit. As they have a variety of syntax and logical errors.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

redfish

ADDITIONAL INFORMATION

It is worth noting that these methods and their inclusion in the all commands to the Chassis category of the redfish_info module does result in attempting to get information from OEM/Vendor specific extensions in a module which seems to otherwise attempt to only cover the generic redfish interface.

Additionally, due to the way these methods have been implemented, they both return a single value even when multiple chassis uris have a matching api command to return min fan speed and thermal configuration. I've left that logic as is so that consumers of this module do not experience breakage from a change in the "shape" of the returned data.

Ultimately I /think/ that these methods and the codepath that calls them should be removed in a future release and we should consider adding a deprecation warning.

Resolves #7951

before the change

$ ansible -m community.general.redfish_info -a '{"category": ["Chassis"], "command": "all", "baseuri": "<redacted>", "username": "administrator", "password": "<redacted>"}' -i localhost, -c local localhost

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'RedfishUtils' object has no attribute 'chassis_uri_list'
localhost | FAILED! => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python3"
    },
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/home/drawks/.ansible/tmp/ansible-tmp-1707250729.0465906-2384637-17649427234300/AnsiballZ_redfish_info.py\", line 107, in <module>\n    _ansiballz_main()\n  File \"/home/drawks/.ansible/tmp/ansible-tmp-1707250729.0465906-2384637-17649427234300/AnsiballZ_redfish_info.py\", line 99, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/drawks/.ansible/tmp/ansible-tmp-1707250729.0465906-2384637-17649427234300/AnsiballZ_redfish_info.py\", line 47, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.community.general.plugins.modules.redfish_info', init_globals=dict(_module_fqn='ansible_collections.community.general.plugins.modules.redfish_info', _modlib_path=modlib_path),\n  File \"/usr/lib64/python3.9/runpy.py\", line 225, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib64/python3.9/runpy.py\", line 97, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib64/python3.9/runpy.py\", line 87, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_community.general.redfish_info_payload_paa25mq4/ansible_community.general.redfish_info_payload.zip/ansible_collections/community/general/plugins/modules/redfish_info.py\", line 568, in <module>\n  File \"/tmp/ansible_community.general.redfish_info_payload_paa25mq4/ansible_community.general.redfish_info_payload.zip/ansible_collections/community/general/plugins/modules/redfish_info.py\", line 501, in main\n  File \"/tmp/ansible_community.general.redfish_info_payload_paa25mq4/ansible_community.general.redfish_info_payload.zip/ansible_collections/community/general/plugins/module_utils/redfish_utils.py\", line 3225, in get_hpe_thermal_config\nAttributeError: 'RedfishUtils' object has no attribute 'chassis_uri_list'\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

after:

localhost | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python3"
    },
    "changed": false,
    "redfish_facts": {
        "chassis": {
            "entries": [
< snip>
                    {
                        "Chassis": {
                            "Status": {
                                "Health": "OK"
                            }
                        }
                    }
                ]
            ],
            "ret": true
        },
        "hpe_fan_percent_min": {
            "ret": false
        },
        "hpe_thermal_config": {
            "ret": false
        },
        "psu": {
            "msg": "Key PowerSupplies not found",
            "ret": false
        },
        "thermals": {
            "entries": [
                {
                    "Name": "01-Inlet Ambient",
                    "PhysicalContext": "Intake",
                    "ReadingCelsius": 16,
< snip >
}

* Fix errors in hpe specific get methods

* corrects reference to non existent `self.chassis_uri_list` to
  `self.chassis_uris`
* corrects syntactically incorrect dereferences
* removes an uneccessary variable assignment to `chassis_uri_list`
  in `get_psu_inventory` method
* adds changelog fragment for above indicating fix of issue #7951

* Update changelog.

---------

Co-authored-by: Felix Fontein <[email protected]>
(cherry picked from commit dd7c3ad)
@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added backport bug This issue/PR relates to a bug module_utils module_utils new_contributor Help guide this first time contributor plugins plugin (any type) traceback labels Feb 24, 2024
@felixfontein felixfontein merged commit 5e5cba9 into stable-7 Feb 24, 2024
142 checks passed
@felixfontein felixfontein deleted the patchback/backports/stable-7/dd7c3ad10d706267ffcd1bea1337a148dfce60af/pr-7952 branch February 24, 2024 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug module_utils module_utils new_contributor Help guide this first time contributor plugins plugin (any type) traceback
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants