diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-02-28 16:09:45 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-02-28 16:09:45 +0000 |
| commit | 5b9fc411db9c7781e16da170ab2837b009d6aae6 (patch) | |
| tree | 31e6b1601ad5552a11c22e114363906181d63bc8 | |
| parent | 6f1eb773befe81a22bb9e2d4da87cd1da598f96e (diff) | |
| parent | 44067ba758b378c4c2c2ff88b0d1b7a3c27ac812 (diff) | |
| download | nova-5b9fc411db9c7781e16da170ab2837b009d6aae6.tar.gz nova-5b9fc411db9c7781e16da170ab2837b009d6aae6.tar.xz nova-5b9fc411db9c7781e16da170ab2837b009d6aae6.zip | |
Merge "Call detach_volume when attach fails"
| -rw-r--r-- | nova/exception.py | 4 | ||||
| -rw-r--r-- | nova/virt/libvirt/connection.py | 13 |
2 files changed, 16 insertions, 1 deletions
diff --git a/nova/exception.py b/nova/exception.py index 668617500..e1caf28fe 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -362,6 +362,10 @@ class InvalidDevicePath(Invalid): message = _("The supplied device path (%(path)s) is invalid.") +class DeviceIsBusy(Invalid): + message = _("The supplied device (%(device)s) is busy.") + + class InvalidCPUInfo(Invalid): message = _("Unacceptable CPU info") + ": %(reason)s" diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py index 9ee098507..356bcdacf 100644 --- a/nova/virt/libvirt/connection.py +++ b/nova/virt/libvirt/connection.py @@ -471,7 +471,18 @@ class LibvirtConnection(driver.ComputeDriver): if FLAGS.libvirt_type == 'lxc': self._attach_lxc_volume(xml, virt_dom, instance_name) else: - virt_dom.attachDevice(xml) + try: + virt_dom.attachDevice(xml) + except Exception, ex: + self.volume_driver_method('disconnect_volume', + connection_info, + mount_device) + + if isinstance(ex, libvirt.libvirtError): + errcode = ex.get_error_code() + if errcode == libvirt.VIR_ERR_OPERATION_FAILED: + raise exception.DeviceIsBusy(device=mount_device) + raise @staticmethod def _get_disk_xml(xml, device): |
