<div dir="ltr"><div>Thanks will try and let you know,<br></div>~Rohit<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 19, 2017 at 1:18 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"><div class="HOEnZb"><div class="h5">On 04/19/2017 09:34 AM, Juan Hernández wrote:<br>
&gt; On 04/19/2017 08:41 AM, TranceWorldLogic . wrote:<br>
&gt;&gt; Hi,<br>
&gt;&gt;<br>
&gt;&gt; I was trying to create VM on specific HOST using python sdk as shown below.<br>
&gt;&gt;<br>
&gt;&gt; ------ Code -------------------<br>
&gt;&gt; vm = vms_service.add(  ....<br>
&gt;&gt;                         host = types.Host(<br>
&gt;&gt;                             name = &quot;host-01&quot;,<br>
&gt;&gt;                         ),<br>
&gt;&gt;           )<br>
&gt;&gt; ------ End Code -------------------<br>
&gt;&gt;<br>
&gt;&gt; It created VM successfully, but when I see in ovirt GUI I saw that VM is<br>
&gt;&gt; not bonded with specific host.<br>
&gt;&gt;<br>
&gt;&gt; Ovirt GUI:<br>
&gt;&gt; Virtual Machines -&gt; click on VM -&gt; &quot;Edit&quot; button -&gt; In advance menu -&gt;<br>
&gt;&gt; &quot;Host&quot; tab<br>
&gt;&gt; Start Running On:<br>
&gt;&gt;    o  Any Host in Cluster  &lt;== This option got selected<br>
&gt;&gt;    o  Specific Host(s)   &lt;== *I want this option to select.*<br>
&gt;&gt;<br>
&gt;&gt; Please help me to bind VM to specific Host via Python SDK<br>
&gt;&gt;<br>
&gt;<br>
&gt; The Vm.host attribute is used only to indicate in what host is the VM<br>
&gt; currently running.<br>
&gt;<br>
&gt; To pin the VM to a set of hosts you have to use Vm.placement_policy, as<br>
&gt; described here:<br>
&gt;<br>
&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;<br>
&gt; With the Python SDK it should be something like this:<br>
&gt;<br>
&gt;   vm = vms_service.add(<br>
&gt;     vm=types.Vm(<br>
&gt;       ...<br>
&gt;       placement_policy=types.<wbr>PlacementPolicy(<br>
&gt;         hosts=[<br>
&gt;           types.Host(name=&#39;host-01&#39;)<br>
&gt;         ]<br>
&gt;       )<br>
&gt;     )<br>
&gt;   )<br>
&gt;<br>
<br>
</div></div>Sorry, the name of the type is incorrect, should be<br>
&#39;types.VmPlacementPolicy&#39;. So the complete example should be like this:<br>
<span class=""><br>
  vm = vms_service.add(<br>
    vm=types.Vm(<br>
      ...<br>
</span>      placement_policy=types.<wbr>VmPlacementPolicy(<br>
<div class="HOEnZb"><div class="h5">        hosts=[<br>
          types.Host(name=&#39;host-01&#39;)<br>
        ]<br>
      )<br>
    )<br>
  )<br>
<br>
</div></div></blockquote></div><br></div>