summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorÉdouard Thuleau <edouard.thuleau@orange.com>2012-10-25 10:32:48 +0200
committerÉdouard Thuleau <edouard.thuleau@orange.com>2012-11-07 10:17:13 +0100
commit6eac65a8e13d3040c0c6561709f59b3d9bab5435 (patch)
tree79619ab5c0699c31a50dc75a3587d8832c17835c /nova/api
parent562b3abc843942a096e5750161c1aae2402d595b (diff)
'BackupCreate' rotation parameter >= 0
In the extension 'admin-actions' of OpenStack Compute API, the action create backups should only accept rotation parameter greater than or equal to zero. If the 'rotation' parameter is negative, OS API returns a badRequest 400 HTTP error. Fixes LP bug #1071168 Change-Id: I6ef08fbecb0f88942cdb16193e9d2c3831866fe9
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/compute/contrib/admin_actions.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/nova/api/openstack/compute/contrib/admin_actions.py b/nova/api/openstack/compute/contrib/admin_actions.py
index 1bac0851d..02a588ffa 100644
--- a/nova/api/openstack/compute/contrib/admin_actions.py
+++ b/nova/api/openstack/compute/contrib/admin_actions.py
@@ -229,6 +229,10 @@ class AdminActionsController(wsgi.Controller):
except ValueError:
msg = _("createBackup attribute 'rotation' must be an integer")
raise exc.HTTPBadRequest(explanation=msg)
+ if rotation < 0:
+ msg = _("createBackup attribute 'rotation' must be greater "
+ "than or equal to zero")
+ raise exc.HTTPBadRequest(explanation=msg)
props = {}
metadata = entity.get('metadata', {})
@@ -251,12 +255,14 @@ class AdminActionsController(wsgi.Controller):
common.raise_http_conflict_for_instance_invalid_state(state_error,
'createBackup')
- # build location of newly-created image entity
- image_id = str(image['id'])
- image_ref = os.path.join(req.application_url, 'images', image_id)
-
resp = webob.Response(status_int=202)
- resp.headers['Location'] = image_ref
+
+ # build location of newly-created image entity if rotation is not zero
+ if rotation > 0:
+ image_id = str(image['id'])
+ image_ref = os.path.join(req.application_url, 'images', image_id)
+ resp.headers['Location'] = image_ref
+
return resp
@wsgi.action('os-migrateLive')