Heat stack creation REST API throws error

asked 2014-10-14 09:56:17 -0500

C Sasi Kanth gravatar image

Hi,

i am getting following error in the heat-api.log when I have tried to create stack using orchestration v1 REST API(/v1/​{tenant_id}​/stacks)...But I am able to create stack from heat stack-create cli command

2014-10-14 12:07:49.610 6964 ERROR root [-] Exception handling resource: preview() takes exactly 3 arguments (2 given)
2014-10-14 12:07:49.611 6964 DEBUG root [-] JSON response : {"explanation": "The server could not comply with the request since\r\nit is either malformed or otherwise incorrect.\r\n", "code": 400, "error": {"message": "The server could not comply with the request since\r", "traceback": "  File \"/usr/lib/python2.7/dist-packages/heat/common/wsgi.py\", line 676, in __call__\n    request, **action_args)\n  File \"/usr/lib/python2.7/dist-packages/heat/common/wsgi.py\", line 746, in dispatch\n    return method(*args, **kwargs)\n  File \"/usr/lib/python2.7/dist-packages/heat/api/openstack/v1/util.py\", line 36, in handle_stack_method\n    return handler(controller, req, **kwargs)\n", "type": "HTTPBadRequest"}, "title": "Bad Request"} to_json /usr/lib/python2.7/dist-packages/heat/common/wsgi.py:577

One of the error says preview() takes exactly 3 arguments (2 given) Based on the documentation I am passing two value "stack-name" and "template"

Here is the heat template

{
  "AWSTemplateFormatVersion" : "2010-09-09",
  "Description" : "My Heat template",
  "Resources" : {
    "server_port" : {
      "Type" : "OS::Neutron::Port",
      "Properties" : {
        "admin_state_up" : "True",
        "network_id" : "a1a46766-d71f-43e8-9dc2-dcae6e7cffab",
        "security_groups" : ["eb01c0cf-c92b-4d4a-809f-a07d6532aa0e"]
      }
    },
    "floating_ip" : {
      "Type" : "OS::Neutron::FloatingIP",
      "Properties" : {
        "floating_network_id" : "c92c5c3e-742e-4e82-b8be-5efe5fa65f8c",
        "port_id" : { "Ref" : "server_port" }
      }
    },
    "server-1" : {
      "Type" : "OS::Nova::Server",
      "Properties" : {
        "name" : "MyHeat-Instance-5",
        "image" : "23d32109-57b1-4a33-98fd-600b9435d15d",
        "flavor": "m1.tiny",
        "networks" : [{
          "port" : { "Ref" : "server_port" }
        }]
      }
    }
  }
}

Python Script:

data = 'stack_name=MyPythonHeatStack&template='+heatTemplate

reqHeader = {"ContentType":"application/json","User-Agent":"python-apiclient","X-Auth-Token":self.token}
data = data.encode("utf-8")
http = urllib3.PoolManager() 
response = http.urlopen('POST', url, headers=reqHeader,body=data).data
{
    "data": data
}
responseData = response.decode("utf-8")

I am not sure which parameter is missing or format of request parameter. I have used the above similar POST request for getting the token from keystone tokens REST API

Can you please point me what could be the issue ?

Thanks, Sasi

edit retag flag offensive close merge delete

Comments

If you run heat --debug stack-create ..., you will see exactly the REST calls that heat-client makes. You can compare these to what you're doing and see where they differ.

larsks gravatar imagelarsks ( 2014-10-14 13:28:20 -0500 )edit