mirror of
https://opendev.org/x/pyghmi
synced 2025-04-13 16:57:46 +00:00
Provide feedback if the clear system config attempt fails
Also extend webclient to generically hold on to last error. Change-Id: Ied9452927260e22708faf4105a2ed3cafe1a6f46
This commit is contained in:
parent
552609114c
commit
f9d784f417
@ -687,12 +687,16 @@ class XCCClient(IMMClient):
|
||||
return {'height': int(dsc['u-height']), 'slot': int(dsc['slot'])}
|
||||
|
||||
def clear_system_configuration(self):
|
||||
self.wc.grab_json_response(
|
||||
'/redfish/v1/Systems/1/Bios/Actions/Bios.ResetBios',
|
||||
{'Action': 'Bios.ResetBios'},
|
||||
headers={'Authorization': 'Basic ' + base64.b64encode(
|
||||
self.username + ':' + self.password),
|
||||
'Content-Type': 'application/json'})
|
||||
res = self.wc.grab_json_response(
|
||||
'/redfish/v1/Systems/1/Bios/Actions/Bios.ResetBios',
|
||||
{'Action': 'Bios.ResetBios'},
|
||||
headers={'Authorization': 'Basic ' + base64.b64encode(
|
||||
self.username + ':' + self.password),
|
||||
'Content-Type': 'application/json'})
|
||||
if not res:
|
||||
raise Exception(
|
||||
'Unexpected response to clear configuration: {0}'.format(
|
||||
self.wc.lastjsonerror))
|
||||
|
||||
def get_webclient(self, login=True):
|
||||
cv = self.ipmicmd.certverify
|
||||
|
@ -100,6 +100,7 @@ class SecureHTTPConnection(httplib.HTTPConnection, object):
|
||||
**kwargs):
|
||||
if 'timeout' not in kwargs:
|
||||
kwargs['timeout'] = 60
|
||||
self.lastjsonerror = None
|
||||
self.broken = False
|
||||
self.thehost = host
|
||||
self.theport = port
|
||||
@ -152,6 +153,7 @@ class SecureHTTPConnection(httplib.HTTPConnection, object):
|
||||
return rsp
|
||||
|
||||
def grab_json_response(self, url, data=None, referer=None, headers=None):
|
||||
self.lastjsonerror = None
|
||||
webclient = self.dupe()
|
||||
if isinstance(data, dict):
|
||||
data = json.dumps(data)
|
||||
@ -163,7 +165,7 @@ class SecureHTTPConnection(httplib.HTTPConnection, object):
|
||||
rsp = webclient.getresponse()
|
||||
if rsp.status == 200:
|
||||
return json.loads(rsp.read())
|
||||
rsp.read()
|
||||
self.lastjsonerror = rsp.read()
|
||||
return {}
|
||||
|
||||
def download(self, url, file):
|
||||
|
Loading…
x
Reference in New Issue
Block a user