summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorBrian Lamar <brian.lamar@rackspace.com>2011-09-26 23:41:28 -0400
committerBrian Lamar <brian.lamar@rackspace.com>2011-09-28 13:51:15 -0400
commitb5abd8e7415c28630852107da7755045f6522b50 (patch)
tree7bfde7966f81d6a2e34b901634782f2528bc1bc4 /nova/api
parentebec34e374bd9ec5354e3648a6e8f3ce26c951b5 (diff)
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
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/images.py13
-rw-r--r--nova/api/openstack/servers.py12
2 files changed, 17 insertions, 8 deletions
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'])