]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
heat API : Make CreateStack work with boto
authorSteven Hardy <shardy@redhat.com>
Fri, 29 Jun 2012 12:08:47 +0000 (13:08 +0100)
committerSteven Hardy <shardy@redhat.com>
Fri, 29 Jun 2012 13:20:59 +0000 (14:20 +0100)
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>
heat/api/v1/__init__.py
heat/api/v1/stacks.py
heat/common/wsgi.py

index 609166571093c8234f9e63479114ed1c9a1761f4..8f0efbd4b9b47b4cdd7b653980969a7fbc476600 100644 (file)
@@ -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}
index cf948039047cfab537e4fbe2fb14b5d15a71db12..be8cd8407eff2f415eb7c94c88188169d034c98a 100644 (file)
@@ -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):
 
index 24d0d0cfce1a4871546ae3fc3cdff168b7618065..83db2216faabf7b0f1084e75a1f565d126632bb4 100644 (file)
@@ -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)