
...=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--