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