[ovirt-users] Bulk move vm disks?
nicolas at devels.es
nicolas at devels.es
Fri Mar 24 11:03:26 UTC 2017
El 2017-03-24 10:29, Ernest Beinrohr escribió:
> On 24.03.2017 11:11, gflwqs gflwqs wrote:
>
>> Hi list,
>> I need to move 600+ vms:from one data domain to another, however
>> from what i can see in the GUI i can only move one vm disk at the
>> time which would be very time consuming.
>>
>> I there any way i can bulk move those vm disks?
>> By the way, I can't stop the vms they have to be online during the
>> migration..
> This is my python program:
>
> # ... API init
>
> vms= api.vms.list(query = 'vmname')
If you're planning to do it that way, make sure you install version 3.x
of ovirt-engine-sdk-python. Newer versions (4.x) differ too much in
syntax.
Also, if you want to move a whole Storage Domain, you might be
interested in listing VMs by the storage domain name, i.e.:
api.vms.list(query='Storage=myoldstoragedomain')
That will return a list of all machines in that storage domain.
>
> for vm in vms:
> print vm.name
> for disk in vm.disks.list( ):
> print " disk: " + disk.name + " " + disk.get_alias()
> sd = api.storagedomains.get('NEWSTORAGE')
>
> try:
> disk.move(params.Action(storage_domain=sd))
>
> disk_id = disk.get_id()
> while True:
> print("Waiting for movement to complete ...")
> time.sleep(10)
> disk = vm.disks.get(id=disk_id)
> if disk.get_status().get_state() == "ok":
> break
>
> except:
> print "Cannot move."
>
> api.disconnect()
>
> --
>
> Ernest Beinrohr, AXON PRO
> Ing [1], RHCE [2], RHCVA [2], LPIC [3], VCA [4],
> +421-2-62410360 +421-903-482603
>
>
> Links:
> ------
> [1] http://www.beinrohr.sk/ing.php
> [2] http://www.beinrohr.sk/rhce.php
> [3] http://www.beinrohr.sk/lpic.php
> [4] http://www.beinrohr.sk/vca.php
>
> _______________________________________________
> Users mailing list
> Users at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/users
More information about the Users
mailing list