<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"><<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"><div class="HOEnZb"><div class="h5">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 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 that VM is<br>
>> not bonded with specific host.<br>
>><br>
>> Ovirt GUI:<br>
>> Virtual Machines -> click on VM -> "Edit" button -> In 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 the VM<br>
> currently running.<br>
><br>
> To pin the VM to a set of hosts you have to use Vm.placement_policy, as<br>
> described here:<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>
><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>
</div></div>Sorry, the name of the type is incorrect, should be<br>
'types.VmPlacementPolicy'. 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='host-01')<br>
]<br>
)<br>
)<br>
)<br>
<br>
</div></div></blockquote></div><br></div>