From a3596658c83ed84970cfaba40d7f489728a00d48 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Tue, 7 Feb 2012 16:56:04 -0800 Subject: Fixes volume snapshotting issues and tests * changes call for create_snapshot from contrib/volumes.py * fixes some raises in volume/snaphsots.py * rewrites volume api tests to use the right endpoint * updates contrib snapshots test to catch the error * fixes bug 928567 * fixes bug 928588 Change-Id: Ifa6bd8b70dc0df5c8811b0123072ba83eb170a45 --- nova/api/openstack/compute/contrib/volumes.py | 6 ++++-- nova/api/openstack/volume/snapshots.py | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'nova/api') diff --git a/nova/api/openstack/compute/contrib/volumes.py b/nova/api/openstack/compute/contrib/volumes.py index 6d0110069..e235ad0fe 100644 --- a/nova/api/openstack/compute/contrib/volumes.py +++ b/nova/api/openstack/compute/contrib/volumes.py @@ -517,18 +517,20 @@ class SnapshotController(object): snapshot = body['snapshot'] volume_id = snapshot['volume_id'] + volume = self.volume_api.get(context, volume_id) + force = snapshot.get('force', False) LOG.audit(_("Create snapshot from volume %s"), volume_id, context=context) if force: new_snapshot = self.volume_api.create_snapshot_force(context, - volume_id, + volume, snapshot.get('display_name'), snapshot.get('display_description')) else: new_snapshot = self.volume_api.create_snapshot(context, - volume_id, + volume, snapshot.get('display_name'), snapshot.get('display_description')) diff --git a/nova/api/openstack/volume/snapshots.py b/nova/api/openstack/volume/snapshots.py index 36687d736..67cfca3ea 100644 --- a/nova/api/openstack/volume/snapshots.py +++ b/nova/api/openstack/volume/snapshots.py @@ -98,7 +98,7 @@ class SnapshotsController(object): try: vol = self.volume_api.get_snapshot(context, id) except exception.NotFound: - return exc.HTTPNotFound() + raise exc.HTTPNotFound() return {'snapshot': _translate_snapshot_detail_view(context, vol)} @@ -112,7 +112,7 @@ class SnapshotsController(object): snapshot = self.volume_api.get_snapshot(context, id) self.volume_api.delete_snapshot(context, snapshot) except exception.NotFound: - return exc.HTTPNotFound() + raise exc.HTTPNotFound() return webob.Response(status_int=202) @wsgi.serializers(xml=SnapshotsTemplate) -- cgit