Ask Your Question

Running a python script in Heat to configure VNF

asked 2015-11-24 08:33:10 -0600

drn gravatar image

updated 2015-11-25 09:33:59 -0600

larsks gravatar image


I could create networks with VM/VNF's using Heat. I came across a link where we can use scripts to configure the VM on boot up. I used horizon to try boot config. I wrote a simple script to create a file (in post-creation tab - while launching an instance) in cirros on boot up but it shows no effect.

echo "Hello World" > /tmp/test.txt

Could someone please let me know the solution? Also, could someone please share a sample python script for boot config ?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-11-25 09:51:53 -0600

larsks gravatar image

For the user-data script to have any affect on your instance, the image you are booting needs to have tooling installed to fetch and execute that image. For most major distributions (CentOS, Red Hat, Fedora, Ubuntu, etc), this is cloud-init, and is installed on the cloud images for these distributions.

Cirros uses an alternative mechanism, which means that you probably don't want to use it for testing because it will not support the same sort of user-data scripts that larger distributions will support (for example, python isn't available on the cirros image, so you wouldn't be able to test out a python script in any case).

Your simple test ought to work. There are a number of diagnostic steps you can perform to figure out what went awry...

First, check if the metadata service is available. After logging into the cirros instance, try running:

# curl

This should return:


If you get an error response, this suggests that there are probably configuration issues in your openstack environment.

If the above worked, trying fetching the user-data script by running:

# curl

This should return your user-data script, e.g:

echo "Hello World" > /tmp/test.txt

If that worked, see if the cirros tooling fetched it correctly. Run:

# cirros-query get user-data

This should return the same thing.

I suspect that one of the above steps will produce some useful diagnostic information. If you do see any errors, feel free to update your question with the additional information and we'll see if we can get things working.

edit flag offensive delete link more



Thank you so much for your help. I executed the commands you mentioned.First 2 commands executed successfully.. Third command (cirros-query get user-data) gave the output no datasource. Please advice

drn gravatar imagedrn ( 2015-11-26 06:34:16 -0600 )edit

I am facing the same problem with debian based vyatta vrouter. I am using it as a VNF. but user-data does not execute on it as well. Please advice for an alternative if any

drn gravatar imagedrn ( 2015-11-26 09:54:47 -0600 )edit

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2015-11-24 08:33:10 -0600

Seen: 1,041 times

Last updated: Nov 25 '15