<div class="xam_msg_class">
<div style="font: normal 13px Arial; color:rgb(31, 28, 27);">hi Juan|guys,<br><br>thanks for hints! but unfortunatly it seems wont works, because I've launched vm with this simple code:<br><br>action = params.Action(vm=params.VM(initialization=params.Initialization(cloud_init=params.CloudInit(host=params.Host(name="rheltest014")))))<br>vm.start( action )<br><br>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...<br><br>there are any ways to debug cloud-init jobs?<br>the params params.Host is right for CloudInit host or is intended for host / hypervisor?<br><br>Best regards<br>Amedeo Salvati<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;">: Tue, 22 Jul 2014 12:21:01 +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/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 operating system</div><div>> > (at this moment centos6 nad centos7), I would like to use cloud-init</div><div>> > options (available on web ui at run-once) to start them and resetting</div><div>> > root password, change hostname and write some configuration 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() under 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 Hat S.L.</div></div>
</div>