<div dir="ltr"><div><div><div>Hi Juan,<br><br></div>It working fine. affinity and hosts have solved my problem.<br><br></div>Thanks,<br></div>~Rohit<br><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 19, 2017 at 5:16 PM, Juan Hernández <span dir="ltr">&lt;<a href="mailto:jhernand@redhat.com" target="_blank">jhernand@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"><span class="">On 04/19/2017 01:27 PM, TranceWorldLogic . wrote:<br>
&gt; Hi,<br>
&gt;<br>
&gt; It is working fine.<br>
&gt; But I want to disable migration policy. It didn&#39;t solve my purpose.<br>
&gt;<br>
&gt; What else I have to do to disable migration ?<br>
&gt;<br>
<br>
</span>Not sure what exactly you want to achieve. Can you elaborate a bit?<br>
<br>
If in addition to pin the VM to a host you also want to disable<br>
migration, you can use the Vm.placement_policy.affinity attribute:<br>
<span class=""><br>
  vm = vms_service.add(<br>
    vm=types.Vm(<br>
      ...<br>
      placement_policy=types.<wbr>VmPlacementPolicy(<br>
        hosts=[<br>
          types.Host(name=&#39;host-01&#39;)<br>
</span>        ],<br>
        affinity=types.VmAffinity.<wbr>PINNED<br>
      )<br>
    )<br>
  )<br>
<br>
Martin, I think that you can explain better than me what are the<br>
meanings of the values of the VmAffinity enum, and what is it<br>
relationship to pinning. Would be nice to have that documented in the<br>
specification of the API.<br>
<span class="im HOEnZb"><br>
&gt;<br>
&gt;<br>
&gt; On Wed, Apr 19, 2017 at 1:36 PM, TranceWorldLogic .<br>
</span><span class="im HOEnZb">&gt; &lt;<a href="mailto:tranceworldlogic@gmail.com">tranceworldlogic@gmail.com</a> &lt;mailto:<a href="mailto:tranceworldlogic@gmail.com">tranceworldlogic@<wbr>gmail.com</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt;     Thanks will try and let you know,<br>
&gt;     ~Rohit<br>
&gt;<br>
&gt;     On Wed, Apr 19, 2017 at 1:18 PM, Juan Hernández &lt;<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a><br>
</span><div class="HOEnZb"><div class="h5">&gt;     &lt;mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt;         On 04/19/2017 09:34 AM, Juan Hernández wrote:<br>
&gt;         &gt; On 04/19/2017 08:41 AM, TranceWorldLogic . wrote:<br>
&gt;         &gt;&gt; Hi,<br>
&gt;         &gt;&gt;<br>
&gt;         &gt;&gt; I was trying to create VM on specific HOST using python sdk<br>
&gt;         as shown below.<br>
&gt;         &gt;&gt;<br>
&gt;         &gt;&gt; ------ Code -------------------<br>
&gt;         &gt;&gt; vm = vms_service.add(  ....<br>
&gt;         &gt;&gt;                         host = types.Host(<br>
&gt;         &gt;&gt;                             name = &quot;host-01&quot;,<br>
&gt;         &gt;&gt;                         ),<br>
&gt;         &gt;&gt;           )<br>
&gt;         &gt;&gt; ------ End Code -------------------<br>
&gt;         &gt;&gt;<br>
&gt;         &gt;&gt; It created VM successfully, but when I see in ovirt GUI I saw<br>
&gt;         that VM is<br>
&gt;         &gt;&gt; not bonded with specific host.<br>
&gt;         &gt;&gt;<br>
&gt;         &gt;&gt; Ovirt GUI:<br>
&gt;         &gt;&gt; Virtual Machines -&gt; click on VM -&gt; &quot;Edit&quot; button -&gt; In<br>
&gt;         advance menu -&gt;<br>
&gt;         &gt;&gt; &quot;Host&quot; tab<br>
&gt;         &gt;&gt; Start Running On:<br>
&gt;         &gt;&gt;    o  Any Host in Cluster  &lt;== This option got selected<br>
&gt;         &gt;&gt;    o  Specific Host(s)   &lt;== *I want this option to select.*<br>
&gt;         &gt;&gt;<br>
&gt;         &gt;&gt; Please help me to bind VM to specific Host via Python SDK<br>
&gt;         &gt;&gt;<br>
&gt;         &gt;<br>
&gt;         &gt; The Vm.host attribute is used only to indicate in what host is<br>
&gt;         the VM<br>
&gt;         &gt; currently running.<br>
&gt;         &gt;<br>
&gt;         &gt; To pin the VM to a set of hosts you have to use<br>
&gt;         Vm.placement_policy, as<br>
&gt;         &gt; described here:<br>
&gt;         &gt;<br>
&gt;         &gt;<br>
&gt;         &gt;<br>
&gt;         <a href="http://ovirt.github.io/ovirt-engine-api-model/4.1/#types/vm/attributes/placement_policy" rel="noreferrer" target="_blank">http://ovirt.github.io/ovirt-<wbr>engine-api-model/4.1/#types/<wbr>vm/attributes/placement_policy</a><br>
&gt;         &lt;<a href="http://ovirt.github.io/ovirt-engine-api-model/4.1/#types/vm/attributes/placement_policy" rel="noreferrer" target="_blank">http://ovirt.github.io/ovirt-<wbr>engine-api-model/4.1/#types/<wbr>vm/attributes/placement_policy</a><wbr>&gt;<br>
&gt;         &gt;<br>
&gt;         &gt; With the Python SDK it should be something like this:<br>
&gt;         &gt;<br>
&gt;         &gt;   vm = vms_service.add(<br>
&gt;         &gt;     vm=types.Vm(<br>
&gt;         &gt;       ...<br>
&gt;         &gt;       placement_policy=types.<wbr>PlacementPolicy(<br>
&gt;         &gt;         hosts=[<br>
&gt;         &gt;           types.Host(name=&#39;host-01&#39;)<br>
&gt;         &gt;         ]<br>
&gt;         &gt;       )<br>
&gt;         &gt;     )<br>
&gt;         &gt;   )<br>
&gt;         &gt;<br>
&gt;<br>
&gt;         Sorry, the name of the type is incorrect, should be<br>
&gt;         &#39;types.VmPlacementPolicy&#39;. So the complete example should be<br>
&gt;         like this:<br>
&gt;<br>
&gt;           vm = vms_service.add(<br>
&gt;             vm=types.Vm(<br>
&gt;               ...<br>
&gt;               placement_policy=types.<wbr>VmPlacementPolicy(<br>
&gt;                 hosts=[<br>
&gt;                   types.Host(name=&#39;host-01&#39;)<br>
&gt;                 ]<br>
&gt;               )<br>
&gt;             )<br>
&gt;           )<br>
&gt;<br>
&gt;<br>
&gt;<br>
<br>
</div></div></blockquote></div><br></div>