From ca9428037a33cf970d4d0c229121ee526614885a Mon Sep 17 00:00:00 2001 From: Rongze Zhu Date: Tue, 11 Sep 2012 07:53:35 +0000 Subject: Add 'detaching' to volume status Fixes bug #1004382 When attach a volume , the volume status is "available -> attaching -> in-use", But when detaching a volume , the volume status is "in-use -> available". So We need 'detaching' volume status, it make the change of state of the volume more clearly. Change-Id: I544220c206899307294d50e26679f5351fdc0cd7 --- nova/compute/api.py | 1 + nova/compute/manager.py | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'nova/compute') diff --git a/nova/compute/api.py b/nova/compute/api.py index 95ad4b7d0..d3b07c2e0 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -1842,6 +1842,7 @@ class API(base.Base): volume = self.volume_api.get(context, volume_id) self.volume_api.check_detach(context, volume) + self.volume_api.begin_detaching(context, volume) self.compute_rpcapi.detach_volume(context, instance=instance, volume_id=volume_id) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 9fc3104d0..94d9a8344 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -1970,9 +1970,17 @@ class ComputeManager(manager.SchedulerDependentManager): # but added for completeness in case we ever do. if connection_info and 'serial' not in connection_info: connection_info['serial'] = volume_id - self.driver.detach_volume(connection_info, - instance['name'], - mp) + try: + self.driver.detach_volume(connection_info, + instance['name'], + mp) + except Exception: # pylint: disable=W0702 + with excutils.save_and_reraise_exception(): + msg = _("Faild to detach volume %(volume_id)s from %(mp)s") + LOG.exception(msg % locals(), context=context, + instance=instance) + volume = self.volume_api.get(context, volume_id) + self.volume_api.roll_detaching(context, volume) @exception.wrap_exception(notifier=notifier, publisher_id=publisher_id()) @reverts_task_state -- cgit