def _poll_image_status(self, job, image_id): try: image_status = self._get_image_status(image_id) except Exception: exc_type, exc_value, exc_tb = sys.exc_info() org_err_msg = tb.format_exception_only(exc_type, exc_value) err_val = { 'job_id': job['id'], 'image_id': image_id, 'org_err_msg': org_err_msg } err_msg = ( _("PollingExc: image: %(image_id)s, err: %(org_err_msg)s") % err_val) LOG.exception('[%(worker_tag)s] %(msg)s' % { 'worker_tag': self.get_worker_tag(), 'msg': err_msg }) self._job_error_occurred(job, error_message=err_msg) raise exc.PollingException(err_msg) if image_status is None or image_status in _FAILED_IMAGE_STATUSES: err_val = { 'image_id': image_id, "image_status": image_status, "job_id": job['id'] } err_msg = ( _("PollingErr: Got failed image status. Details:" " image_id: %(image_id)s, 'image_status': %(image_status)s" " job_id: %(job_id)s") % err_val) self._job_error_occurred(job, error_message=err_msg) raise exc.PollingException(err_msg) return image_status
def _get_image_id(self, job): image_id = None if 'image_id' in job['metadata']: image_id = job['metadata']['image_id'] try: image_status = self._get_image_status(image_id) if image_status in _FAILED_IMAGE_STATUSES: return None except Exception: exc_type, exc_value, exc_tb = sys.exc_info() org_err_msg = tb.format_exception_only(exc_type, exc_value) err_val = { "job_id": job['id'], "image_id": image_id, "org_err_msg": org_err_msg } err_msg = _("ERROR get_image_id():" " job_id: %(job_id)s, image_id: %(image_id)s" " err:%(org_err_msg)s") % err_val LOG.exception("[%(worker_tag)s] Error getting snapshot image " "details. %(msg)s" % { 'worker_tag': self.get_worker_tag(), 'msg': err_msg }) self._job_error_occurred(job, error_message=err_msg) raise exc.PollingException(err_msg) return image_id
def _get_image_id(self, job): image_id = None if 'image_id' in job['metadata']: image_id = job['metadata']['image_id'] try: image_status = self._get_image_status(image_id) if image_status in _FAILED_IMAGE_STATUSES: return None except Exception: exc_type, exc_value, exc_tb = sys.exc_info() org_err_msg = tb.format_exception_only(exc_type, exc_value) err_val = { "job_id": job['id'], "image_id": image_id, "org_err_msg": org_err_msg } err_msg = _("ERROR get_image_id():" " job_id: %(job_id)s, image_id: %(image_id)s" " err:%(org_err_msg)s") % err_val LOG.exception("Error getting snapshot image details. %s", err_msg) self._update_job_error(job, error_msg=err_msg) raise exc.PollingException(err_msg) return image_id