<div class="xam_msg_class">
<div style="font: normal 13px Arial; color:rgb(31, 28, 27);">thanks! <br><br>best regards<br>a<br><br>
<div><span style="font-family:Arial; font-size:11px; color:#5F5F5F;">Da</span><span style="font-family:Arial; font-size:12px; color:#5F5F5F; padding-left:5px;">: "Juan Hernandez" jhernand@redhat.com</span></div>
<div><span style="font-family:Arial; font-size:11px; color:#5F5F5F;">A</span><span style="font-family:Arial; font-size:12px; color:#5F5F5F; padding-left:5px;">: "Amedeo Salvati" amedeo@oscert.net, users@ovirt.org</span></div>
<div><span style="font-family:Arial; font-size:11px; color:#5F5F5F;">Cc</span><span style="font-family:Arial; font-size:12px; color:#5F5F5F; padding-left:5px;">: </span></div>
<div><span style="font-family:Arial; font-size:11px; color:#5F5F5F;">Data</span><span style="font-family:Arial; font-size:12px; color:#5F5F5F; padding-left:5px;">: Wed, 23 Jul 2014 14:44:57 +0200</span></div>
<div><span style="font-family:Arial; font-size:11px; color:#5F5F5F;">Oggetto</span><span style="font-family:Arial; font-size:12px; color:#5F5F5F; padding-left:5px;">: Re: [ovirt-users] cloud-init options under python-sdk</span></div>
<br>
<div>> On 07/23/2014 02:39 PM, Amedeo Salvati wrote:</div><div>> > hello Juan|guys,</div><div>> > </div><div>> > I still have problems with cloud-init options on python-sdk... now I'm</div><div>> > trying to reset root password and according to xml available at</div><div>> > http://www.ovirt.org/Features/Cloud-Init_Integration and specifically</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><div>> > <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 = params.Action(</div><div>> > vm=params.VM(</div><div>> > initialization=params.Initialization(</div><div>> > cloud_init=params.CloudInit(</div><div>> > host=params.Host(address="rheltest025"),</div><div>> > users=params.Users(</div><div>> > </div><div>> > user=params.User(user_name="root", password="pippo")</div><div>> </div><div>> Try to use a list here:</div><div>> </div><div>> user=[parms.User(...)]</div><div>> </div><div>> > )</div><div>> > )</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>> > Da: "Amedeo Salvati" amedeo@oscert.net</div><div>> > A: jhernand@redhat.com</div><div>> > Cc: users@ovirt.org</div><div>> > Data: Tue, 22 Jul 2014 15:50:58 +0200</div><div>> > Oggetto: Re: [ovirt-users] cloud-init options under python-sdk</div><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" jhernand@redhat.com</div><div>> >> A: "Amedeo Salvati" amedeo@oscert.net, users@ovirt.org</div><div>> >> Cc:</div><div>> >> Data: Tue, 22 Jul 2014 15:32:45 +0200</div><div>> >> Oggetto: Re: [ovirt-users] cloud-init options under python-sdk</div><div>> > </div><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</div><div>> >> > > launched vm with this simple code:</div><div>> >> > ></div><div>> >> > > action =</div><div>> >> > ></div><div>> > params.Action(vm=params.VM(initialization=params.Initialization(cloud_init=params.CloudInit(host=params.Host(name="rheltest014")))))</div><div>> >> > > 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 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 cloud-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>> >> ></div><div>> >> > To change the hostname you have to use the "address" property of the</div><div>> >> > "Host" class:</div><div>> >> ></div><div>> >> > host=params.Host(</div><div>> >> > address="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</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>> >> ></div><div>> >> > # ps -ef | grep qemu-kvm | grep myvm</div><div>> >> ></div><div>> >> > The qemu-kvm command line will have a parameter indicating the file that</div><div>> >> > contains the cloud-init data:</div><div>> >> ></div><div>> >> > -drive file=/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 Hernandez" jhernand@redhat.com</div><div>> >> > > A: "Amedeo Salvati" 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: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</div><div>> > operating system</div><div>> >> > >> > (at this moment centos6 nad centos7), I would like to use</div><div>> > cloud-init</div><div>> >> > >> > options (available on web ui 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 hints) using</div><div>> > 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() under</div><div>> >> > > rhel6|7:</div><div>> >> > >> ></div><div>> >> > >> > try:</div><div>> >> > >> > osVersion = vm.get_os().get_type()</div><div>> >> > >> > if (osVersion == "rhel_6x64" or osVersion == "rhel_6" or</div><div>> >> > >> > osVersion == "rhel_7x64") and CLOUDINIT == "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 != 'down':</div><div>> >> > >> > sleep(1)</div><div>> >> > >> > vmstat = vm.get_status().state</div><div>> >> > >> > except Exception, err:</div><div>> >> > >> > 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>> >> > >></div><div>> >> > >> It should be something like this:</div><div>> >> > >></div><div>> >> > >> from ovirtsdk.xml import params</div><div>> >> > >></div><div>> >> > >> action = params.Action(</div><div>> >> > >> vm=params.VM(</div><div>> >> > >> initialization=params.Initialization(</div><div>> >> > >> cloud_init=params.CloudInit(</div><div>> >> > >> host=params.Host(</div><div>> >> > >> name="myvm"</div><div>> >> > >> ),</div><div>> >> > >> users=...,</div><div>> >> > >> files=...,</div><div>> >> > >> ...</div><div>> >> > >> )</div><div>> >> > >> )</div><div>> >> > >> )</div><div>> >> > >> )</div><div>> >> > >></div><div>> >> > >> vm.start(action)</div><div>> >> > >></div><div>> >> > >></div><div>> >> > >> --</div><div>> >> > >> Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta</div><div>> >> > >> 3ºD, 28016 Madrid, Spain</div><div>> >> > >> Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red</div><div>> > Hat S.L.</div><div>> >> ></div><div>> >> ></div><div>> >> > --</div><div>> >> > Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta</div><div>> >> > 3ºD, 28016 Madrid, Spain</div><div>> >> > Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat</div><div>> > S.L.</div><div>> </div><div>> </div><div>> -- </div><div>> Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta</div><div>> 3ºD, 28016 Madrid, Spain</div><div>> Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L.</div></div>
</div>