diff options
author | Alessandro Pilotti <ap@pilotti.it> | 2012-11-16 17:53:49 +0200 |
---|---|---|
committer | Alessandro Pilotti <ap@pilotti.it> | 2012-11-16 17:53:49 +0200 |
commit | e0a25b83c63feac4752f623bb2715fffc825478b (patch) | |
tree | 08021c2de0068cc21693b86ded410f19d156ebc0 | |
parent | 48967d3822299b345589673be79cbcb58fa95d79 (diff) | |
download | nova-e0a25b83c63feac4752f623bb2715fffc825478b.tar.gz nova-e0a25b83c63feac4752f623bb2715fffc825478b.tar.xz nova-e0a25b83c63feac4752f623bb2715fffc825478b.zip |
Fixes an error reporting bug on Hyper-V
Fixes Bug #1079739
In case of errors during Hyper-V job executions, error reporting is not working
properly due to a bug in the way in which the message is formatted.
This fix handles the formatting properly for any type of WMI job.
Change-Id: Ife2756d42d14e19d9e7f204c317adc248025041a
-rw-r--r-- | nova/virt/hyperv/vmutils.py | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/nova/virt/hyperv/vmutils.py b/nova/virt/hyperv/vmutils.py index 15c03e613..8e509cd28 100644 --- a/nova/virt/hyperv/vmutils.py +++ b/nova/virt/hyperv/vmutils.py @@ -55,7 +55,6 @@ class VMUtils(object): else: return vms[0].ElementName - #TODO(alexpilotti): use the reactor to poll instead of sleep def check_job_status(self, jobpath): """Poll WMI job state for completion""" job_wmi_path = jobpath.replace('\\', '/') @@ -65,12 +64,26 @@ class VMUtils(object): time.sleep(0.1) job = wmi.WMI(moniker=job_wmi_path) if job.JobState != constants.WMI_JOB_STATE_COMPLETED: - LOG.debug(_("WMI job failed: %(ErrorSummaryDescription)s - " - "%(ErrorDescription)s - %(ErrorCode)s") % job) + job_state = job.JobState + if job.path().Class == "Msvm_ConcreteJob": + err_sum_desc = job.ErrorSummaryDescription + err_desc = job.ErrorDescription + err_code = job.ErrorCode + LOG.debug(_("WMI job failed with status %(job_state)d. " + "Error details: %(err_sum_desc)s - %(err_desc)s - " + "Error code: %(err_code)d") % locals()) + else: + (error, ret_val) = job.GetError() + if not ret_val and error: + LOG.debug(_("WMI job failed with status %(job_state)d. " + "Error details: %(error)s") % locals()) + else: + LOG.debug(_("WMI job failed with status %(job_state)d. " + "No error description available") % locals()) return False desc = job.Description elap = job.ElapsedTime - LOG.debug(_("WMI job succeeded: %(desc)s, Elapsed=%(elap)s ") + LOG.debug(_("WMI job succeeded: %(desc)s, Elapsed=%(elap)s") % locals()) return True |