diff --git a/pyghmi/ipmi/oem/lenovo/imm.py b/pyghmi/ipmi/oem/lenovo/imm.py index 90d1b16f..bb0d6b14 100644 --- a/pyghmi/ipmi/oem/lenovo/imm.py +++ b/pyghmi/ipmi/oem/lenovo/imm.py @@ -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 diff --git a/pyghmi/util/webclient.py b/pyghmi/util/webclient.py index 18ddb83b..d833fca7 100644 --- a/pyghmi/util/webclient.py +++ b/pyghmi/util/webclient.py @@ -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):