DMTF / Redfish-Usecase-Checkers

This is a collection of python3 tools to exercise and validate common use cases for Redfish
Other
1 stars 6 forks source link

power_control.py throws AttributeError: 'RestResponse' object has no attribute 'is_processing' #29

Closed gkeishin closed 4 years ago

gkeishin commented 4 years ago
$ python3 Redfish-Usecase-Checkers/power_control/power_control.py -r xx.xx.xx.xx -u root -p 0penBmc -S Always
Found 1 system instances
Resetting 1318ECA using On
Traceback (most recent call last):
  File "Redfish-Usecase-Checkers/power_control/power_control.py", line 79, in <module>
    response = redfish_utilities.poll_task_monitor( redfish_obj, response )
  File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/redfish_utilities/tasks.py", line 32, in poll_task_monitor
    if not response.is_processing:
AttributeError: 'RestResponse' object has no attribute 'is_processing'
$ python -V
Python 3.6.3

$ pip3 list | grep -e redfish -e jsonschema
jsonschema                      2.6.0
redfish                         2.0.7
redfish-utilities               1.0.1
redfishtool                     1.0.8
mraineri commented 4 years ago

It looks like your version of the redfish package is out of date; version 2.0.8 added some helpers for task management. We also updated the requirements.txt file to reflect that (currently shows it needs to be 2.1.0 or higher).

Could you please try running pip3 install -r requirements.txt and try it again?

gkeishin commented 4 years ago

@mraineri sure.. let me do those and check..

gkeishin commented 4 years ago
 python3 Redfish-Usecase-Checkers/power_control/power_control.py -r xx.xx.xx.xx -u root -p 0penBmc -S Always
Found 1 system instances
Resetting 1318ECA using On
Traceback (most recent call last):
  File "Redfish-Usecase-Checkers/power_control/power_control.py", line 88, in <module>
    if system_info.dict["PowerState"] != exp_power_state:
  File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/redfish/rest/v1.py", line 240, in dict
    return json.loads(self.text)
  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
$ pip3 list | grep -e redfish -e jsonschema
jsonschema                      2.6.0
redfish                         2.1.2
redfish-utilities               1.0.1
redfishtool                     1.0.8
mraineri commented 4 years ago

Thanks! Would you be able to provide the computer system resource for "1318ECA"? I'm guessing it doesn't have a "PowerState" property.

gkeishin commented 4 years ago

Snippet of computer system

    "/redfish/v1/Systems/system": {
        "@odata.context": "/redfish/v1/$metadata#ComputerSystem.ComputerSystem",
        "@odata.id": "/redfish/v1/Systems/system",
        "@odata.type": "#ComputerSystem.v1_6_0.ComputerSystem",
        "Actions": {
            "#ComputerSystem.Reset": {
                "ResetType@Redfish.AllowableValues": [
                    "On",
                    "ForceOff",
                    "ForceOn",
                    "ForceRestart",
                    "GracefulRestart",
                    "GracefulShutdown",
                    "PowerCycle",
                    "Nmi"
                ],
                "target": "/redfish/v1/Systems/system/Actions/ComputerSystem.Reset"
            }
        },

        "Description": "Computer System",
        "Id": "1318ECA",
        "PowerState": "On",  <---
mraineri commented 4 years ago

I think I see the problem; there's an assumption the test is doing right now where it assumes the URI of the systems it finds follow the pattern "/redfish/v1/System/{SystemId}", where {SystemId} is the Id property of the system. This was a rule added in Redfish spec version 1.6.0, but older implementations can't be assumed to follow this.

I'm guessing at this point it's doing a "GET" on "/redfish/v1/Systems/1318ECA", which will result in a 404. However, I'd expect it to not get a JSON decoding error; a 404 should still be returning a JSON response.

What is provided as the response if you try to go to /redfish/v1/Systems/1318ECA? There is definitely some cleanup and error checking that can be done to make this more helpful, but it would be good to know so I can try to simulate the condition while making improvements.

gkeishin commented 4 years ago
$  redfishtool -r xx.xx.xx.xx -u root -p 0penBmc -S Always raw  GET /redfish/v1/Systems/
{
    "@odata.context": "/redfish/v1/$metadata#ComputerSystemCollection.ComputerSystemCollection",
    "@odata.id": "/redfish/v1/Systems",
    "@odata.type": "#ComputerSystemCollection.ComputerSystemCollection",
    "Members": [
        {
            "@odata.id": "/redfish/v1/Systems/system"
        }
    ],
    "Members@odata.count": 1,
    "Name": "Computer System Collection"
}
$  redfishtool -r xx.xx.xx.xx -u root -p 0penBmc -S Always raw  GET /redfish/v1/Systems/1318ECA
   redfishtool: Transport: Response Error: status_code: 404 -- Not Found
   redfishtool: raw: Error getting response
mraineri commented 4 years ago

I made a branch with a fix for the issue. If you can please try it out for me and let me know how it goes.

gkeishin commented 4 years ago

Awesome @mraineri .. Will do in few... Will keep posted

gkeishin commented 4 years ago
$ git  clone -b Power-Control-Error-Handling https://github.com/DMTF/Redfish-Usecase-Checkers
Cloning into 'Redfish-Usecase-Checkers'...
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 274 (delta 0), reused 2 (delta 0), pack-reused 270
Receiving objects: 100% (274/274), 71.39 KiB | 0 bytes/s, done.
Resolving deltas: 100% (140/140), done.
gkeishin@ ~/DMTF/Redfish-Usecase-Checkers
$ git branch
* Power-Control-Error-Handling
$ python3 Redfish-Usecase-Checkers/power_control/power_control.py -r xx.xx.xx.xx -u root -p 0penBmc -S Always
Found 1 system instances
Resetting WITHERSPOON_0006 using On
Resetting WITHERSPOON_0006 using ForceOff
Resetting WITHERSPOON_0006 using ForceOn
Resetting WITHERSPOON_0006 using ForceRestart
Resetting WITHERSPOON_0006 using GracefulRestart
Resetting WITHERSPOON_0006 using GracefulShutdown
Resetting WITHERSPOON_0006 using PowerCycle
Resetting WITHERSPOON_0006 using Nmi

works like charm @mraineri .. Thanks a bunch for fixing it up quick.. Appreciated..