diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-09-21 21:47:25 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-09-21 21:47:25 +0000 |
| commit | 3b69895b4c8ff78e6f986fc7e60c724428e3ca0b (patch) | |
| tree | 406d17c458e49af8a49cd87f7d6795f049b97f80 | |
| parent | 9dc1b976cf0fa12fb3be673f5269212cde11c740 (diff) | |
| parent | 4c09d809c9bd37eeb55f64ec01f8a0b900f9a3bf (diff) | |
| download | nova-3b69895b4c8ff78e6f986fc7e60c724428e3ca0b.tar.gz nova-3b69895b4c8ff78e6f986fc7e60c724428e3ca0b.tar.xz nova-3b69895b4c8ff78e6f986fc7e60c724428e3ca0b.zip | |
Merge "Cleanup exception handling"
| -rw-r--r-- | nova/api/openstack/compute/contrib/floating_ips.py | 2 | ||||
| -rw-r--r-- | nova/virt/hyperv/vmops.py | 2 | ||||
| -rw-r--r-- | nova/virt/libvirt/driver.py | 27 | ||||
| -rw-r--r-- | nova/virt/xenapi/vm_utils.py | 2 |
4 files changed, 19 insertions, 14 deletions
diff --git a/nova/api/openstack/compute/contrib/floating_ips.py b/nova/api/openstack/compute/contrib/floating_ips.py index f3692e02e..be952eb8a 100644 --- a/nova/api/openstack/compute/contrib/floating_ips.py +++ b/nova/api/openstack/compute/contrib/floating_ips.py @@ -175,7 +175,7 @@ class FloatingIPController(object): nmfi.message = _("No more floating ips in pool %s.") % pool else: nmfi.message = _("No more floating ips available.") - raise nmfi + raise return _translate_floating_ip_view(ip) diff --git a/nova/virt/hyperv/vmops.py b/nova/virt/hyperv/vmops.py index af6f9cfbf..8c86016c2 100644 --- a/nova/virt/hyperv/vmops.py +++ b/nova/virt/hyperv/vmops.py @@ -157,7 +157,7 @@ class VMOps(baseops.BaseOps): except Exception as exn: LOG.exception(_('spawn vm failed: %s'), exn) self.destroy(instance) - raise exn + raise def _create_vm(self, instance): """Create a VM but don't start it. """ diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 567ed6ec8..7e828163c 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -1183,11 +1183,11 @@ class LibvirtDriver(driver.ComputeDriver): else: LOG.error(_("Error on '%(path)s' while checking direct I/O: " "'%(ex)s'") % {'path': dirpath, 'ex': str(e)}) - raise e + raise except Exception, e: LOG.error(_("Error on '%(path)s' while checking direct I/O: " "'%(ex)s'") % {'path': dirpath, 'ex': str(e)}) - raise e + raise finally: try: os.unlink(testfile) @@ -2764,6 +2764,16 @@ class LibvirtDriver(driver.ComputeDriver): """Manage the local cache of images.""" self.image_cache_manager.verify_base_images(context) + def _cleanup_remote_migration(self, dest, inst_base, inst_base_resize): + """Used only for cleanup in case migrate_disk_and_power_off fails""" + try: + if os.path.exists(inst_base_resize): + utils.execute('rm', '-rf', inst_base) + utils.execute('mv', inst_base_resize, inst_base) + utils.execute('ssh', dest, 'rm', '-rf', inst_base) + except Exception: + pass + @exception.wrap_exception() def migrate_disk_and_power_off(self, context, instance, dest, instance_type, network_info, @@ -2816,15 +2826,10 @@ class LibvirtDriver(driver.ComputeDriver): else: # raw or qcow2 with no backing file libvirt_utils.copy_image(from_path, img_path, host=dest) - except Exception, e: - try: - if os.path.exists(inst_base_resize): - utils.execute('rm', '-rf', inst_base) - utils.execute('mv', inst_base_resize, inst_base) - utils.execute('ssh', dest, 'rm', '-rf', inst_base) - except Exception: - pass - raise e + except Exception: + with excutils.save_and_reraise_exception(): + self._cleanup_remote_migration(dest, inst_base, + inst_base_resize) return disk_info_text diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py index 03a86415c..a9adb4575 100644 --- a/nova/virt/xenapi/vm_utils.py +++ b/nova/virt/xenapi/vm_utils.py @@ -1148,7 +1148,7 @@ def _fetch_disk_image(context, session, instance, name_label, image_id, e.args = e.args + ([dict(type=ImageType.to_string(image_type), uuid=vdi_uuid, file=filename)],) - raise e + raise def determine_disk_image_type(image_meta): |
