From 9cf1c6f269ac10c2493653c646bbef9271cf7122 Mon Sep 17 00:00:00 2001 From: Zane Bitter Date: Tue, 9 Oct 2012 10:37:01 +0200 Subject: [PATCH] Fix bugs in ReST API stack creation Change-Id: I39277224305465cc951e397f340012563c0f7174 Signed-off-by: Zane Bitter --- heat/api/openstack/v1/stacks.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/heat/api/openstack/v1/stacks.py b/heat/api/openstack/v1/stacks.py index c377af3138..1e529dcb10 100644 --- a/heat/api/openstack/v1/stacks.py +++ b/heat/api/openstack/v1/stacks.py @@ -56,7 +56,7 @@ CREATE_PARAMS = ( ) -def json_parse(self, data, data_type): +def json_parse(data, data_type): try: return json.loads(data) except ValueError: @@ -211,22 +211,25 @@ class StackController(object): """ if PARAM_STACK_NAME not in req.params: raise exc.HTTPBadRequest(explanation=_("No stack name specified")) - stack_name = req.params[PARAMS_STACK_NAME] + stack_name = req.params[PARAM_STACK_NAME] stack_params = get_user_params(req) template = get_template(req) args = get_args(req) try: - identity = self.engine_rpcapi.create_stack(req.context, - stack_name, - template, - stack_params, - args) + result = self.engine_rpcapi.create_stack(req.context, + stack_name, + template, + stack_params, + args) except rpc_common.RemoteError as ex: return self._remote_error(ex) - raise exc.HTTPCreated(location=stack_url(req, identity)) + if 'Description' in result: + raise exc.HTTPBadRequest(explanation=result['Description']) + + raise exc.HTTPCreated(location=stack_url(req, result)) @tenant_local def lookup(self, req, stack_name): @@ -296,6 +299,9 @@ class StackController(object): except rpc_common.RemoteError as ex: return self._remote_error(ex) + if 'Description' in res: + raise exc.HTTPBadRequest(explanation=res['Description']) + raise exc.HTTPAccepted() @identified_stack