<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 >> Edit >> Host >> "Run On:" >> Specific >. choose a hostname<br>
2) right click a offline VM >> Edit >> Host >> "Migration Options:" >> "Do not allow migration"<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="Default", async=False):<br> """<br> Import VM From a Export domain into your storage domain <br>
"""<br> timeoutSec=1800 <br> pollInterval=2<br><br> exportStorageDomain = self.api.storagedomains.list(type_="export")[0]<br> actionParams = params.Action(<br> storage_domain=self.api.storagedomains.get(storage_domain_name),<br>
cluster=self.api.clusters.get("Default"),<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 != 'down':<br> if time.time() - start > timeoutSec:<br>
raise Exception("Timed out (%s) waiting for %s to obtain down status" % (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 "Run as" to the specified host but "Run as" was
set to "Any host in the cluster". Am I missing something ? <br></div><div><br></div><div>2) Secondly, I tried modifying the VM "Run as" hostname with the below code <br></div><div><div><br></div>>>> api = API (url = "xx" , username ="XX", pasword ="XX", ca_file = "ca")<br>
<div>>>> vm_obj = api.vms.list(name="test_vm_101")[0]<br>>>> vm_obj.set_host="rhev1"<br>>>> 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 " "Migration Options" ? <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>