<div dir="ltr"><div><div><div>Hi Michael Pasternak, <br><br></div>Thanks for the info. <br><br>I was able to modify the VM as :<br><br> vm_placement_params = params.VmPlacementPolicy(host = params.VM(name=rhev_host_name), affinity = "pinned")<br>
vm_obj.set_placement_policy(vm_placement_params)<br> vm_obj.update()<br><br><br></div><div>Thanks much !!<br></div><div><br></div>thanks,<br></div>Karthik<br><br><div><div><br><div><br><br></div></div></div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Dec 28, 2013 at 11:51 PM, Michael Pasternak <span dir="ltr"><<a href="mailto:mpastern@redhat.com" target="_blank">mpastern@redhat.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Hi,<br>
<br>
take a look at vm.start.__doc__ it should have all the answers you're looking for,<br>
as about migrate options, these two [1] are responsible for pinning vm to specific host,<br>
possible options for the 'affinity' can be seen at <vm_affinities> [2].<br>
<br>
[1]<br>
<br>
[@param <a href="http://action.vm.placement_policy.host.id" target="_blank">action.vm.placement_policy.host.id</a>|name: string]<br>
[@param action.vm.placement_policy.affinity: string]<br>
<br>
[2]<br>
<br>
http[s]://host[:port]/api/capabilities<br>
<div><div class="h5"><br>
<br>
On 12/27/2013 11:54 PM, karthik S wrote:<br>
> Dear Users,<br>
><br>
> I am karthik, based in Mountain View, CA. I have been using python ovirtsdk for QA Automation tests for RHEV-M for past two months. My knowledge on ovirtsdk is intermittent<br>
> at this stage.<br>
><br>
> I want to do the below actions that we do on rhev-M using python ovirtsdk.<br>
><br>
> On, RHEV-M UI<br>
> ============<br>
> 1) right click a offline VM >> Edit >> Host >> "Run On:" >> Specific >. choose a hostname<br>
> 2) right click a offline VM >> Edit >> Host >> "Migration Options:" >> "Do not allow migration"<br>
><br>
> python Code:<br>
> ==========<br>
><br>
> 1) The VM was imported from export domain to my storage_domain using the code<br>
><br>
><br>
> def import_vm(self, source_vm_name, dest_vm_name, storage_domain_name, rhev_host_name=None, cluster_name="Default", async=False):<br>
> """<br>
> Import VM From a Export domain into your storage domain<br>
> """<br>
> timeoutSec=1800<br>
> pollInterval=2<br>
><br>
> exportStorageDomain = self.api.storagedomains.list(type_="export")[0]<br>
> actionParams = params.Action(<br>
> storage_domain=self.api.storagedomains.get(storage_domain_name),<br>
> cluster=self.api.clusters.get("Default"),<br>
> clone=1,<br>
> vm = params.VM (name=dest_vm_name,<br>
> snapshots=params.Snapshots(collapse_snapshots=1),<br>
> disks = params.Disks(clone = 1),<br>
> host = params.Host(name=rhev_host_name)<br>
> ))<br>
><br>
> exportStorageDomain.vms.get(source_vm_name).import_vm(actionParams)<br>
> start = time.time()<br>
> while self.api.vms.get(dest_vm_name).status.state != 'down':<br>
> if time.time() - start > timeoutSec:<br>
> raise Exception("Timed out (%s) waiting for %s to obtain down status" % (timeoutSec, vm_name))<br>
> time.sleep(pollInterval)<br>
><br>
> return self.api.vms.get(name=dest_vm_name)[0]<br>
><br>
><br>
> Issue : Upon import, this method did not set the "Run as" to the specified host but "Run as" was set to "Any host in the cluster". Am I missing something ?<br>
><br>
> 2) Secondly, I tried modifying the VM "Run as" hostname with the below code<br>
><br>
>>>> api = API (url = "xx" , username ="XX", pasword ="XX", ca_file = "ca")<br>
>>>> vm_obj = api.vms.list(name="test_vm_101")[0]<br>
>>>> vm_obj.set_host="rhev1"<br>
>>>> vm_obj.update()<br>
><br>
> This did not help either. Seems I am missing something..<br>
><br>
><br>
> 3) finally how to set " "Migration Options" ?<br>
><br>
><br>
> Your help would appreciated and will help me to get greater understanding of the SDK itself.<br>
><br>
> Thanks,<br>
> Karthik<br>
><br>
><br>
><br>
><br>
</div></div>> _______________________________________________<br>
> Users mailing list<br>
> <a href="mailto:Users@ovirt.org">Users@ovirt.org</a><br>
> <a href="http://lists.ovirt.org/mailman/listinfo/users" target="_blank">http://lists.ovirt.org/mailman/listinfo/users</a><br>
><br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
<br>
Michael Pasternak<br>
RedHat, ENG-Virtualization R&D<br>
</font></span></blockquote></div><br></div>