2
0
mirror of https://opendev.org/x/pyghmi synced 2025-01-14 03:37:47 +00:00

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
This commit is contained in:
Jarrod Johnson 2019-05-07 16:20:48 -04:00
parent 70bf3cf165
commit 0f115fdb02

View File

@ -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: