[ovirt-users] cloud-init options under python-sdk

Amedeo Salvati amedeo at oscert.net
Tue Jul 22 12:55:31 UTC 2014


hi Juan|guys,

thanks for hints! but unfortunatly it seems wont works, because I've launched vm with this simple code:

action = params.Action(vm=params.VM(initialization=params.Initialization(cloud_init=params.CloudInit(host=params.Host(name="rheltest014")))))
vm.start( action )

but after boot the VM, cloud-init service hasn't set hostname and on cloud-init.log and cloud-init-output.log I cannot find any entry for setting hostname, instead if I use web ui it work's fine...

there are any ways to debug cloud-init jobs?
the params params.Host is right for CloudInit host or is intended for host / hypervisor?

Best regards
Amedeo Salvati


Da: "Juan Hernandez" jhernand at redhat.com
A: "Amedeo Salvati" amedeo at oscert.net, users at ovirt.org
Cc: 
Data: Tue, 22 Jul 2014 12:21:01 +0200
Oggetto: Re: [ovirt-users] cloud-init options under python-sdk


> On 07/22/2014 11:48 AM, Amedeo Salvati wrote:
> > hello guys!
> > 
> > I'm writing some python code to start VMs, and based on operating system
> > (at this moment centos6 nad centos7), I would like to use cloud-init
> > options (available on web ui at run-once) to start them and resetting
> > root password, change hostname and write some configuration files by
> > using yaml semantics, but at this moment I was unable to find a way to
> > do it...
> > 
> > somebody know a way (or could send me some hints) using python-sdk to
> > start A VM and pass to it cloud-init options?
> > 
> > e.g. the portion of code I would like to change is vm.start() under rhel6|7:
> > 
> >             try:
> >                 osVersion = vm.get_os().get_type()
> >                 if (osVersion == "rhel_6x64" or osVersion == "rhel_6" or
> > osVersion == "rhel_7x64") and CLOUDINIT == "yes":
> >                     print "Starting VM: " + vm.name + " with cloud-init
> > options"
> > ---->                    vm.start()              <----------  >                 else:
> >                     print "Starting VM " + vm.name
> >                     vm.start()
> >                 while vmstat != 'down':
> >                     sleep(1)
> >                     vmstat = vm.get_status().state
> >             except Exception, err:
> >                 print "Error on starting VM"
> >                 print err
> > 
> > 
> > Best regards
> > Amedeo Salvati
> > 
> 
> It should be something like this:
> 
>   from ovirtsdk.xml import params
> 
>   action = params.Action(
>     vm=params.VM(
>       initialization=params.Initialization(
>         cloud_init=params.CloudInit(
>           host=params.Host(
>             name="myvm"
>           ),
>           users=...,
>           files=...,
>           ...
>         )
>       )
>     )
>   )
> 
>   vm.start(action)
> 
> 
> -- 
> Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta
> 3ºD, 28016 Madrid, Spain
> Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ovirt.org/pipermail/users/attachments/20140722/e6999935/attachment-0001.html>


More information about the Users mailing list