openbmc / openbmc-tools

Collection of useful tools to interact with openbmc
Apache License 2.0
32 stars 27 forks source link

openbmctool: health_check fail JSON #44

Open ssombar opened 6 years ago

ssombar commented 6 years ago

openbmctool: version 1.06, 1.07 or 1.08

when doing python3 openbmctool.py -H $BMC_IP -U **** -P **** health_check get failure "JSON object must be str, not 'dict'" as follows:

Attempting login... Traceback (most recent call last): File "openbmctool.py", line 2290, in main() File "openbmctool.py", line 2264, in main output = args.func(args.host, args, mysess) File "openbmctool.py", line 1582, in healthCheck sels = json.loads(selPrint(host, args, session)) File "/opt/rh/rh-python34/root/usr/lib64/python3.4/json/init.py", line 312, in loads s.class.name)) TypeError: the JSON object must be str, not 'dict'

This seen on recent r7 firmware. Older firmware works fine.

amboar commented 5 years ago

@ssombar please use the triple back-tick markdown when pasting code or console output into github issues. It prevents github's rendering engine interpreting your log output as markdown. What you write looks like:

```
My code, console or log output here
```

A guide to using github-flavoured markdown is here:

https://guides.github.com/features/mastering-markdown/

Cheers,

Andrew

tom-ky-wu commented 11 months ago

Hi, I have the similar issue I'm using openbmctool version 1.19

python3 $(which openbmctool.py) -H xxx.xxx.xxx.xxx:443 -U root -P 0penBmc health_check

The response message is as follows:

Attempting login...
Traceback (most recent call last):
  File "/usr/bin/openbmctool.py", line 5408, in <module>
    main()
  File "/usr/bin/openbmctool.py", line 5376, in main
    output = args.func(args.host, args, mysess)
  File "/usr/bin/openbmctool.py", line 2507, in healthCheck
    sels = json.loads(selPrint(host, args, session))
  File "/usr/lib/python3.10/json/__init__.py", line 339, in loads
    raise TypeError(f'the JSON object must be str, bytes or bytearray, '
TypeError: the JSON object must be str, bytes or bytearray, not dict

what might cause the problem?

mdmillerii commented 11 months ago

The error is coming from https://github.com/python/cpython/blob/88bac5d5044e577825db1f9367af908dc9a3ad82/Lib/json/__init__.py#L299

However latest tool has loads in healtcheck at line 2476 https://github.com/openbmc/openbmc-tools/blob/cff0bfa003d9f8a2f12f13c9b80646315c6f6b8c/openbmctool/openbmctool.py#L2476 so ~please indicate the exact version you are using.~ ahhh you stated 1.06 7 8, which is 2018 (current is 1.19)

I'm not close to being an expert in Python but it appears that health check is modifing d but passing args to fru status . As a quick check does asking for json output by adding -j make health check work?

Otherwise I'll defer to others.

tom-ky-wu commented 11 months ago

Hi, thank you for your reply. But I'm the different user from above, just encounter the similar health_check fail JSON error. I'm sure I download the latest code from master branch and the tool version is 1.19

mdmillerii commented 11 months ago

I'm the different user from above, just encounter the similar health_check fail JSON error. I'm sure I download the latest code from master branch and the tool version is 1.19

If the issue is what I identified it hasn't been addressed. Can you report if it works when you ask for json by adding -j? If so I'll propose a patch. (I don't have a system available to test at this point).

tom-ky-wu commented 11 months ago

Hi, I've solved the problem. I've exported the paths for the "openbmctool.py" and "policyTable.json" files to the PATH environment variable to run the openbmc-test-automation. However, I'm still encountering an issue that the "policyTable.json" cannot be loaded when running the program. That's why I can see the above message. In the end, I created folder path "/opt/ibm/ras/lib" and placed files there to slove the problem. Code Reference here https://github.com/openbmc/openbmc-tools/blob/master/openbmctool/openbmctool.py#L1181-L1190

mdmillerii commented 11 months ago

Thanks for the report @tom-ky-wu , and I'm glad you were able to identify the cause your issue. I missed that your json.loads was a different context and totally different source.

I see the tool has a buildscripts subdirectory to package an RPM with the library in that /opt/ibm location, but the readme doesn't mention it or how to install. The PATH environment variable is used to search for executables but as you discovered not data files by default. As you found, the script looks in the current directory, the place installed by the RPM, and the relative lib if one manually unpacked it.

Possible enhancements would be to look relative to the python script and or documentation to mention the file is needed.

See here if you would like to help by sending a patch: https://github.com/openbmc/openbmc-tools#sending-patches