HewlettPackard / python-ilorest-library

Python library for interacting with devices which support a Redfish Service
Apache License 2.0
187 stars 92 forks source link

Fix getting attributes of a RisObject instance #79

Closed skunkie closed 3 years ago

skunkie commented 4 years ago

When getting a nonexistent attribute of a RisObject instance, instead of an AttributeError exception, a KeyError exception is raised. This is not an expected behaviour.

Example:

import redfish

SYSTEM_URL = "https://10.0.0.100"
LOGIN_ACCOUNT = "admin"
LOGIN_PASSWORD = "password"

REDFISH_OBJ = redfish.RedfishClient(
    base_url=SYSTEM_URL,
    username=LOGIN_ACCOUNT,
    password=LOGIN_PASSWORD
)

REDFISH_OBJ.login()

RESPONSE = REDFISH_OBJ.get("/redfish/v1/systems/1")

RESPONSE_OBJ = RESPONSE.obj

print(RESPONSE_OBJ.NonExistingAttr)
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call
last)
<ipython-input-6-a41dd91fc6ac> in <module>
----> 1 print(RESPONSE_OBJ.NonExistingAttr)

KeyError: 'NonExistingAttr'
rajeevkallur commented 3 years ago

Please put the screenshot after the fix

skunkie commented 3 years ago

Here is the screenshot after the fix redfish