diff --git a/pyghmi/redfish/oem/lenovo/xcc.py b/pyghmi/redfish/oem/lenovo/xcc.py index de6d25ff..5f80e79f 100644 --- a/pyghmi/redfish/oem/lenovo/xcc.py +++ b/pyghmi/redfish/oem/lenovo/xcc.py @@ -751,43 +751,41 @@ class OEMHandler(generic.OEMHandler): progress( {'phase': 'upload', 'progress': 100 * wc.get_upload_progress()}) - if (uploadthread.rspstatus >= 300 - or uploadthread.rspstatus < 200): - rsp = uploadthread.rsp - errmsg = '' - try: - rsp = json.loads(rsp) - errmsg = ( - rsp['error'][ - '@Message.ExtendedInfo'][0]['Message']) - except Exception: - raise Exception(uploadthread.rsp) - raise Exception(errmsg) - rsp = json.loads(uploadthread.rsp) - monitorurl = rsp['TaskMonitor'] - complete = False - while not complete: - pgress, status = self._do_web_request(monitorurl) - if status < 200 or status >= 300: - raise Exception(pgress) - if not pgress: - break - for msg in pgress.get('Messages', []): - if 'Verify failed' in msg.get('Message', ''): - raise Exception(msg['Message']) - state = pgress['TaskState'] - if state in ('Cancelled', 'Exception', 'Interrupted', - 'Suspended'): - raise Exception( - json.dumps(json.dumps(pgress['Messages']))) - pct = float(pgress['PercentComplete']) - complete = state == 'Completed' - progress({'phase': 'apply', 'progress': pct}) - if not complete: - time.sleep(3) - if bank == 'backup': - return 'complete' - return 'pending' + if (uploadthread.rspstatus >= 300 + or uploadthread.rspstatus < 200): + rsp = uploadthread.rsp + errmsg = '' + try: + rsp = json.loads(rsp) + errmsg = ( + rsp['error'][ + '@Message.ExtendedInfo'][0]['Message']) + except Exception: + raise Exception(uploadthread.rsp) + raise Exception(errmsg) + rsp = json.loads(uploadthread.rsp) + monitorurl = rsp['TaskMonitor'] + complete = False + while not complete: + pgress = self._do_web_request(monitorurl, cache=False) + if not pgress: + break + for msg in pgress.get('Messages', []): + if 'Verify failed' in msg.get('Message', ''): + raise Exception(msg['Message']) + state = pgress['TaskState'] + if state in ('Cancelled', 'Exception', 'Interrupted', + 'Suspended'): + raise Exception( + json.dumps(json.dumps(pgress['Messages']))) + pct = float(pgress['PercentComplete']) + complete = state == 'Completed' + progress({'phase': 'apply', 'progress': pct}) + if not complete: + time.sleep(3) + if bank == 'backup': + return 'complete' + return 'pending' finally: self._do_web_request( '/redfish/v1/UpdateService',