]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Throw InvalidSnapshot for failed snap delete
authorEric Harney <eharney@redhat.com>
Tue, 2 Apr 2013 13:23:05 +0000 (09:23 -0400)
committerEric Harney <eharney@redhat.com>
Tue, 2 Apr 2013 13:50:49 +0000 (09:50 -0400)
When delete is called for a snapshot not in the "available" or
"error" state, throw an InvalidSnapshot exception rather than
InvalidVolume.

Change-Id: I47f55b3357d75b5c0c9a704aaf693f4764fd112c

cinder/tests/test_volume.py
cinder/volume/api.py

index 47a23811560842212236485d7d852c202da9fe6d..c6579f47ee016d9ee94770edd7cf2b58cec31312 100644 (file)
@@ -520,7 +520,7 @@ class VolumeTestCase(test.TestCase):
         volume_api = cinder.volume.api.API()
 
         snapshot['status'] = 'badstatus'
-        self.assertRaises(exception.InvalidVolume,
+        self.assertRaises(exception.InvalidSnapshot,
                           volume_api.delete_snapshot,
                           self.context,
                           snapshot)
index 995276748cb4e8d15da9398164032e9e5be38588..0dd0b314620f3590f1bc2234bae6777449ed1431 100644 (file)
@@ -586,7 +586,7 @@ class API(base.Base):
     def delete_snapshot(self, context, snapshot, force=False):
         if not force and snapshot['status'] not in ["available", "error"]:
             msg = _("Volume Snapshot status must be available or error")
-            raise exception.InvalidVolume(reason=msg)
+            raise exception.InvalidSnapshot(reason=msg)
         self.db.snapshot_update(context, snapshot['id'],
                                 {'status': 'deleting'})
         volume = self.db.volume_get(context, snapshot['volume_id'])