Hi,
take a look at vm.start.__doc__ it should have all the answers you're looking for,
as about migrate options, these two [1] are responsible for pinning vm to specific host,
possible options for the 'affinity' can be seen at <vm_affinities> [2].
[1]
[@param action.vm.placement_policy.host.id|name: string]
[@param action.vm.placement_policy.affinity: string]
[2]
http[s]://host[:port]/api/capabilities
On 12/27/2013 11:54 PM, karthik S wrote:
Dear Users,
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.
I want to do the below actions that we do on rhev-M using python ovirtsdk.
On, RHEV-M UI
============
1) right click a offline VM >> Edit >> Host >> "Run On:"
>> Specific >. choose a hostname
2) right click a offline VM >> Edit >> Host >> "Migration
Options:" >> "Do not allow migration"
python Code:
==========
1) The VM was imported from export domain to my storage_domain using the code
def import_vm(self, source_vm_name, dest_vm_name, storage_domain_name,
rhev_host_name=None, cluster_name="Default", async=False):
"""
Import VM From a Export domain into your storage domain
"""
timeoutSec=1800
pollInterval=2
exportStorageDomain = self.api.storagedomains.list(type_="export")[0]
actionParams = params.Action(
storage_domain=self.api.storagedomains.get(storage_domain_name),
cluster=self.api.clusters.get("Default"),
clone=1,
vm = params.VM (name=dest_vm_name,
snapshots=params.Snapshots(collapse_snapshots=1),
disks = params.Disks(clone = 1),
host =
params.Host(name=rhev_host_name)
))
exportStorageDomain.vms.get(source_vm_name).import_vm(actionParams)
start = time.time()
while self.api.vms.get(dest_vm_name).status.state != 'down':
if time.time() - start > timeoutSec:
raise Exception("Timed out (%s) waiting for %s to obtain down
status" % (timeoutSec, vm_name))
time.sleep(pollInterval)
return self.api.vms.get(name=dest_vm_name)[0]
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 ?
2) Secondly, I tried modifying the VM "Run as" hostname with the below code
>>> api = API (url = "xx" , username ="XX", pasword
="XX", ca_file = "ca")
>>> vm_obj = api.vms.list(name="test_vm_101")[0]
>>> vm_obj.set_host="rhev1"
>>> vm_obj.update()
This did not help either. Seems I am missing something..
3) finally how to set " "Migration Options" ?
Your help would appreciated and will help me to get greater understanding of the SDK
itself.
Thanks,
Karthik
_______________________________________________
Users mailing list
Users(a)ovirt.org
http://lists.ovirt.org/mailman/listinfo/users