From 0f115fdb02ec0ea62df4a8944424aa23a190f45b Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 7 May 2019 16:20:48 -0400 Subject: [PATCH] More clearly indicate bad credentials When used with invalid credentials, present a more clear exception rather than a missed member of a dictionary. Change-Id: I1e5bda9368673db62dce3ca2fd321cd79c62cb9c --- pyghmi/redfish/command.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pyghmi/redfish/command.py b/pyghmi/redfish/command.py index da0405b8..38cdee0c 100644 --- a/pyghmi/redfish/command.py +++ b/pyghmi/redfish/command.py @@ -275,7 +275,12 @@ class Command(object): self.wc.set_basic_credentials(userid, password) self.wc.set_header('Content-Type', 'application/json') systems = overview['Systems']['@odata.id'] - members = self.wc.grab_json_response(systems) + res = self.wc.grab_json_response_with_status(systems) + if res[1] == 401: + raise exc.PyghmiException('Access Denied') + elif res[1] < 200 or res[1] >= 300: + raise exc.PyghmiException(repr(res[0])) + members = res[0] self._varsensormap = {} systems = members['Members'] if sysurl: