Hi, Thanks a lot.
J.P. -----Original Message----- From: Juan Hernández [mailto:jhern...@redhat.com] Sent: mardi 8 mars 2016 10:32 To: Jean-Pierre Ribeauville Cc: Yaniv Kaul; users@ovirt.org Subject: Re: [ovirt-users] VM migration by using the Python SDK On 03/07/2016 07:59 PM, Yaniv Kaul wrote: > > > On Mon, Mar 7, 2016 at 6:17 PM, Jean-Pierre Ribeauville > <jpribeauvi...@axway.com <mailto:jpribeauvi...@axway.com>> wrote: > > Hi,____ > > __ __ > > __ __ > > I'm a little bit lost by looking how to migrate a Guest between two > nodes of a same cluster by using ovirt python API . > > > Copy-paste from oVirt system tests[1], adapt as you need: > > def vm_migrate(prefix): > api = prefix.virt_env.engine_vm().get_api() > host_names = [h.name <http://h.name>() for h in > prefix.virt_env.host_vms()] > > migrate_params = params.Action( > host=params.Host( > name=sorted(host_names)[1] > ), > ) > api.vms.get(VM1_NAME).migrate(migrate_params) > testlib.assert_true_within_short( > lambda: api.vms.get(VM1_NAME).status.state == 'up', > ) > > > Y. > [1] > https://gerrit.ovirt.org/#/c/48206/4/basic_suite_3.6/test-scenarios/00 > 4_basic_sanity.py > The above is correct. If you want a simpler complete example, it should be something like this: ---8<--- #!/usr/bin/python from ovirtsdk.api import API from ovirtsdk.xml import params # Connect to the server: api = API( url="https://engine.example.com/ovirt-engine/api", username="admin@internal", password="...", ca_file="/etc/pki/ovirt-engine/ca.pem", debug=False, ) # Find the VM: vm = api.vms.get(name="myvm") # Migrate the VM to the host: vm.migrate( action=params.Action( host=params.Host( name="myhost", ) ), ) # Disconnect: api.disconnect() --->8--- -- Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta 3ºD, 28016 Madrid, Spain Inscrita en el Reg. Mercantil de Madrid - C.I.F. B82657941 - Red Hat S.L. _______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users