
23 Jul
2014
23 Jul
'14
3:39 p.m.
--_=__=_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=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=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--