summaryrefslogtreecommitdiffstats
path: root/nova/volume/api.py
diff options
context:
space:
mode:
authorAnthony Young <sleepsonthefloor@gmail.com>2012-03-29 16:57:19 -0700
committerAnthony Young <sleepsonthefloor@gmail.com>2012-03-29 18:34:49 -0700
commit43c63d11417de8624d120ca78a9849d09ffa8cf6 (patch)
treeb3f60cf08b3dc1effe913442dd173b376113b001 /nova/volume/api.py
parent75676812e867a36778fa5b1beb3d2dbfcb87bec2 (diff)
downloadnova-43c63d11417de8624d120ca78a9849d09ffa8cf6.tar.gz
nova-43c63d11417de8624d120ca78a9849d09ffa8cf6.tar.xz
nova-43c63d11417de8624d120ca78a9849d09ffa8cf6.zip
Check that volume has no snapshots before deletion
* Raise a helpful error message if existing snapshots are detected * Fixes bug 968700 * Fixes bug 968649 Change-Id: I470db6bd51a103249aae9bfcb2167f0a486732c2
Diffstat (limited to 'nova/volume/api.py')
-rw-r--r--nova/volume/api.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/nova/volume/api.py b/nova/volume/api.py
index bf79fd119..26d56c057 100644
--- a/nova/volume/api.py
+++ b/nova/volume/api.py
@@ -136,6 +136,12 @@ class API(base.Base):
if volume['status'] not in ["available", "error"]:
msg = _("Volume status must be available or error")
raise exception.InvalidVolume(reason=msg)
+
+ snapshots = self.db.snapshot_get_all_for_volume(context, volume_id)
+ if len(snapshots):
+ msg = _("Volume still has %d dependent snapshots" % len(snapshots))
+ raise exception.InvalidVolume(reason=msg)
+
now = utils.utcnow()
self.db.volume_update(context, volume_id, {'status': 'deleting',
'terminated_at': now})