heat API : Make CreateStack work with boto
Further API rework to make stack creation work via boto - Use webob.request.params not GET, as boto passes POST parameters in body - Wrap CreateStack response in CreateStackResponse as expected by boto - Add API debug for JSON format responses - (second version in stackforge due to long-line fix) ref #125 Change-Id: I347368ee0395a9019fae69a06e45260379ed7722 Signed-off-by: Steven Hardy <shardy@redhat.com>
This commit is contained in:
parent
4fe38c787e
commit
cd94c31909
|
@ -146,7 +146,7 @@ class API(wsgi.Router):
|
||||||
|
|
||||||
def action_match(environ, result):
|
def action_match(environ, result):
|
||||||
req = Request(environ)
|
req = Request(environ)
|
||||||
env_action = req.GET.get("Action")
|
env_action = req.params.get("Action")
|
||||||
return env_action == api_action
|
return env_action == api_action
|
||||||
|
|
||||||
return {'function': action_match}
|
return {'function': action_match}
|
||||||
|
|
|
@ -169,7 +169,11 @@ class StackController(object):
|
||||||
except rpc_common.RemoteError as ex:
|
except rpc_common.RemoteError as ex:
|
||||||
return webob.exc.HTTPBadRequest(str(ex))
|
return webob.exc.HTTPBadRequest(str(ex))
|
||||||
|
|
||||||
return {'CreateStackResult': self._stackid_addprefix(res)}
|
# Note boto expects CreateStackResult wrapped in CreateStackResponse
|
||||||
|
# CreateStackResponse is not mentioned in the aws API docs, so we
|
||||||
|
# need to check against a real AWS response to ensure this is correct
|
||||||
|
return {'CreateStackResponse':
|
||||||
|
{'CreateStackResult': self._stackid_addprefix(res)}}
|
||||||
|
|
||||||
def get_template(self, req):
|
def get_template(self, req):
|
||||||
|
|
||||||
|
|
|
@ -429,7 +429,9 @@ class JSONResponseSerializer(object):
|
||||||
return obj.isoformat()
|
return obj.isoformat()
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
return json.dumps(data, default=sanitizer)
|
response = json.dumps(data, default=sanitizer)
|
||||||
|
logging.debug("JSON response : %s" % response)
|
||||||
|
return response
|
||||||
|
|
||||||
def default(self, response, result):
|
def default(self, response, result):
|
||||||
response.content_type = 'application/json'
|
response.content_type = 'application/json'
|
||||||
|
@ -462,8 +464,9 @@ class XMLResponseSerializer(object):
|
||||||
eltree = etree.Element(root)
|
eltree = etree.Element(root)
|
||||||
doc = etree.ElementTree(eltree)
|
doc = etree.ElementTree(eltree)
|
||||||
self.object_to_element(data.get(root), eltree)
|
self.object_to_element(data.get(root), eltree)
|
||||||
logging.debug("XML response : %s" % etree.tostring(eltree))
|
response = etree.tostring(eltree)
|
||||||
return etree.tostring(eltree)
|
logging.debug("XML response : %s" % response)
|
||||||
|
return response
|
||||||
|
|
||||||
def default(self, response, result):
|
def default(self, response, result):
|
||||||
response.content_type = 'application/xml'
|
response.content_type = 'application/xml'
|
||||||
|
@ -512,7 +515,7 @@ class Resource(object):
|
||||||
# would appear that the default response serialization is XML, as
|
# would appear that the default response serialization is XML, as
|
||||||
# described in the API docs, but passing a query parameter of
|
# described in the API docs, but passing a query parameter of
|
||||||
# ContentType=JSON results in a JSON serialized response...
|
# ContentType=JSON results in a JSON serialized response...
|
||||||
content_type = request.GET.get("ContentType")
|
content_type = request.params.get("ContentType")
|
||||||
|
|
||||||
deserialized_request = self.dispatch(self.deserializer,
|
deserialized_request = self.dispatch(self.deserializer,
|
||||||
action, request)
|
action, request)
|
||||||
|
|
Loading…
Reference in New Issue