
--_=__=_XaM3_.1406022513.2A.527548.42.32355.52.42.007.202691555 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable hello guys! =0A=0AI'm writing some python code to start VMs, and based on= operating system (at this moment centos6 nad centos7), I would like to u= se cloud-init options (available on web ui at run-once) to start them and= resetting root password, change hostname and write some configuration fi= les by using yaml semantics, but at this moment I was unable to find a wa= y to do it...=0A=0Asomebody know a way (or could send me some hints) usin= g python-sdk to start A VM and pass to it cloud-init options?=0A=0Ae.g. t= he portion of code I would like to change is vm.start() under rhel6|7:=0A= =0A=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 try= :=0A=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 osVersion =3D vm.get_os().get_type()=0A=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 if (osVersion =3D=3D "rhel_6x64" or osVersion =3D=3D "rhel_6" or osVe= rsion =3D=3D "rhel_7x64") and CLOUDINIT =3D=3D "yes":=0A=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 print "Starting VM: " + vm.name + " with cloud-init= options"=0A----> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 vm.start()=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 <-----= -----=0A=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 else:=0A=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = print "Starting VM " + vm.name=0A=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = vm.start()=0A=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 while vmstat !=3D 'down':=0A=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 sleep(1)=0A=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= vmstat =3D vm.get_status().state=0A=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 except Exception, err:=0A=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pri= nt "Error on starting VM"=0A=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 print err=0A=0A=0ABest rega= rds=0AAmedeo Salvati --_=__=_XaM3_.1406022513.2A.527548.42.32355.52.42.007.202691555 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable =0A<div class=3D"xam_msg_class">=0A<div style=3D"font: normal 13px Arial;= color:rgb(31, 28, 27);">hello guys! <br><br>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 momen= t I was unable to find a way to do it...<br><br>somebody know a way (or c= ould send me some hints) using python-sdk to start A VM and pass to it cl= oud-init options?<br><br>e.g. the portion of code I would like to change = is vm.start() under rhel6|7:<br><br> &= nbsp; try:<br>  = ; osVersion =3D vm.= get_os().get_type()<br> &n= bsp; if (osVersion =3D=3D "rhel_6x64"= or osVersion =3D=3D "rhel_6" or osVersion =3D=3D "rhel_7x64") and CLOUDI= NIT =3D=3D "yes":<br> &nbs= p; print "Sta= rting VM: " + vm.name + " with cloud-init options"<br>----> &nbs= p;  = ; vm.start() &= nbsp; <----------<br> &= nbsp; &n= bsp; else:<br>  = ; print "Starting V= M " + vm.name<br> &n= bsp; vm.start()<br>= &= nbsp; while vmstat !=3D 'down':<br> &n= bsp; &nb= sp; sleep(1)<br> &nb= sp; vms= tat =3D vm.get_status().state<br> &nbs= p; except Exception, err:<br> &n= bsp; pr= int "Error on starting VM"<br> &= nbsp; print err<br><br><br>Best= regards<br>Amedeo Salvati</div>=0A</div>=0A --_=__=_XaM3_.1406022513.2A.527548.42.32355.52.42.007.202691555--

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.

--_=__=_XaM3_.1406033731.2A.648784.42.24684.52.42.007.584362592 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable hi Juan|guys,=0A=0Athanks for hints! but unfortunatly it seems wont works= , because I've launched vm with this simple code:=0A=0Aaction =3D params.= Action(vm=3Dparams.VM(initialization=3Dparams.Initialization(cloud_init=3D= params.CloudInit(host=3Dparams.Host(name=3D"rheltest014")))))=0Avm.start(= action )=0A=0Abut after boot the VM, cloud-init service hasn't set hostn= ame and on cloud-init.log and cloud-init-output.log I cannot find any ent= ry for setting hostname, instead if I use web ui it work's fine...=0A=0At= here are any ways to debug cloud-init jobs?=0Athe params params.Host is r= ight for CloudInit host or is intended for host / hypervisor?=0A=0ABest r= egards=0AAmedeo Salvati=0A=0A=0ADa: "Juan Hernandez" jhernand@redhat.com=0A= A: "Amedeo Salvati" amedeo@oscert.net, users@ovirt.org=0ACc: =0AData: Tue= , 22 Jul 2014 12:21:01 +0200=0AOggetto: Re: [ovirt-users] cloud-init opti= ons under python-sdk=0A=0A=0A> On 07/22/2014 11:48 AM, Amedeo Salvati wro= te:=0A> > hello guys!=0A> > =0A> > I'm writing some python code to start = VMs, and based on operating system=0A> > (at this moment centos6 nad cent= os7), I would like to use cloud-init=0A> > options (available on web ui a= t run-once) to start them and resetting=0A> > root password, change hostn= ame and write some configuration files by=0A> > using yaml semantics, but= at this moment I was unable to find a way to=0A> > do it...=0A> > =0A> >= somebody know a way (or could send me some hints) using python-sdk to=0A= > > start A VM and pass to it cloud-init options?=0A> > =0A> > e.g. the p= ortion of code I would like to change is vm.start() under rhel6|7:=0A> > = =0A> > try:=0A> > osVersion =3D vm.get_os().g= et_type()=0A> > if (osVersion =3D=3D "rhel_6x64" or osVer= sion =3D=3D "rhel_6" or=0A> > osVersion =3D=3D "rhel_7x64") and CLOUDINIT= =3D=3D "yes":=0A> > print "Starting VM: " + vm.name = + " with cloud-init=0A> > options"=0A> > ----> vm.star= t() <---------- > else:=0A> > = print "Starting VM " + vm.name=0A> > vm.start(= )=0A> > while vmstat !=3D 'down':=0A> > = sleep(1)=0A> > vmstat =3D vm.get_status().state=0A= > > except Exception, err:=0A> > print "Error= on starting VM"=0A> > print err=0A> > =0A> > =0A> > Best= regards=0A> > Amedeo Salvati=0A> > =0A> =0A> It should be something like= this:=0A> =0A> from ovirtsdk.xml import params=0A> =0A> action =3D p= arams.Action(=0A> vm=3Dparams.VM(=0A> initialization=3Dparams.I= nitialization(=0A> cloud_init=3Dparams.CloudInit(=0A> h= ost=3Dparams.Host(=0A> name=3D"myvm"=0A> ),=0A> = users=3D...,=0A> files=3D...,=0A> ...=0A> = )=0A> )=0A> )=0A> )=0A> =0A> vm.start(action)=0A> =0A> = =0A> -- =0A> Direcci=C3=B3n Comercial: C/Jose Bardasano Baos, 9, Edif. Go= rbea 3, planta=0A> 3=C2=BAD, 28016 Madrid, Spain=0A> Inscrita en el Reg. = Mercantil de Madrid =E2=80=93 C.I.F. B82657941 - Red Hat S.L. --_=__=_XaM3_.1406033731.2A.648784.42.24684.52.42.007.584362592 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable =0A<div class=3D"xam_msg_class">=0A<div style=3D"font: normal 13px Arial;= color:rgb(31, 28, 27);">hi Juan|guys,<br><br>thanks for hints! but unfor= tunatly it seems wont works, because I've launched vm with this simple co= de:<br><br>action =3D params.Action(vm=3Dparams.VM(initialization=3Dparam= s.Initialization(cloud_init=3Dparams.CloudInit(host=3Dparams.Host(name=3D= "rheltest014")))))<br>vm.start( action )<br><br>but after boot the VM, cl= oud-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 us= e web ui it work's fine...<br><br>there are any ways to debug cloud-init = jobs?<br>the params params.Host is right for CloudInit host or is intende= d for host / hypervisor?<br><br>Best regards<br>Amedeo Salvati<br><br>=0A= <div><span style=3D"font-family:Arial; font-size:11px; color:#5F5F5F;">Da= </span><span style=3D"font-family:Arial; font-size:12px; color:#5F5F5F; p= adding-left:5px;">: "Juan Hernandez" jhernand@redhat.com</span></div>=0A<= div><span style=3D"font-family:Arial; font-size:11px; color:#5F5F5F;">A</= span><span style=3D"font-family:Arial; font-size:12px; color:#5F5F5F; pad= ding-left:5px;">: "Amedeo Salvati" amedeo@oscert.net, users@ovirt.org</sp= an></div>=0A<div><span style=3D"font-family:Arial; font-size:11px; color:= #5F5F5F;">Cc</span><span style=3D"font-family:Arial; font-size:12px; colo= r:#5F5F5F; padding-left:5px;">: </span></div>=0A<div><span style=3D"font-= family:Arial; font-size:11px; color:#5F5F5F;">Data</span><span style=3D"f= ont-family:Arial; font-size:12px; color:#5F5F5F; padding-left:5px;">: Tue= , 22 Jul 2014 12:21:01 +0200</span></div>=0A<div><span style=3D"font-fami= ly:Arial; font-size:11px; color:#5F5F5F;">Oggetto</span><span style=3D"fo= nt-family:Arial; font-size:12px; color:#5F5F5F; padding-left:5px;">: Re: = [ovirt-users] cloud-init options under python-sdk</span></div>=0A<br>=0A<= div>> On 07/22/2014 11:48 AM, Amedeo Salvati wrote:</div><div>> >= ; hello guys!</div><div>> > </div><div>> > I'm writing some p= ython code to start VMs, and based on operating system</div><div>> >= ; (at this moment centos6 nad centos7), I would like to use cloud-init</d= iv><div>> > options (available on web ui at run-once) to start them= and resetting</div><div>> > root password, change hostname and wri= te some configuration files by</div><div>> > using yaml semantics, = but at this moment I was unable to find a way to</div><div>> > do i= t...</div><div>> > </div><div>> > somebody know a way (or cou= ld send me some hints) using python-sdk to</div><div>> > start A VM= and pass to it cloud-init options?</div><div>> > </div><div>> &= gt; e.g. the portion of code I would like to change is vm.start() under r= hel6|7:</div><div>> > </div><div>> > try:</div><d= iv>> > osVersion =3D vm.get_os().get_type()</div><d= iv>> > if (osVersion =3D=3D "rhel_6x64" or osVersio= n =3D=3D "rhel_6" or</div><div>> > osVersion =3D=3D "rhel_7x64") an= d CLOUDINIT =3D=3D "yes":</div><div>> > print "= Starting VM: " + vm.name + " with cloud-init</div><div>> > options"= </div><div>> > ----> vm.start() = <---------- > else:</div><div>> > = print "Starting VM " + vm.name</div><div>> > = vm.start()</div><div>> > while vmstat !=3D = 'down':</div><div>> > sleep(1)</div><div>> &= gt; vmstat =3D vm.get_status().state</div><div>> &= gt; except Exception, err:</div><div>> > = print "Error on starting VM"</div><div>> > print = err</div><div>> > </div><div>> > </div><div>> > Best re= gards</div><div>> > Amedeo Salvati</div><div>> > </div><div>&= gt; </div><div>> It should be something like this:</div><div>> </di= v><div>> from ovirtsdk.xml import params</div><div>> </div><div>&= gt; action =3D params.Action(</div><div>> vm=3Dparams.VM(</div><= div>> initialization=3Dparams.Initialization(</div><div>> = cloud_init=3Dparams.CloudInit(</div><div>> host=3Dparam= s.Host(</div><div>> name=3D"myvm"</div><div>> = ),</div><div>> users=3D...,</div><div>> files=3D= ...,</div><div>> ...</div><div>> )</div><div>>= )</div><div>> )</div><div>> )</div><div>> </div><di= v>> vm.start(action)</div><div>> </div><div>> </div><div>> = -- </div><div>> Direcci=C3=B3n Comercial: C/Jose Bardasano Baos, 9, Ed= if. Gorbea 3, planta</div><div>> 3=C2=BAD, 28016 Madrid, Spain</div><d= iv>> Inscrita en el Reg. Mercantil de Madrid =E2=80=93 C.I.F. B8265794= 1 - Red Hat S.L.</div></div>=0A</div>=0A --_=__=_XaM3_.1406033731.2A.648784.42.24684.52.42.007.584362592--

On 07/22/2014 02:55 PM, Amedeo Salvati wrote:
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
To change the hostname you have to use the "address" property of the "Host" class: host=params.Host( address="myhostname.example.com" ) The "Host" class is used for many things, including CloudInit and hypervisors. But in this context it is just a container for the host name. To debug cloud-init start the VM (with the GUI or with the RESTAPI), then go to the hypervisor where it is actually running, and look for the corresponding qemu-kvm process: # ps -ef | grep qemu-kvm | grep myvm The qemu-kvm command line will have a parameter indicating the file that contains the cloud-init data: -drive file=/var/run/vdsm/payload/...img Copy that file somewhere, then mount it and inspect the content: # cp /var/run/vdsm/payload/...img /tmp/my.img # mount -o loop,ro /tmp/my.img /mnt # find /mnt ... # umount /mnt
Da: "Juan Hernandez" jhernand@redhat.com A: "Amedeo Salvati" amedeo@oscert.net, users@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.
-- 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.

the params params.Host is right for CloudInit host or is intended for= =0A> > host / hypervisor?=0A> > =0A> > Best regards=0A> > Amedeo Salvati=0A= =0A> =0A> To change the hostname you have to use the "address" proper= ty of the=0A> "Host" class:=0A> =0A> host=3Dparams.Host(=0A> addr= ess=3D"myhostname.example.com"=0A> )=0A> =0A> The "Host" class is used = for many things, including CloudInit and=0A> hypervisors. But in this con= text it is just a container for the host name.=0A> =0A> To debug cloud-in= it start the VM (with the GUI or with the RESTAPI),=0A> then go to the hy=
The qemu-kvm command line will have a parameter indicating the file tha= t=0A> contains the cloud-init data:=0A> =0A> -drive file=3D/var/run/vds= m/payload/...img=0A> =0A> Copy that file somewhere, then mount it and ins=
--_=__=_XaM3_.1406037058.2A.600036.42.2016.52.42.007.1017900328 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable many thanks Juan it works!=0A=0Abest regards=0Aa=0A=0A=0A=0ADa: "Juan Her= nandez" jhernand@redhat.com=0AA: "Amedeo Salvati" amedeo@oscert.net, user= s@ovirt.org=0ACc: =0AData: Tue, 22 Jul 2014 15:32:45 +0200=0AOggetto: Re:= [ovirt-users] cloud-init options under python-sdk=0A=0A=0A> On 07/22/201= 4 02:55 PM, Amedeo Salvati wrote:=0A> > hi Juan|guys,=0A> > =0A> > thanks= for hints! but unfortunatly it seems wont works, because I've=0A> > laun= ched vm with this simple code:=0A> > =0A> > action =3D=0A> > params.Actio= n(vm=3Dparams.VM(initialization=3Dparams.Initialization(cloud_init=3Dpara= ms.CloudInit(host=3Dparams.Host(name=3D"rheltest014")))))=0A> > vm.start(= action )=0A> > =0A> > but after boot the VM, cloud-init service hasn't s= et hostname and on=0A> > cloud-init.log and cloud-init-output.log I canno= t find any entry for=0A> > setting hostname, instead if I use web ui it w= ork's fine...=0A> > =0A> > there are any ways to debug cloud-init jobs?=0A= pervisor where it is actually running, and look for the=0A> corresponding= qemu-kvm process:=0A> =0A> # ps -ef | grep qemu-kvm | grep myvm=0A> =0A= pect the content:=0A> =0A> # cp /var/run/vdsm/payload/...img /tmp/my.im= g=0A> # mount -o loop,ro /tmp/my.img /mnt=0A> # find /mnt=0A> ...=0A=
Data: Tue, 22 Jul 2014 12:21:01 +0200=0A> > Oggetto: Re: [ovirt-users= ] cloud-init options under python-sdk=0A> > =0A> >> On 07/22/2014 11:48 A= M, Amedeo Salvati wrote:=0A> >> > hello guys!=0A> >> >=0A> >> > I'm writi= ng some python code to start VMs, and based on operating system=0A> >> > = (at this moment centos6 nad centos7), I would like to use cloud-init=0A> =
options (available on web ui at run-once) to start them and resettin= g=0A> >> > root password, change hostname and write some configuration fi= les by=0A> >> > using yaml semantics, but at this moment I was unable to = find a way to=0A> >> > do it...=0A> >> >=0A> >> > somebody know a way (or= could send me some hints) using python-sdk to=0A> >> > start A VM and pa= ss to it cloud-init options?=0A> >> >=0A> >> > e.g. the portion of code I= would like to change is vm.start() under=0A> > rhel6|7:=0A> >> >=0A> >> =
# umount /mnt=0A> =0A> =0A> > Da: "Juan Hernandez" jhernand@redhat.co= m=0A> > A: "Amedeo Salvati" amedeo@oscert.net, users@ovirt.org=0A> > Cc:=0A= try:=0A> >> > osVersion =3D vm.get_os().get_type()=0A> >> > if (osVersi= on =3D=3D "rhel_6x64" or osVersion =3D=3D "rhel_6" or=0A> >> > osVersion = =3D=3D "rhel_7x64") and CLOUDINIT =3D=3D "yes":=0A> >> > print "Starting = VM: " + vm.name + " with cloud-init=0A> >> > options"=0A> >> > ----> vm.s= tart() <---------- > else:=0A> >> > print "Starting VM " + vm.name=0A> >>= vm.start()=0A> >> > while vmstat !=3D 'down':=0A> >> > sleep(1)=0A> >>= vmstat =3D vm.get_status().state=0A> >> > except Exception, err:=0A> >=
print "Error on starting VM"=0A> >> > print err=0A> >> >=0A> >> >=0A>=
Best regards=0A> >> > Amedeo Salvati=0A> >> >=0A> >>=0A> >> It shou= ld be something like this:=0A> >>=0A> >> from ovirtsdk.xml import params=0A= =0A> >> action =3D params.Action(=0A> >> vm=3Dparams.VM(=0A> >> initi= alization=3Dparams.Initialization(=0A> >> cloud_init=3Dparams.CloudInit(=0A= host=3Dparams.Host(=0A> >> name=3D"myvm"=0A> >> ),=0A> >> users=3D..= .,=0A> >> files=3D...,=0A> >> ...=0A> >> )=0A> >> )=0A> >> )=0A> >> )=0A>= =0A> >> vm.start(action)=0A> >>=0A> >>=0A> >> --=0A> >> Direcci=C3=B3n= Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta=0A> >> 3=C2=BA= D, 28016 Madrid, Spain=0A> >> Inscrita en el Reg. Mercantil de Madrid =E2= =80=93 C.I.F. B82657941 - Red Hat S.L.=0A> =0A> =0A> -- =0A> Direcci=C3=B3= n Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta=0A> 3=C2=BA= D, 28016 Madrid, Spain=0A> Inscrita en el Reg. Mercantil de Madrid =E2=80= =93 C.I.F. B82657941 - Red Hat S.L. --_=__=_XaM3_.1406037058.2A.600036.42.2016.52.42.007.1017900328 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
<span style=3D"font-family:Arial; font-size:12px; color:#5F5F5F; padding= -left:5px;">: Re: [ovirt-users] cloud-init options under python-sdk</span= </div>=0A<br>=0A<div>> On 07/22/2014 02:55 PM, Amedeo Salvati wrote:<= /div><div>> > hi Juan|guys,</div><div>> > </div><div>> >= ; thanks for hints! but unfortunatly it seems wont works, because I've</d= iv><div>> > launched vm with this simple code:</div><div>> > = </div><div>> > action =3D</div><div>> > params.Action(vm=3Dpa= rams.VM(initialization=3Dparams.Initialization(cloud_init=3Dparams.CloudI= nit(host=3Dparams.Host(name=3D"rheltest014")))))</div><div>> > vm.s= tart( action )</div><div>> > </div><div>> > but after boot th= e VM, cloud-init service hasn't set hostname and on</div><div>> > c= loud-init.log and cloud-init-output.log I cannot find any entry for</div>= <div>> > setting hostname, instead if I use web ui it work's fine..= .</div><div>> > </div><div>> > there are any ways to debug cl= oud-init jobs?</div><div>> > the params params.Host is right for Cl= oudInit host or is intended for</div><div>> > host / hypervisor?</d= iv><div>> > </div><div>> > Best regards</div><div>> > A= medeo Salvati</div><div>> > </div><div>> </div><div>> To chan= ge the hostname you have to use the "address" property of the</div><div>&= gt; "Host" class:</div><div>> </div><div>> host=3Dparams.Host(</d= iv><div>> address=3D"myhostname.example.com"</div><div>> )<= /div><div>> </div><div>> The "Host" class is used for many things, = including CloudInit and</div><div>> hypervisors. But in this context i= t is just a container for the host name.</div><div>> </div><div>> T= o debug cloud-init start the VM (with the GUI or with the RESTAPI),</div>= <div>> then go to the hypervisor where it is actually running, and loo= k for the</div><div>> corresponding qemu-kvm process:</div><div>> <= /div><div>> # ps -ef | grep qemu-kvm | grep myvm</div><div>> </di= v><div>> The qemu-kvm command line will have a parameter indicating th= e file that</div><div>> contains the cloud-init data:</div><div>> <= /div><div>> -drive file=3D/var/run/vdsm/payload/...img</div><div>>= ; </div><div>> Copy that file somewhere, then mount it and inspect the= content:</div><div>> </div><div>> # cp /var/run/vdsm/payload/...= img /tmp/my.img</div><div>> # mount -o loop,ro /tmp/my.img /mnt</div= <div>> # find /mnt</div><div>> ...</div><div>> # umount /= mnt</div><div>> </div><div>> </div><div>> > Da: "Juan Hernand= ez" jhernand@redhat.com</div><div>> > A: "Amedeo Salvati" amedeo@os= cert.net, users@ovirt.org</div><div>> > Cc:</div><div>> > Dat= a: Tue, 22 Jul 2014 12:21:01 +0200</div><div>> > Oggetto: Re: [ovir= t-users] cloud-init options under python-sdk</div><div>> > </div><d= iv>> >> On 07/22/2014 11:48 AM, Amedeo Salvati wrote:</div><div>= > >> > hello guys!</div><div>> >> ></div><div>>= ; >> > I'm writing some python code to start VMs, and based on o=
=0A<div class=3D"xam_msg_class">=0A<div style=3D"font: normal 13px Arial;= color:rgb(31, 28, 27);">many thanks Juan it works!<br><br>best regards<b= r>a<br><br><br>=0A<div><span style=3D"font-family:Arial; font-size:11px; = color:#5F5F5F;">Da</span><span style=3D"font-family:Arial; font-size:12px= ; color:#5F5F5F; padding-left:5px;">: "Juan Hernandez" jhernand@redhat.co= m</span></div>=0A<div><span style=3D"font-family:Arial; font-size:11px; c= olor:#5F5F5F;">A</span><span style=3D"font-family:Arial; font-size:12px; = color:#5F5F5F; padding-left:5px;">: "Amedeo Salvati" amedeo@oscert.net, u= sers@ovirt.org</span></div>=0A<div><span style=3D"font-family:Arial; font= -size:11px; color:#5F5F5F;">Cc</span><span style=3D"font-family:Arial; fo= nt-size:12px; color:#5F5F5F; padding-left:5px;">: </span></div>=0A<div><s= pan style=3D"font-family:Arial; font-size:11px; color:#5F5F5F;">Data</spa= n><span style=3D"font-family:Arial; font-size:12px; color:#5F5F5F; paddin= g-left:5px;">: Tue, 22 Jul 2014 15:32:45 +0200</span></div>=0A<div><span = style=3D"font-family:Arial; font-size:11px; color:#5F5F5F;">Oggetto</span= perating system</div><div>> >> > (at this moment centos6 nad = centos7), I would like to use cloud-init</div><div>> >> > opt= ions (available on web ui at run-once) to start them and resetting</div><= div>> >> > root password, change hostname and write some conf= iguration files by</div><div>> >> > using yaml semantics, but= at this moment I was unable to find a way to</div><div>> >> >= ; do it...</div><div>> >> ></div><div>> >> > some= body know a way (or could send me some hints) using python-sdk to</div><d= iv>> >> > start A VM and pass to it cloud-init options?</div>= <div>> >> ></div><div>> >> > e.g. the portion of = code I would like to change is vm.start() under</div><div>> > rhel6= |7:</div><div>> >> ></div><div>> >> > try:</div><= div>> >> > osVersion =3D vm.get_os().get_type()</div><div>>= ; >> > if (osVersion =3D=3D "rhel_6x64" or osVersion =3D=3D "rhe= l_6" or</div><div>> >> > osVersion =3D=3D "rhel_7x64") and CL= OUDINIT =3D=3D "yes":</div><div>> >> > print "Starting VM: " = + vm.name + " with cloud-init</div><div>> >> > options"</div>= <div>> >> > ----> vm.start() <---------- > else:</di= v><div>> >> > print "Starting VM " + vm.name</div><div>> &= gt;> > vm.start()</div><div>> >> > while vmstat !=3D 'd= own':</div><div>> >> > sleep(1)</div><div>> >> > = vmstat =3D vm.get_status().state</div><div>> >> > except Exce= ption, err:</div><div>> >> > print "Error on starting VM"</di= v><div>> >> > print err</div><div>> >> ></div><di= v>> >> ></div><div>> >> > Best regards</div><div>= > >> > Amedeo Salvati</div><div>> >> ></div><div>= > >></div><div>> >> It should be something like this:</= div><div>> >></div><div>> >> from ovirtsdk.xml import p= arams</div><div>> >></div><div>> >> action =3D params.A= ction(</div><div>> >> vm=3Dparams.VM(</div><div>> >> in= itialization=3Dparams.Initialization(</div><div>> >> cloud_init=3D= params.CloudInit(</div><div>> >> host=3Dparams.Host(</div><div>&= gt; >> name=3D"myvm"</div><div>> >> ),</div><div>> >= > users=3D...,</div><div>> >> files=3D...,</div><div>> >= ;> ...</div><div>> >> )</div><div>> >> )</div><div>&= gt; >> )</div><div>> >> )</div><div>> >></div><di= v>> >> vm.start(action)</div><div>> >></div><div>> &= gt;></div><div>> >> --</div><div>> >> Direcci=C3=B3n= Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta</div><div>&g= t; >> 3=C2=BAD, 28016 Madrid, Spain</div><div>> >> Inscrit= a en el Reg. Mercantil de Madrid =E2=80=93 C.I.F. B82657941 - Red Hat S.L= .</div><div>> </div><div>> </div><div>> -- </div><div>> Direc= ci=C3=B3n Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta</di= v><div>> 3=C2=BAD, 28016 Madrid, Spain</div><div>> Inscrita en el R= eg. Mercantil de Madrid =E2=80=93 C.I.F. B82657941 - Red Hat S.L.</div></= div>=0A</div>=0A --_=__=_XaM3_.1406037058.2A.600036.42.2016.52.42.007.1017900328--

--_=__=_XaM3_.1406119165.2A.938030.42.22058.52.42.007.1270689716 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable hello Juan|guys,=0A=0AI still have problems with cloud-init options on py= thon-sdk... now I'm trying to reset root password and according to xml av= ailable at http://www.ovirt.org/Features/Cloud-Init_Integration and speci= fically for user/pw:=0A=0A...=0A<users>=0A=C2=A0 <user>=0A=C2=A0=C2=A0=C2= =A0 <user_name>root</user_name>=0A=C2=A0=C2=A0=C2=A0 <password>myPass</pa= ssword>=0A=C2=A0 </user>=0A</users>=0A...=0A=0AI've changed action object= with this example:=0A=0Aaction =3D params.Action(=0A=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 vm=3Dparams.VM(=0A=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= initialization=3Dparams.Initialization(=0A=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 cloud_init=3Dparams.CloudInit(=0A=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 host=3Dparams.Host(address=3D"rheltest025"),=0A= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 users=3Dpara= ms.Users(=0A=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 user=3Dparams.User(user_name=3D"root", password=3D"= pippo")=0A=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 )=0A=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 )=0A=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 )=0A=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = )=0A=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 )=0A= =0Abut when i try to start a vm I got this error: "TypeError: 'User' obje= ct is not iterable"=0A=0Asomebody has some hints for resetting root passw= ord?=0A=0ABest regards=0AAmedeo Salvati=0A=0A=0A=0ADa: "Amedeo Salvati" a= medeo@oscert.net=0AA: jhernand@redhat.com=0ACc: users@ovirt.org=0AData: T= ue, 22 Jul 2014 15:50:58 +0200=0AOggetto: Re: [ovirt-users] cloud-init op= tions under python-sdk=0A=0A=0A=0A=0A=0A=0A> many thanks Juan it works!=0A= =0A> best regards=0A> a=0A=0A=0A=0A> Da: "Juan Hernandez" jhernand@redhat= .com=0A> A: "Amedeo Salvati" amedeo@oscert.net, users@ovirt.org=0A> Cc: =0A= > Data: Tue, 22 Jul 2014 15:32:45 +0200=0A> Oggetto: Re: [ovirt-users] cl= oud-init options under python-sdk=0A=0A=0A> > On 07/22/2014 02:55 PM, Ame= deo Salvati wrote:=0A> > > hi Juan|guys,=0A> > > =0A> > > thanks for hint= s! but unfortunatly it seems wont works, because I've=0A> > > launched vm= with this simple code:=0A> > > =0A> > > action =3D=0A> > > params.Action= (vm=3Dparams.VM(initialization=3Dparams.Initialization(cloud_init=3Dparam= s.CloudInit(host=3Dparams.Host(name=3D"rheltest014")))))=0A> > > vm.start= ( action )=0A> > > =0A> > > but after boot the VM, cloud-init service has= n't set hostname and on=0A> > > cloud-init.log and cloud-init-output.log = I cannot find any entry for=0A> > > setting hostname, instead if I use we= b ui it work's fine...=0A> > > =0A> > > there are any ways to debug cloud= -init jobs?=0A> > > the params params.Host is right for CloudInit host or= is intended for=0A> > > host / hypervisor?=0A> > > =0A> > > Best regards= =0A> > > Amedeo Salvati=0A> > > =0A> > =0A> > To change the hostname you = have to use the "address" property of the=0A> > "Host" class:=0A> > =0A> = > host=3Dparams.Host(=0A> > address=3D"myhostname.example.com"=0A= > > )=0A> > =0A> > The "Host" class is used for many things, including = CloudInit and=0A> > hypervisors. But in this context it is just a contain= er for the host name.=0A> > =0A> > To debug cloud-init start the VM (with= the GUI or with the RESTAPI),=0A> > then go to the hypervisor where it i= s actually running, and look for the=0A> > corresponding qemu-kvm process= :=0A> > =0A> > # ps -ef | grep qemu-kvm | grep myvm=0A> > =0A> > The qe= mu-kvm command line will have a parameter indicating the file that=0A> > = contains the cloud-init data:=0A> > =0A> > -drive file=3D/var/run/vdsm/= payload/...img=0A> > =0A> > Copy that file somewhere, then mount it and i= nspect the content:=0A> > =0A> > # cp /var/run/vdsm/payload/...img /tmp= /my.img=0A> > # mount -o loop,ro /tmp/my.img /mnt=0A> > # find /mnt=0A= > > ...=0A> > # umount /mnt=0A> > =0A> > =0A> > > Da: "Juan Hernandez= " jhernand@redhat.com=0A> > > A: "Amedeo Salvati" amedeo@oscert.net, user= s@ovirt.org=0A> > > Cc:=0A> > > Data: Tue, 22 Jul 2014 12:21:01 +0200=0A>= > > Oggetto: Re: [ovirt-users] cloud-init options under python-sdk=0A> >= > =0A> > >> On 07/22/2014 11:48 AM, Amedeo Salvati wrote:=0A> > >> > hel= lo guys!=0A> > >> >=0A> > >> > I'm writing some python code to start VMs,= and based on operating system=0A> > >> > (at this moment centos6 nad cen= tos7), I would like to use cloud-init=0A> > >> > options (available on we= b ui at run-once) to start them and resetting=0A> > >> > root password, c= hange hostname and write some configuration files by=0A> > >> > using yam= l semantics, but at this moment I was unable to find a way to=0A> > >> > = do it...=0A> > >> >=0A> > >> > somebody know a way (or could send me some= hints) using python-sdk to=0A> > >> > start A VM and pass to it cloud-in= it options?=0A> > >> >=0A> > >> > e.g. the portion of code I would like t= o change is vm.start() under=0A> > > rhel6|7:=0A> > >> >=0A> > >> > try:=0A= > > >> > osVersion =3D vm.get_os().get_type()=0A> > >> > if (osVersion =3D= =3D "rhel_6x64" or osVersion =3D=3D "rhel_6" or=0A> > >> > osVersion =3D=3D= "rhel_7x64") and CLOUDINIT =3D=3D "yes":=0A> > >> > print "Starting VM: = " + vm.name + " with cloud-init=0A> > >> > options"=0A> > >> > ----> vm.s= tart() <---------- > else:=0A> > >> > print "Starting VM " + vm.name=0A> = > >> > vm.start()=0A> > >> > while vmstat !=3D 'down':=0A> > >> > sleep(1= )=0A> > >> > vmstat =3D vm.get_status().state=0A> > >> > except Exception= , err:=0A> > >> > print "Error on starting VM"=0A> > >> > print err=0A> >= >> >=0A> > >> >=0A> > >> > Best regards=0A> > >> > Amedeo Salvati=0A> > = >> >=0A> > >>=0A> > >> It should be something like this:=0A> > >>=0A> > >= > from ovirtsdk.xml import params=0A> > >>=0A> > >> action =3D params.Act= ion(=0A> > >> vm=3Dparams.VM(=0A> > >> initialization=3Dparams.Initializa= tion(=0A> > >> cloud_init=3Dparams.CloudInit(=0A> > >> host=3Dparams.Host= (=0A> > >> name=3D"myvm"=0A> > >> ),=0A> > >> users=3D...,=0A> > >> files= =3D...,=0A> > >> ...=0A> > >> )=0A> > >> )=0A> > >> )=0A> > >> )=0A> > >>= =0A> > >> vm.start(action)=0A> > >>=0A> > >>=0A> > >> --=0A> > >> Direcci= =C3=B3n Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta=0A> >= >> 3=C2=BAD, 28016 Madrid, Spain=0A> > >> Inscrita en el Reg. Mercantil = de Madrid =E2=80=93 C.I.F. B82657941 - Red Hat S.L.=0A> > =0A> > =0A> > -= - =0A> > Direcci=C3=B3n Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea= 3, planta=0A> > 3=C2=BAD, 28016 Madrid, Spain=0A> > Inscrita en el Reg. = Mercantil de Madrid =E2=80=93 C.I.F. B82657941 - Red Hat S.L.=0A=0A=0A=0A= --_=__=_XaM3_.1406119165.2A.938030.42.22058.52.42.007.1270689716 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable =0A<div class=3D"xam_msg_class">=0A<div style=3D"font: normal 13px Arial;= color:rgb(31, 28, 27);">hello Juan|guys,<br><br>I still have problems wi= th cloud-init options on python-sdk... now I'm trying to reset root passw= ord and according to xml available at http://www.ovirt.org/Features/Cloud= -Init_Integration and specifically for user/pw:<br><br>...<br><users&g= t;<br> <user><br> <user_name>root<= /user_name><br> <password>myPass</password&= gt;<br> </user><br></users><br>...<br><br>I've changed = action object with this example:<br><br>action =3D params.Action(<br>&nbs= p;  = ; vm=3Dparams= .VM(<br>  = ; = initialization=3Dparams.Initialization(<br> = ; = &= nbsp; cloud_init=3Dparams.CloudInit(<br>&nb= sp; &nbs= p;  = ; host=3Dpara= ms.Host(address=3D"rheltest025"),<br> = &= nbsp; &n= bsp; users=3Dparams.Users(<br> &= nbsp; &n= bsp; &nb= sp; use= r=3Dparams.User(user_name=3D"root", password=3D"pippo")<br> &n= bsp; &nb= sp; &nbs= p;  = ; )<br> = &= nbsp; )= <br> &nb= sp; &nbs= p; )<br>  = ; = )<br>&= nbsp; &n= bsp; )<br><br= >but when i try to start a vm I got this error: "TypeError: 'User' object= is not iterable"<br><br>somebody has some hints for resetting root passw= ord?<br><br>Best regards<br>Amedeo Salvati<br><br><br>=0A<div><span style= =3D"font-family:Arial; font-size:11px; color:#5F5F5F;">Da</span><span sty= le=3D"font-family:Arial; font-size:12px; color:#5F5F5F; padding-left:5px;= ">: "Amedeo Salvati" amedeo@oscert.net</span></div>=0A<div><span style=3D= "font-family:Arial; font-size:11px; color:#5F5F5F;">A</span><span style=3D= "font-family:Arial; font-size:12px; color:#5F5F5F; padding-left:5px;">: j= hernand@redhat.com</span></div>=0A<div><span style=3D"font-family:Arial; = font-size:11px; color:#5F5F5F;">Cc</span><span style=3D"font-family:Arial= ; font-size:12px; color:#5F5F5F; padding-left:5px;">: users@ovirt.org</sp= an></div>=0A<div><span style=3D"font-family:Arial; font-size:11px; color:= #5F5F5F;">Data</span><span style=3D"font-family:Arial; font-size:12px; co= lor:#5F5F5F; padding-left:5px;">: Tue, 22 Jul 2014 15:50:58 +0200</span><= /div>=0A<div><span style=3D"font-family:Arial; font-size:11px; color:#5F5= F5F;">Oggetto</span><span style=3D"font-family:Arial; font-size:12px; col= or:#5F5F5F; padding-left:5px;">: Re: [ovirt-users] cloud-init options und= er python-sdk</span></div>=0A<br>=0A=0A<div class=3D"xam_msg_class">=0A=0A= <div class=3D"xam_msg_class">=0A<div style=3D"font: normal 13px Arial; co= lor:rgb(31, 28, 27);">> many thanks Juan it works!<br><br>> best re= gards<br>> a<br><br><br>=0A<div><span style=3D"font-family:Arial; font= -size:11px; color:#5F5F5F;">> Da</span><span style=3D"font-family:Aria= l; font-size:12px; color:#5F5F5F; padding-left:5px;">: "Juan Hernandez" j= hernand@redhat.com</span></div>=0A<div><span style=3D"font-family:Arial; = font-size:11px; color:#5F5F5F;">> A</span><span style=3D"font-family:A= rial; font-size:12px; color:#5F5F5F; padding-left:5px;">: "Amedeo Salvati= " amedeo@oscert.net, users@ovirt.org</span></div>=0A<div><span style=3D"f= ont-family:Arial; font-size:11px; color:#5F5F5F;">> Cc</span><span sty= le=3D"font-family:Arial; font-size:12px; color:#5F5F5F; padding-left:5px;= ">: </span></div>=0A<div><span style=3D"font-family:Arial; font-size:11px= ; color:#5F5F5F;">> Data</span><span style=3D"font-family:Arial; font-= size:12px; color:#5F5F5F; padding-left:5px;">: Tue, 22 Jul 2014 15:32:45 = +0200</span></div>=0A<div><span style=3D"font-family:Arial; font-size:11p= x; color:#5F5F5F;">> Oggetto</span><span style=3D"font-family:Arial; f= ont-size:12px; color:#5F5F5F; padding-left:5px;">: Re: [ovirt-users] clou= d-init options under python-sdk</span></div>=0A<br>=0A<div>> > On 0= 7/22/2014 02:55 PM, Amedeo Salvati wrote:</div><div>> > > hi Jua= n|guys,</div><div>> > > </div><div>> > > thanks for hin= ts! but unfortunatly it seems wont works, because I've</div><div>> >= ; > launched vm with this simple code:</div><div>> > > </div>= <div>> > > action =3D</div><div>> > > params.Action(vm=3D= params.VM(initialization=3Dparams.Initialization(cloud_init=3Dparams.Clou= dInit(host=3Dparams.Host(name=3D"rheltest014")))))</div><div>> > &g= t; vm.start( action )</div><div>> > > </div><div>> > > = but after boot the VM, cloud-init service hasn't set hostname and on</div= ><div>> > > cloud-init.log and cloud-init-output.log I cannot fi= nd any entry for</div><div>> > > setting hostname, instead if I = use web ui it work's fine...</div><div>> > > </div><div>> >= ; > there are any ways to debug cloud-init jobs?</div><div>> > &= gt; the params params.Host is right for CloudInit host or is intended for= </div><div>> > > host / hypervisor?</div><div>> > > </d= iv><div>> > > Best regards</div><div>> > > Amedeo Salva= ti</div><div>> > > </div><div>> > </div><div>> > To = change the hostname you have to use the "address" property of the</div><d= iv>> > "Host" class:</div><div>> > </div><div>> > hos= t=3Dparams.Host(</div><div>> > address=3D"myhostname.example.= com"</div><div>> > )</div><div>> > </div><div>> > The= "Host" class is used for many things, including CloudInit and</div><div>= > > hypervisors. But in this context it is just a container for the= host name.</div><div>> > </div><div>> > To debug cloud-init = start the VM (with the GUI or with the RESTAPI),</div><div>> > then= go to the hypervisor where it is actually running, and look for the</div= ><div>> > corresponding qemu-kvm process:</div><div>> > </div= ><div>> > # ps -ef | grep qemu-kvm | grep myvm</div><div>> >= ; </div><div>> > The qemu-kvm command line will have a parameter in= dicating the file that</div><div>> > contains the cloud-init data:<= /div><div>> > </div><div>> > -drive file=3D/var/run/vdsm/pa= yload/...img</div><div>> > </div><div>> > Copy that file some= where, then mount it and inspect the content:</div><div>> > </div><= div>> > # cp /var/run/vdsm/payload/...img /tmp/my.img</div><div>&= gt; > # mount -o loop,ro /tmp/my.img /mnt</div><div>> > # fi= nd /mnt</div><div>> > ...</div><div>> > # umount /mnt</di= v><div>> > </div><div>> > </div><div>> > > Da: "Juan= Hernandez" jhernand@redhat.com</div><div>> > > A: "Amedeo Salva= ti" amedeo@oscert.net, users@ovirt.org</div><div>> > > Cc:</div>= <div>> > > Data: Tue, 22 Jul 2014 12:21:01 +0200</div><div>> = > > Oggetto: Re: [ovirt-users] cloud-init options under python-sdk<= /div><div>> > > </div><div>> > >> On 07/22/2014 11:4= 8 AM, Amedeo Salvati wrote:</div><div>> > >> > hello guys!= </div><div>> > >> ></div><div>> > >> > I'm = writing some python code to start VMs, and based on operating system</div= ><div>> > >> > (at this moment centos6 nad centos7), I wou= ld like to use cloud-init</div><div>> > >> > options (avai= lable on web ui at run-once) to start them and resetting</div><div>> &= gt; >> > root password, change hostname and write some configura= tion files by</div><div>> > >> > using yaml semantics, but= at this moment I was unable to find a way to</div><div>> > >>= ; > do it...</div><div>> > >> ></div><div>> > >= ;> > somebody know a way (or could send me some hints) using python= -sdk to</div><div>> > >> > start A VM and pass to it cloud= -init options?</div><div>> > >> ></div><div>> > >= > > e.g. the portion of code I would like to change is vm.start() u= nder</div><div>> > > rhel6|7:</div><div>> > >> ><= /div><div>> > >> > try:</div><div>> > >> > = osVersion =3D vm.get_os().get_type()</div><div>> > >> > if= (osVersion =3D=3D "rhel_6x64" or osVersion =3D=3D "rhel_6" or</div><div>= > > >> > osVersion =3D=3D "rhel_7x64") and CLOUDINIT =3D=3D= "yes":</div><div>> > >> > print "Starting VM: " + vm.name= + " with cloud-init</div><div>> > >> > options"</div><div= >> > >> > ----> vm.start() <---------- > else:</d= iv><div>> > >> > print "Starting VM " + vm.name</div><div>= > > >> > vm.start()</div><div>> > >> > whil= e vmstat !=3D 'down':</div><div>> > >> > sleep(1)</div><di= v>> > >> > vmstat =3D vm.get_status().state</div><div>>= > >> > except Exception, err:</div><div>> > >> &= gt; print "Error on starting VM"</div><div>> > >> > print = err</div><div>> > >> ></div><div>> > >> ></= div><div>> > >> > Best regards</div><div>> > >>= ; > Amedeo Salvati</div><div>> > >> ></div><div>> &g= t; >></div><div>> > >> It should be something like this= :</div><div>> > >></div><div>> > >> from ovirtsdk= .xml import params</div><div>> > >></div><div>> > >&= gt; action =3D params.Action(</div><div>> > >> vm=3Dparams.VM= (</div><div>> > >> initialization=3Dparams.Initialization(</d= iv><div>> > >> cloud_init=3Dparams.CloudInit(</div><div>> = > >> host=3Dparams.Host(</div><div>> > >> name=3D"my= vm"</div><div>> > >> ),</div><div>> > >> users=3D= ...,</div><div>> > >> files=3D...,</div><div>> > >&g= t; ...</div><div>> > >> )</div><div>> > >> )</div= ><div>> > >> )</div><div>> > >> )</div><div>> = > >></div><div>> > >> vm.start(action)</div><div>>= ; > >></div><div>> > >></div><div>> > >>= --</div><div>> > >> Direcci=C3=B3n Comercial: C/Jose Bardasa= no Baos, 9, Edif. Gorbea 3, planta</div><div>> > >> 3=C2=BAD,= 28016 Madrid, Spain</div><div>> > >> Inscrita en el Reg. Mer= cantil de Madrid =E2=80=93 C.I.F. B82657941 - Red Hat S.L.</div><div>>= > </div><div>> > </div><div>> > -- </div><div>> > D= irecci=C3=B3n Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta= </div><div>> > 3=C2=BAD, 28016 Madrid, Spain</div><div>> > In= scrita en el Reg. Mercantil de Madrid =E2=80=93 C.I.F. B82657941 - Red Ha= t S.L.</div></div>=0A</div>=0A=0A</div>=0A</div>=0A</div>=0A --_=__=_XaM3_.1406119165.2A.938030.42.22058.52.42.007.1270689716--

On 07/23/2014 02:39 PM, Amedeo Salvati wrote:
hello Juan|guys,
I still have problems with cloud-init options on python-sdk... now I'm trying to reset root password and according to xml available at http://www.ovirt.org/Features/Cloud-Init_Integration and specifically for user/pw:
... <users> <user> <user_name>root</user_name> <password>myPass</password> </user> </users> ...
I've changed action object with this example:
action = params.Action( vm=params.VM( initialization=params.Initialization( cloud_init=params.CloudInit( host=params.Host(address="rheltest025"), users=params.Users(
user=params.User(user_name="root", password="pippo")
Try to use a list here: user=[parms.User(...)]
) ) ) ) )
but when i try to start a vm I got this error: "TypeError: 'User' object is not iterable"
somebody has some hints for resetting root password?
Best regards Amedeo Salvati
Da: "Amedeo Salvati" amedeo@oscert.net A: jhernand@redhat.com Cc: users@ovirt.org Data: Tue, 22 Jul 2014 15:50:58 +0200 Oggetto: Re: [ovirt-users] cloud-init options under python-sdk
many thanks Juan it works!
best regards a
Da: "Juan Hernandez" jhernand@redhat.com A: "Amedeo Salvati" amedeo@oscert.net, users@ovirt.org Cc: Data: Tue, 22 Jul 2014 15:32:45 +0200 Oggetto: Re: [ovirt-users] cloud-init options under python-sdk
On 07/22/2014 02:55 PM, Amedeo Salvati wrote:
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
To change the hostname you have to use the "address" property of the "Host" class:
host=params.Host( address="myhostname.example.com" )
The "Host" class is used for many things, including CloudInit and hypervisors. But in this context it is just a container for the host name.
To debug cloud-init start the VM (with the GUI or with the RESTAPI), then go to the hypervisor where it is actually running, and look for the corresponding qemu-kvm process:
# ps -ef | grep qemu-kvm | grep myvm
The qemu-kvm command line will have a parameter indicating the file that contains the cloud-init data:
-drive file=/var/run/vdsm/payload/...img
Copy that file somewhere, then mount it and inspect the content:
# cp /var/run/vdsm/payload/...img /tmp/my.img # mount -o loop,ro /tmp/my.img /mnt # find /mnt ... # umount /mnt
Da: "Juan Hernandez" jhernand@redhat.com A: "Amedeo Salvati" amedeo@oscert.net, users@ovirt.org Cc: Data: Tue, 22 Jul 2014 12:21:01 +0200 Oggetto: Re: [ovirt-users] cloud-init options under python-sdk
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
On 07/22/2014 11:48 AM, Amedeo Salvati wrote: 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.
-- 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.
-- 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.

...=0A> > =0A> > =0A> > root=0A> > myPass=0A> > =0A> > =0A= ...=0A> > =0A> > I've changed action object with this example:=0A> > = =0A> > action =3D params.Action(=0A> > vm=3Dparam= s.VM(=0A> > initialization=3Dparams.Initializ= ation(=0A> > cloud_init=3Dparams.CloudIni= t(=0A> > host=3Dparams.Host(address=3D= "rheltest025"),=0A> > users=3Dparams.= Users(=0A> > =0A> > user=3Dparams.= User(user_name=3D"root", password=3D"pippo")=0A> =0A> Try to use a list h= ere:=0A> =0A> user=3D[parms.User(...)]=0A> =0A> > = )=0A> > )=0A> > = )=0A> > )=0A> >= )=0A> > =0A> > but when i try to start a vm I go= t this error: "TypeError: 'User' object=0A> > is not iterable"=0A> > =0A>= somebody has some hints for resetting root password?=0A> > =0A> > Best= regards=0A> > Amedeo Salvati=0A> > =0A> > =0A> > Da: "Amedeo Salvati" am= edeo@oscert.net=0A> > A: jhernand@redhat.com=0A> > Cc: users@ovirt.org=0A= Data: Tue, 22 Jul 2014 15:50:58 +0200=0A> > Oggetto: Re: [ovirt-users= ] cloud-init options under python-sdk=0A> > =0A> >> many thanks Juan it w= orks!=0A> > =0A> >> best regards=0A> >> a=0A> > =0A> > =0A> >> Da: "Juan = Hernandez" jhernand@redhat.com=0A> >> A: "Amedeo Salvati" amedeo@oscert.n= et, users@ovirt.org=0A> >> Cc:=0A> >> Data: Tue, 22 Jul 2014 15:32:45 +02= 00=0A> >> Oggetto: Re: [ovirt-users] cloud-init options under python-sdk=0A= =0A> >> > On 07/22/2014 02:55 PM, Amedeo Salvati wrote:=0A> >> > > hi= Juan|guys,=0A> >> > >=0A> >> > > thanks for hints! but unfortunatly it s= eems wont works, because I've=0A> >> > > launched vm with this simple cod= e:=0A> >> > >=0A> >> > > action =3D=0A> >> > >=0A> > params.Action(vm=3Dp= arams.VM(initialization=3Dparams.Initialization(cloud_init=3Dparams.Cloud= Init(host=3Dparams.Host(name=3D"rheltest014")))))=0A> >> > > vm.start( ac= tion )=0A> >> > >=0A> >> > > but after boot the VM, cloud-init service ha= sn't set hostname and on=0A> >> > > cloud-init.log and cloud-init-output.= log I cannot find any entry for=0A> >> > > setting hostname, instead if I= use web ui it work's fine...=0A> >> > >=0A> >> > > there are any ways to= debug cloud-init jobs?=0A> >> > > the params params.Host is right for Cl= oudInit host or is intended for=0A> >> > > host / hypervisor?=0A> >> > >=0A=
Best regards=0A> >> > > Amedeo Salvati=0A> >> > >=0A> >> >=0A> >= To change the hostname you have to use the "address" property of the=0A= "Host" class:=0A> >> >=0A> >> > host=3Dparams.Host(=0A> >> > addre= ss=3D"myhostname.example.com"=0A> >> > )=0A> >> >=0A> >> > The "Host" cla= ss is used for many things, including CloudInit and=0A> >> > hypervisors.= But in this context it is just a container for the host=0A> > name.=0A> = =0A> >> > To debug cloud-init start the VM (with the GUI or with the = RESTAPI),=0A> >> > then go to the hypervisor where it is actually running= , and look for the=0A> >> > corresponding qemu-kvm process:=0A> >> >=0A> = # ps -ef | grep qemu-kvm | grep myvm=0A> >> >=0A> >> > The qemu-kvm = command line will have a parameter indicating the file that=0A> >> > cont= ains the cloud-init data:=0A> >> >=0A> >> > -drive file=3D/var/run/vdsm/p= ayload/...img=0A> >> >=0A> >> > Copy that file somewhere, then mount it a= nd inspect the content:=0A> >> >=0A> >> > # cp /var/run/vdsm/payload/...i= mg /tmp/my.img=0A> >> > # mount -o loop,ro /tmp/my.img /mnt=0A> >> > # fi= nd /mnt=0A> >> > ...=0A> >> > # umount /mnt=0A> >> >=0A> >> >=0A> >> > > = Da: "Juan Hernandez" jhernand@redhat.com=0A> >> > > A: "Amedeo Salvati" a= medeo@oscert.net, users@ovirt.org=0A> >> > > Cc:=0A> >> > > Data: Tue, 22= Jul 2014 12:21:01 +0200=0A> >> > > Oggetto: Re: [ovirt-users] cloud-init=
I'm writing some python code to start VMs, and based on=0A> > operatin= g system=0A> >> > >> > (at this moment centos6 nad centos7), I would like= to use=0A> > cloud-init=0A> >> > >> > options (available on web ui at ru= n-once) to start them and=0A> > resetting=0A> >> > >> > root password, ch= ange hostname and write some configuration=0A> > files by=0A> >> > >> > u= sing yaml semantics, but at this moment I was unable to find a=0A> > way = to=0A> >> > >> > do it...=0A> >> > >> >=0A> >> > >> > somebody know a way= (or could send me some hints) using=0A> > python-sdk to=0A> >> > >> > st= art A VM and pass to it cloud-init options?=0A> >> > >> >=0A> >> > >> > e= .g. the portion of code I would like to change is vm.start() under=0A> >>=
rhel6|7:=0A> >> > >> >=0A> >> > >> > try:=0A> >> > >> > osVersion =3D= vm.get_os().get_type()=0A> >> > >> > if (osVersion =3D=3D "rhel_6x64" or= osVersion =3D=3D "rhel_6" or=0A> >> > >> > osVersion =3D=3D "rhel_7x64")= and CLOUDINIT =3D=3D "yes":=0A> >> > >> > print "Starting VM: " + vm.nam= e + " with cloud-init=0A> >> > >> > options"=0A> >> > >> > ----> vm.start= () <---------- > else:=0A> >> > >> > print "Starting VM " + vm.name=0A> >=
vm.start()=0A> >> > >> > while vmstat !=3D 'down':=0A> >> > >> >= sleep(1)=0A> >> > >> > vmstat =3D vm.get_status().state=0A> >> > >> > ex= cept Exception, err:=0A> >> > >> > print "Error on starting VM"=0A> >> > = print err=0A> >> > >> >=0A> >> > >> >=0A> >> > >> > Best regards=0A>=
Amedeo Salvati=0A> >> > >> >=0A> >> > >>=0A> >> > >> It should= be something like this:=0A> >> > >>=0A> >> > >> from ovirtsdk.xml import=
--_=__=_XaM3_.1406124038.2A.738213.42.5125.52.42.007.117871013 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable thanks! =0A=0Abest regards=0Aa=0A=0A=0ADa: "Juan Hernandez" jhernand@redh= at.com=0AA: "Amedeo Salvati" amedeo@oscert.net, users@ovirt.org=0ACc: =0A= Data: Wed, 23 Jul 2014 14:44:57 +0200=0AOggetto: Re: [ovirt-users] cloud-= init options under python-sdk=0A=0A=0A> On 07/23/2014 02:39 PM, Amedeo Sa= lvati wrote:=0A> > hello Juan|guys,=0A> > =0A> > I still have problems wi= th cloud-init options on python-sdk... now I'm=0A> > trying to reset root= password and according to xml available at=0A> > http://www.ovirt.org/Fe= atures/Cloud-Init_Integration and specifically=0A> > for user/pw:=0A> > =0A= options under python-sdk=0A> >> > >=0A> >> > >> On 07/22/2014 11:48 AM, = Amedeo Salvati wrote:=0A> >> > >> > hello guys!=0A> >> > >> >=0A> >> > >>= params=0A> >> > >>=0A> >> > >> action =3D params.Action(=0A> >> > >> vm=3D= params.VM(=0A> >> > >> initialization=3Dparams.Initialization(=0A> >> > >=
cloud_init=3Dparams.CloudInit(=0A> >> > >> host=3Dparams.Host(=0A> >> >=
name=3D"myvm"=0A> >> > >> ),=0A> >> > >> users=3D...,=0A> >> > >> fil= es=3D...,=0A> >> > >> ...=0A> >> > >> )=0A> >> > >> )=0A> >> > >> )=0A> >=
)=0A> >> > >>=0A> >> > >> vm.start(action)=0A> >> > >>=0A> >> > >>= =0A> >> > >> --=0A> >> > >> Direcci=C3=B3n Comercial: C/Jose Bardasano Ba= os, 9, Edif. Gorbea 3, planta=0A> >> > >> 3=C2=BAD, 28016 Madrid, Spain=0A=
Inscrita en el Reg. Mercantil de Madrid =E2=80=93 C.I.F. B82657= 941 - Red=0A> > Hat S.L.=0A> >> >=0A> >> >=0A> >> > --=0A> >> > Direcci=C3= =B3n Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta=0A> >> >= 3=C2=BAD, 28016 Madrid, Spain=0A> >> > Inscrita en el Reg. Mercantil de = Madrid =E2=80=93 C.I.F. B82657941 - Red Hat=0A> > S.L.=0A> =0A> =0A> -- =0A= Direcci=C3=B3n Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, pla= nta=0A> 3=C2=BAD, 28016 Madrid, Spain=0A> Inscrita en el Reg. Mercantil d= e Madrid =E2=80=93 C.I.F. B82657941 - Red Hat S.L. --_=__=_XaM3_.1406124038.2A.738213.42.5125.52.42.007.117871013 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
<span style=3D"font-family:Arial; font-size:11px; color:#5F5F5F;">Da</sp= an><span style=3D"font-family:Arial; font-size:12px; color:#5F5F5F; paddi= ng-left:5px;">: "Juan Hernandez" jhernand@redhat.com</span></div>=0A<div>= <span style=3D"font-family:Arial; font-size:11px; color:#5F5F5F;">A</span= <span style=3D"font-family:Arial; font-size:12px; color:#5F5F5F; padding= -left:5px;">: "Amedeo Salvati" amedeo@oscert.net, users@ovirt.org</span><= /div>=0A<div><span style=3D"font-family:Arial; font-size:11px; color:#5F5= F5F;">Cc</span><span style=3D"font-family:Arial; font-size:12px; color:#5= F5F5F; padding-left:5px;">: </span></div>=0A<div><span style=3D"font-fami= ly:Arial; font-size:11px; color:#5F5F5F;">Data</span><span style=3D"font-= family:Arial; font-size:12px; color:#5F5F5F; padding-left:5px;">: Wed, 23= Jul 2014 14:44:57 +0200</span></div>=0A<div><span style=3D"font-family:A= rial; font-size:11px; color:#5F5F5F;">Oggetto</span><span style=3D"font-f= amily:Arial; font-size:12px; color:#5F5F5F; padding-left:5px;">: Re: [ovi= rt-users] cloud-init options under python-sdk</span></div>=0A<br>=0A<div>= > On 07/23/2014 02:39 PM, Amedeo Salvati wrote:</div><div>> > he= llo Juan|guys,</div><div>> > </div><div>> > I still have prob= lems with cloud-init options on python-sdk... now I'm</div><div>> >=
<div>> >> many thanks Juan it works!</div><div>> > </div>= <div>> >> best regards</div><div>> >> a</div><div>> = > </div><div>> > </div><div>> >> Da: "Juan Hernandez" j= hernand@redhat.com</div><div>> >> A: "Amedeo Salvati" amedeo@osc= ert.net, users@ovirt.org</div><div>> >> Cc:</div><div>> >&= gt; Data: Tue, 22 Jul 2014 15:32:45 +0200</div><div>> >> Oggetto= : Re: [ovirt-users] cloud-init options under python-sdk</div><div>> &g= t; </div><div>> >> > On 07/22/2014 02:55 PM, Amedeo Salvati w= rote:</div><div>> >> > > hi Juan|guys,</div><div>> >= > > ></div><div>> >> > > thanks for hints! but un= fortunatly it seems wont works, because I've</div><div>> >> >= > launched vm with this simple code:</div><div>> >> > >= ;</div><div>> >> > > action =3D</div><div>> >> &g= t; ></div><div>> > params.Action(vm=3Dparams.VM(initialization=3D=
<div>> >> ></div><div>> >> > The qemu-kvm comman= d line will have a parameter indicating the file that</div><div>> >= > > contains the cloud-init data:</div><div>> >> ></div= <div>> >> > -drive file=3D/var/run/vdsm/payload/...img</div>= <div>> >> ></div><div>> >> > Copy that file somew= here, then mount it and inspect the content:</div><div>> >> >= </div><div>> >> > # cp /var/run/vdsm/payload/...img /tmp/my.i= mg</div><div>> >> > # mount -o loop,ro /tmp/my.img /mnt</div>= <div>> >> > # find /mnt</div><div>> >> > ...</div= <div>> >> > # umount /mnt</div><div>> >> ></div>= <div>> >> ></div><div>> >> > > Da: "Juan Herna= ndez" jhernand@redhat.com</div><div>> >> > > A: "Amedeo Sa= lvati" amedeo@oscert.net, users@ovirt.org</div><div>> >> > &g= t; Cc:</div><div>> >> > > Data: Tue, 22 Jul 2014 12:21:01 = +0200</div><div>> >> > > Oggetto: Re: [ovirt-users] cloud-= init options under python-sdk</div><div>> >> > ></div><div= > >> > >> On 07/22/2014 11:48 AM, Amedeo Salvati wrote= :</div><div>> >> > >> > hello guys!</div><div>> &= gt;> > >> ></div><div>> >> > >> > I'm= writing some python code to start VMs, and based on</div><div>> > = operating system</div><div>> >> > >> > (at this mome= nt centos6 nad centos7), I would like to use</div><div>> > cloud-in= it</div><div>> >> > >> > options (available on web u= i at run-once) to start them and</div><div>> > resetting</div><div>= > >> > >> > root password, change hostname and write= some configuration</div><div>> > files by</div><div>> >> = > >> > using yaml semantics, but at this moment I was unable = to find a</div><div>> > way to</div><div>> >> > >>= ; > do it...</div><div>> >> > >> ></div><div>>= >> > >> > somebody know a way (or could send me some h= ints) using</div><div>> > python-sdk to</div><div>> >> >= ; >> > start A VM and pass to it cloud-init options?</div><div>&= gt; >> > >> ></div><div>> >> > >> >= ; e.g. the portion of code I would like to change is vm.start() under</di= v><div>> >> > > rhel6|7:</div><div>> >> > >= > ></div><div>> >> > >> > try:</div><div>> = >> > >> > osVersion =3D vm.get_os().get_type()</div><di= v>> >> > >> > if (osVersion =3D=3D "rhel_6x64" or os= Version =3D=3D "rhel_6" or</div><div>> >> > >> > osV= ersion =3D=3D "rhel_7x64") and CLOUDINIT =3D=3D "yes":</div><div>> >= ;> > >> > print "Starting VM: " + vm.name + " with cloud-i= nit</div><div>> >> > >> > options"</div><div>> &g= t;> > >> > ----> vm.start() <---------- > else:</=
<div>> > S.L.</div><div>> </div><div>> </div><div>> -- </=
=0A<div class=3D"xam_msg_class">=0A<div style=3D"font: normal 13px Arial;= color:rgb(31, 28, 27);">thanks! <br><br>best regards<br>a<br><br>=0A<div= trying to reset root password and according to xml available at</div><di= v>> > http://www.ovirt.org/Features/Cloud-Init_Integration and spec= ifically</div><div>> > for user/pw:</div><div>> > </div><div>= > > ...</div><div>> > <users></users></div><div>> > <= user></user></div><div>> > <user_name>root</user_name></div><di= v>> > <password>myPass</password></div><div>> > </div><= div>> > </div><div>> > ...</div><div>> > </div><div>>= ; > I've changed action object with this example:</div><div>> > = </div><div>> > action =3D params.Action(</div><div>> > = vm=3Dparams.VM(</div><div>> > = initialization=3Dparams.Initialization(</div><div>> > = cloud_init=3Dparams.CloudInit(</div><div>>= > host=3Dparams.Host(address=3D"r= heltest025"),</div><div>> > use= rs=3Dparams.Users(</div><div>> > = </div><div>> > user=3Dparams.User(user_name=3D"root", password= =3D"pippo")</div><div>> </div><div>> Try to use a list here:</div><= div>> </div><div>> user=3D[parms.User(...)]</div><div>> </div>= <div>> > )</div><div>> &= gt; )</div><div>> > = )</div><div>> > )<= /div><div>> > )</div><div>> > </div><= div>> > but when i try to start a vm I got this error: "TypeError: = 'User' object</div><div>> > is not iterable"</div><div>> > </= div><div>> > somebody has some hints for resetting root password?</= div><div>> > </div><div>> > Best regards</div><div>> > = Amedeo Salvati</div><div>> > </div><div>> > </div><div>> &= gt; Da: "Amedeo Salvati" amedeo@oscert.net</div><div>> > A: jhernan= d@redhat.com</div><div>> > Cc: users@ovirt.org</div><div>> > = Data: Tue, 22 Jul 2014 15:50:58 +0200</div><div>> > Oggetto: Re: [o= virt-users] cloud-init options under python-sdk</div><div>> > </div= params.Initialization(cloud_init=3Dparams.CloudInit(host=3Dparams.Host(na= me=3D"rheltest014")))))</div><div>> >> > > vm.start( actio= n )</div><div>> >> > ></div><div>> >> > > b= ut after boot the VM, cloud-init service hasn't set hostname and on</div>= <div>> >> > > cloud-init.log and cloud-init-output.log I c= annot find any entry for</div><div>> >> > > setting hostna= me, instead if I use web ui it work's fine...</div><div>> >> >= ; ></div><div>> >> > > there are any ways to debug clou= d-init jobs?</div><div>> >> > > the params params.Host is = right for CloudInit host or is intended for</div><div>> >> > = > host / hypervisor?</div><div>> >> > ></div><div>> = >> > > Best regards</div><div>> >> > > Amedeo = Salvati</div><div>> >> > ></div><div>> >> ></d= iv><div>> >> > To change the hostname you have to use the "ad= dress" property of the</div><div>> >> > "Host" class:</div><d= iv>> >> ></div><div>> >> > host=3Dparams.Host(</d= iv><div>> >> > address=3D"myhostname.example.com"</div><div>&= gt; >> > )</div><div>> >> ></div><div>> >> = > The "Host" class is used for many things, including CloudInit and</d= iv><div>> >> > hypervisors. But in this context it is just a = container for the host</div><div>> > name.</div><div>> >> = ></div><div>> >> > To debug cloud-init start the VM (with = the GUI or with the RESTAPI),</div><div>> >> > then go to the= hypervisor where it is actually running, and look for the</div><div>>= >> > corresponding qemu-kvm process:</div><div>> >> &g= t;</div><div>> >> > # ps -ef | grep qemu-kvm | grep myvm</div= div><div>> >> > >> > print "Starting VM " + vm.name<= /div><div>> >> > >> > vm.start()</div><div>> >= > > >> > while vmstat !=3D 'down':</div><div>> >>= > >> > sleep(1)</div><div>> >> > >> > v= mstat =3D vm.get_status().state</div><div>> >> > >> >= ; except Exception, err:</div><div>> >> > >> > print= "Error on starting VM"</div><div>> >> > >> > print = err</div><div>> >> > >> ></div><div>> >> &g= t; >> ></div><div>> >> > >> > Best regards<= /div><div>> >> > >> > Amedeo Salvati</div><div>> = >> > >> ></div><div>> >> > >></div><d= iv>> >> > >> It should be something like this:</div><di= v>> >> > >></div><div>> >> > >> from = ovirtsdk.xml import params</div><div>> >> > >></div><di= v>> >> > >> action =3D params.Action(</div><div>> &g= t;> > >> vm=3Dparams.VM(</div><div>> >> > >>= ; initialization=3Dparams.Initialization(</div><div>> >> > &g= t;> cloud_init=3Dparams.CloudInit(</div><div>> >> > >&g= t; host=3Dparams.Host(</div><div>> >> > >> name=3D"myvm= "</div><div>> >> > >> ),</div><div>> >> > &= gt;> users=3D...,</div><div>> >> > >> files=3D...,</= div><div>> >> > >> ...</div><div>> >> > >= ;> )</div><div>> >> > >> )</div><div>> >> &= gt; >> )</div><div>> >> > >> )</div><div>> >= ;> > >></div><div>> >> > >> vm.start(action= )</div><div>> >> > >></div><div>> >> > >= ></div><div>> >> > >> --</div><div>> >> >= ; >> Direcci=C3=B3n Comercial: C/Jose Bardasano Baos, 9, Edif. Gorb= ea 3, planta</div><div>> >> > >> 3=C2=BAD, 28016 Madrid= , Spain</div><div>> >> > >> Inscrita en el Reg. Mercant= il de Madrid =E2=80=93 C.I.F. B82657941 - Red</div><div>> > Hat S.L= .</div><div>> >> ></div><div>> >> ></div><div>>= ; >> > --</div><div>> >> > Direcci=C3=B3n Comercial:= C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta</div><div>> >>= > 3=C2=BAD, 28016 Madrid, Spain</div><div>> >> > Inscrita= en el Reg. Mercantil de Madrid =E2=80=93 C.I.F. B82657941 - Red Hat</div= div><div>> Direcci=C3=B3n Comercial: C/Jose Bardasano Baos, 9, Edif. G= orbea 3, planta</div><div>> 3=C2=BAD, 28016 Madrid, Spain</div><div>&g= t; Inscrita en el Reg. Mercantil de Madrid =E2=80=93 C.I.F. B82657941 - R= ed Hat S.L.</div></div>=0A</div>=0A --_=__=_XaM3_.1406124038.2A.738213.42.5125.52.42.007.117871013--
participants (2)
-
Amedeo Salvati
-
Juan Hernandez