<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 = &quot;pinned&quot;)<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">&lt;<a href="mailto:mpastern@redhat.com" target="_blank">mpastern@redhat.com</a>&gt;</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&#39;re looking for,<br>
as about migrate options, these two [1] are responsible for pinning vm to specific host,<br>
possible options for the &#39;affinity&#39; can be seen at &lt;vm_affinities&gt; [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>
&gt; Dear Users,<br>
&gt;<br>
&gt; 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>
&gt; at this stage.<br>
&gt;<br>
&gt; I want to do the below actions that we do on rhev-M using python ovirtsdk.<br>
&gt;<br>
&gt; On, RHEV-M UI<br>
&gt; ============<br>
&gt; 1) right click a offline VM &gt;&gt; Edit &gt;&gt; Host &gt;&gt; &quot;Run On:&quot; &gt;&gt; Specific &gt;. choose a hostname<br>
&gt; 2) right click a offline VM &gt;&gt; Edit &gt;&gt; Host &gt;&gt;  &quot;Migration Options:&quot; &gt;&gt; &quot;Do not allow migration&quot;<br>
&gt;<br>
&gt; python Code:<br>
&gt; ==========<br>
&gt;<br>
&gt; 1) The VM was imported from export domain to my storage_domain using the code<br>
&gt;<br>
&gt;<br>
&gt;     def import_vm(self, source_vm_name, dest_vm_name, storage_domain_name, rhev_host_name=None, cluster_name=&quot;Default&quot;,  async=False):<br>
&gt;         &quot;&quot;&quot;<br>
&gt;             Import VM From a Export domain into your storage domain<br>
&gt;         &quot;&quot;&quot;<br>
&gt;         timeoutSec=1800<br>
&gt;         pollInterval=2<br>
&gt;<br>
&gt;         exportStorageDomain = self.api.storagedomains.list(type_=&quot;export&quot;)[0]<br>
&gt;         actionParams = params.Action(<br>
&gt;                                      storage_domain=self.api.storagedomains.get(storage_domain_name),<br>
&gt;                                      cluster=self.api.clusters.get(&quot;Default&quot;),<br>
&gt;                                      clone=1,<br>
&gt;                                      vm = params.VM (name=dest_vm_name,<br>
&gt;                                                      snapshots=params.Snapshots(collapse_snapshots=1),<br>
&gt;                                                      disks = params.Disks(clone = 1),<br>
&gt;                                                      host = params.Host(name=rhev_host_name)<br>
&gt;                                     ))<br>
&gt;<br>
&gt;         exportStorageDomain.vms.get(source_vm_name).import_vm(actionParams)<br>
&gt;         start = time.time()<br>
&gt;         while self.api.vms.get(dest_vm_name).status.state != &#39;down&#39;:<br>
&gt;                 if time.time() - start &gt; timeoutSec:<br>
&gt;                     raise Exception(&quot;Timed out (%s) waiting for %s to obtain down status&quot; % (timeoutSec, vm_name))<br>
&gt;                 time.sleep(pollInterval)<br>
&gt;<br>
&gt;         return self.api.vms.get(name=dest_vm_name)[0]<br>
&gt;<br>
&gt;<br>
&gt; Issue :  Upon import, this method did not set the &quot;Run as&quot; to the specified host  but &quot;Run as&quot; was set to &quot;Any host in the cluster&quot;.  Am I missing something ?<br>
&gt;<br>
&gt; 2) Secondly, I tried modifying the VM &quot;Run as&quot; hostname with the below code<br>
&gt;<br>
&gt;&gt;&gt;&gt; api = API (url = &quot;xx&quot; , username =&quot;XX&quot;, pasword =&quot;XX&quot;, ca_file = &quot;ca&quot;)<br>
&gt;&gt;&gt;&gt; vm_obj = api.vms.list(name=&quot;test_vm_101&quot;)[0]<br>
&gt;&gt;&gt;&gt; vm_obj.set_host=&quot;rhev1&quot;<br>
&gt;&gt;&gt;&gt; vm_obj.update()<br>
&gt;<br>
&gt; This did not help either. Seems I am missing something..<br>
&gt;<br>
&gt;<br>
&gt; 3) finally how to set &quot; &quot;Migration Options&quot; ?<br>
&gt;<br>
&gt;<br>
&gt; Your help would appreciated and will help me to get greater understanding of the SDK itself.<br>
&gt;<br>
&gt; Thanks,<br>
&gt; Karthik<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
</div></div>&gt; _______________________________________________<br>
&gt; Users mailing list<br>
&gt; <a href="mailto:Users@ovirt.org">Users@ovirt.org</a><br>
&gt; <a href="http://lists.ovirt.org/mailman/listinfo/users" target="_blank">http://lists.ovirt.org/mailman/listinfo/users</a><br>
&gt;<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
<br>
Michael Pasternak<br>
RedHat, ENG-Virtualization R&amp;D<br>
</font></span></blockquote></div><br></div>