Ask Your Question
0

Include user data in stack creation over API

asked 2015-01-13 11:41:35 -0500

adam__ gravatar image

I am able to create stacks with custom user data information using the python heat client. But when I am creating a stack using the API and sending up my data in JSON format - I seem to be unable to send up the user data in the right format.

If I send it up as a string with newlines like \n eg:

#cloud-config \nfinal_message: "System is up after $UPTIME"

Then once the server is up I can see the message

Userdata empty or not executable: [Errno 8] Exec format error

However if I try to change the user data information into a JSON object/array then I just get a 400 (Bad Request) response from the server when I try to do the POST.

I would appreciate any thoughts as to how this information should be properly formatted.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-10-12 00:51:34 -0500

To know the REST API structure behind for every commands which executed as part of heat client. Then enable --debug option as part of CLI.

heat --debug stack-create teststack -f /tmp/instance.yaml

Below is the USER_DATA structure of 'RAW' type as part of Heat Stack creation

curl -g -i -X POST http://stageopenstack233.ccs.com:8004... -H "X-Auth-Key: xxxxx" -H "X-Auth-User: admin" -H "User-Agent: python-heatclient" -H "Content-Type: application/json" -H "X-Auth-Url: http://192.168.1.233:5000/v2.0" -H "Accept: application/json" -H "X-Auth-Token: {SHA1}5b3dfa3a55b8675d6d4a963185f5c4bde3e690b3" -d '{"files": {}, "disable_rollback": true, "parameters": {}, "stack_name": "jptest", "environment": {}, "template": {"heat_template_version": "2013-05-23", "description": "HOT template to create instance", "resources": {"Create_Instance": {"type": "OS::Nova::Server", "properties": {"user_data_format": "RAW", "name": "teststack", "key_name": "jp", "image": "ubuntu14.04.02-cloud-password-image", "user_data": "apt-get -y update apt-get -y install docker.io apt-get -y install apache2", "flavor": "m1.small", "networks": [{"network": "6baa48a5-cbff-48c0-8dfc-a6a574a79be4"}]}}}}}'

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2015-01-13 11:41:35 -0500

Seen: 718 times

Last updated: Oct 12 '15