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. _______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users