Ask Your Question
1

post creation script when launching server through novaclient python bindings?

asked 2014-05-14 07:15:02 -0600

gad0lin gravatar image

updated 2014-05-15 04:23:11 -0600

darragh-oreilly gravatar image

I can specify post creation script in horizon but I don't see a way to specify post script file when launching though nova client.

nova.servers.create(name = name,
                    image = "AMI-abcdefg",
                    flavor = "m1.medium",
                    network = "28dadsadsa9-de6a-413e-a752-c800b86303d4",
                    key_name = "c")

Can I do it automagically by passing some extra user data parameter?

It doesn't look obvious to me how that can be achived by looking on method definition:

 def create(self, name, image, flavor, meta=None, files=None,
           reservation_id=None, min_count=None,
           max_count=None, security_groups=None, userdata=None,
           key_name=None, availability_zone=None,
           block_device_mapping=None, block_device_mapping_v2=None,
           nics=None, scheduler_hints=None,
           config_drive=None, disk_config=None, **kwargs):

I am using grizzly release and nova client api 1.1.

edit retag flag offensive close merge delete

Comments

Hi, I have the same problem too. All I need is to run some script like 'echo'ssss'>/root/ttt.tt' on creation of an instance. Can you please give me appropriate Python code.

Dhana gravatar imageDhana ( 2014-06-09 10:01:23 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
0

answered 2014-05-15 04:20:41 -0600

darragh-oreilly gravatar image

updated 2014-05-15 04:24:25 -0600

I think userdata is the one - see here. You may have to pass a string buffer with the file contents to it. Maybe run nova boot with --debug to see what it does. Or turn on debug on nova-api and see what Horizon does.

edit flag offensive delete link more
0

answered 2014-05-15 03:56:02 -0600

craigtracey gravatar image

Hi,

Yes you can automate a wide variety of things via a package named cloud-init. This package primarily reads from provided user-data (or a variety is other sources), and configures a guest instance accordingly. I wrote a blog post about this done time ago...hopefully this will help you: http://www.scalehorizontally.com/2013...

Let me know if this gets you moving... Best, Craig

edit flag offensive delete link more

Comments

Hi, I have the same problem too. All I need is to run some script like 'echo'ssss'>/root/ttt.tt' on creation of an instance. Can you please give me appropriate Python code.

Dhana gravatar imageDhana ( 2014-06-09 10:01:10 -0600 )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: 2014-05-14 07:15:02 -0600

Seen: 3,327 times

Last updated: May 15 '14