From a4833cbc5657cc148d64ac10264f260a19969e1b Mon Sep 17 00:00:00 2001 From: Eric Harney Date: Tue, 2 Apr 2013 09:23:05 -0400 Subject: [PATCH] Throw InvalidSnapshot for failed snap delete 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 | 2 +- cinder/volume/api.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cinder/tests/test_volume.py b/cinder/tests/test_volume.py index 47a238115..c6579f47e 100644 --- a/cinder/tests/test_volume.py +++ b/cinder/tests/test_volume.py @@ -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) diff --git a/cinder/volume/api.py b/cinder/volume/api.py index 995276748..0dd0b3146 100644 --- a/cinder/volume/api.py +++ b/cinder/volume/api.py @@ -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']) -- 2.45.2