<div dir="ltr"><div><div>Dear Users,<br><br></div><div>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 at this stage.<br>
<br></div><div>I want to do the below actions that we do on rhev-M using python ovirtsdk.<br><br></div>On, RHEV-M UI<br>============<br>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>
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><br></div><div>python Code:<br>==========<br><br></div><div>1) The VM was imported from export domain to my storage_domain using the code<br>
</div><div><br><br>    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>        &quot;&quot;&quot;<br>            Import VM From a Export domain into your storage domain <br>
        &quot;&quot;&quot;<br>        timeoutSec=1800 <br>        pollInterval=2<br><br>        exportStorageDomain = self.api.storagedomains.list(type_=&quot;export&quot;)[0]<br>        actionParams = params.Action(<br>                                     storage_domain=self.api.storagedomains.get(storage_domain_name),<br>
                                     cluster=self.api.clusters.get(&quot;Default&quot;),<br>                                     clone=1,<br>                                     vm = params.VM (name=dest_vm_name,<br>                                                     snapshots=params.Snapshots(collapse_snapshots=1),<br>
                                                     disks = params.Disks(clone = 1),<br>                                                     host = params.Host(name=rhev_host_name)<br>                                    ))<br>
<br>        exportStorageDomain.vms.get(source_vm_name).import_vm(actionParams)<br>        start = time.time()<br>        while self.api.vms.get(dest_vm_name).status.state != &#39;down&#39;:<br>                if time.time() - start &gt; timeoutSec:<br>
                    raise Exception(&quot;Timed out (%s) waiting for %s to obtain down status&quot; % (timeoutSec, vm_name))<br>                time.sleep(pollInterval)<br><br>        return self.api.vms.get(name=dest_vm_name)[0]<br>
<br><br></div><div>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></div><div><br></div><div>2) Secondly, I tried modifying the VM &quot;Run as&quot; hostname with the below code <br></div><div><div><br></div>&gt;&gt;&gt; api = API (url = &quot;xx&quot; , username =&quot;XX&quot;, pasword =&quot;XX&quot;, ca_file = &quot;ca&quot;)<br>
<div>&gt;&gt;&gt; vm_obj = api.vms.list(name=&quot;test_vm_101&quot;)[0]<br>&gt;&gt;&gt; vm_obj.set_host=&quot;rhev1&quot;<br>&gt;&gt;&gt; vm_obj.update()<br><br></div><div>This did not help either. Seems I am missing something.. <br>
<br><br></div><div>3) finally how to set &quot; &quot;Migration Options&quot; ? <br><br><br></div><div>Your help would appreciated and will help me to get greater understanding of the SDK itself.<br><br></div><div>Thanks,<br>
Karthik<br><br></div><br></div></div>