From 6fe4b23e3e4278825833e628f958c3d517e3d9f8 Mon Sep 17 00:00:00 2001 From: Chuck Short Date: Fri, 24 Aug 2012 10:42:45 -0500 Subject: Check volume status before detaching. If the volume is already detached previously, check the volume status before preforming the detach. Otherwise you get a nasty traceback because the instance_uuid no longer exists. Change-Id: I0df4240fb6500d5f99a20d63d82fd258fccdc9fc Signed-off-by: Chuck Short --- nova/compute/api.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nova/compute/api.py b/nova/compute/api.py index 6c21414b6..205f59667 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -1724,6 +1724,10 @@ class API(base.Base): def detach_volume(self, context, volume_id): """Detach a volume from an instance.""" volume = self.volume_api.get(context, volume_id) + if volume['attach_status'] == 'detached': + msg = _("Volume must be attached in order to detach.") + raise exception.InvalidVolume(reason=msg) + instance_uuid = volume['instance_uuid'] instance = self.db.instance_get_by_uuid(context.elevated(), instance_uuid) -- cgit