Browse Source

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>
changes/71/271/2
Steven Hardy 10 years ago
parent
commit
cd94c31909
  1. 2
      heat/api/v1/__init__.py
  2. 6
      heat/api/v1/stacks.py
  3. 11
      heat/common/wsgi.py

2
heat/api/v1/__init__.py

@ -146,7 +146,7 @@ class API(wsgi.Router):
def action_match(environ, result):
req = Request(environ)
env_action = req.GET.get("Action")
env_action = req.params.get("Action")
return env_action == api_action
return {'function': action_match}

6
heat/api/v1/stacks.py

@ -169,7 +169,11 @@ class StackController(object):
except rpc_common.RemoteError as 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):

11
heat/common/wsgi.py

@ -429,7 +429,9 @@ class JSONResponseSerializer(object):
return obj.isoformat()
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):
response.content_type = 'application/json'
@ -462,8 +464,9 @@ class XMLResponseSerializer(object):
eltree = etree.Element(root)
doc = etree.ElementTree(eltree)
self.object_to_element(data.get(root), eltree)
logging.debug("XML response : %s" % etree.tostring(eltree))
return etree.tostring(eltree)
response = etree.tostring(eltree)
logging.debug("XML response : %s" % response)
return response
def default(self, response, result):
response.content_type = 'application/xml'
@ -512,7 +515,7 @@ class Resource(object):
# would appear that the default response serialization is XML, as
# described in the API docs, but passing a query parameter of
# 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,
action, request)

Loading…
Cancel
Save