From b5abd8e7415c28630852107da7755045f6522b50 Mon Sep 17 00:00:00 2001 From: Brian Lamar Date: Mon, 26 Sep 2011 23:41:28 -0400 Subject: Snapshots/backups can no longer happen simultaneously. Tests included. Implemented exception.InstanceBusy when attempting to snapshot/backup an instance which is already snapshotting or being currently backed up. Fixes bug 727502. (Patch Set 2) 3 new exceptions: InstanceBusy, InstanceSnapshotting, and InstanceBackingUp (Patch Set 3) Oops. New exceptions now inherit from InstanceBusy (Patch Set 4) Tests now tear down created instances Change-Id: I9614740bba26c04e64b0e27c24fbace12334f4d1 --- nova/api/openstack/images.py | 13 +++++++++---- nova/api/openstack/servers.py | 12 ++++++++---- 2 files changed, 17 insertions(+), 8 deletions(-) (limited to 'nova/api') diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py index 088c261a1..64bd4a39d 100644 --- a/nova/api/openstack/images.py +++ b/nova/api/openstack/images.py @@ -130,10 +130,15 @@ class ControllerV10(Controller): context = req.environ["nova.context"] props = {'instance_id': instance_id} - image = self._compute_service.snapshot(context, - instance_id, - image_name, - extra_properties=props) + + try: + image = self._compute_service.snapshot(context, + instance_id, + image_name, + extra_properties=props) + except exception.InstanceBusy: + msg = _("Server is currently creating an image. Please wait.") + raise webob.exc.HTTPConflict(explanation=msg) return dict(image=self.get_builder(req).build(image, detail=True)) diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 4a2d0bcbc..de081343e 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -1246,10 +1246,14 @@ class ControllerV11(Controller): msg = _("Invalid metadata") raise exc.HTTPBadRequest(explanation=msg) - image = self.compute_api.snapshot(context, - instance_id, - image_name, - extra_properties=props) + try: + image = self.compute_api.snapshot(context, + instance_id, + image_name, + extra_properties=props) + except exception.InstanceBusy: + msg = _("Server is currently creating an image. Please wait.") + raise webob.exc.HTTPConflict(explanation=msg) # build location of newly-created image entity image_id = str(image['id']) -- cgit