Skip to content

Commit

Permalink
Fixes an error reporting bug on Hyper-V
Browse files Browse the repository at this point in the history
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
  • Loading branch information
alexpilotti committed Nov 16, 2012
1 parent 48967d3 commit e0a25b8
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions nova/virt/hyperv/vmutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def lookup(self, conn, i):
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('\\', '/')
Expand All @@ -65,12 +64,26 @@ def check_job_status(self, jobpath):
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

Expand Down

0 comments on commit e0a25b8

Please sign in to comment.