Ask Your Question
0

Running a python script in Heat to configure VNF

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

drn gravatar image

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

larsks gravatar image

Hi,

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.

#!/bin/bash
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
0

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

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 http://169.254.169.254/

This should return:

1.0
2007-01-19
2007-03-01
2007-08-29
2007-10-10
2007-12-15
2008-02-01
2008-09-01
2009-04-04

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 http://169.254.169.254/latest/user-data

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

#!/bin/bash
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

Comments

Hi,

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 -0500 )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 -0500 )edit

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-11-24 08:33:10 -0500

Seen: 599 times

Last updated: Nov 25 '15