<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 24.03.2017 11:11, gflwqs gflwqs
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAFYgF=qZidGx=2xB3bNTPQkaE9UZ8bmLp8uYAq23N0ojorT-EQ@mail.gmail.com">
<div dir="ltr">Hi list,
<div>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.</div>
<div><br>
</div>
<div>I there any way i can bulk move those vm disks?</div>
<div>By the way, I can't stop the vms they have to be online
during the migration..</div>
<div><br>
</div>
</div>
</blockquote>
This is my python program:<br>
<br>
<tt># ... API init</tt><tt><br>
</tt><tt><br>
</tt><tt>vms= api.vms.list(query = 'vmname')</tt><tt><br>
</tt><tt><br>
</tt><tt>for vm in vms:</tt><tt><br>
</tt><tt> print vm.name</tt><tt><br>
</tt><tt> for disk in vm.disks.list( ):</tt><tt><br>
</tt><tt> print " disk: " + disk.name + " " + disk.get_alias()</tt><tt><br>
</tt><tt> sd = api.storagedomains.get('NEWSTORAGE')</tt><tt><br>
</tt><tt><br>
</tt><tt> try:</tt><tt><br>
</tt><tt> disk.move(params.Action(storage_domain=sd))</tt><tt><br>
</tt><tt><br>
</tt><tt> disk_id = disk.get_id()</tt><tt><br>
</tt><tt> while True:</tt><tt><br>
</tt><tt> print("Waiting for movement to complete ...")</tt><tt><br>
</tt><tt> time.sleep(10)</tt><tt><br>
</tt><tt> disk = vm.disks.get(id=disk_id)</tt><tt><br>
</tt><tt> if disk.get_status().get_state() == "ok":</tt><tt><br>
</tt><tt> break</tt><tt><br>
</tt><tt><br>
</tt><tt> except:</tt><tt><br>
</tt><tt> print "Cannot move."</tt><tt><br>
</tt><tt><br>
</tt><tt>api.disconnect()</tt><tt><br>
</tt><br>
<br>
<br>
<div class="moz-signature">-- <br>
<div id="oernii_footer" style="color: gray;">
<span style="font-family: Lucida Console, Luxi Mono, Courier,
monospace; font-size: 90%;">
Ernest Beinrohr, AXON PRO<br>
<a style="text-decoration: none; color: gray;"
href="http://www.beinrohr.sk/ing.php">Ing</a>, <a
style="text-decoration: none; color: gray;"
href="http://www.beinrohr.sk/rhce.php">RHCE</a>, <a
style="text-decoration: none; color: gray;"
href="http://www.beinrohr.sk/rhce.php">RHCVA</a>, <a
style="text-decoration: none; color: gray;"
href="http://www.beinrohr.sk/lpic.php">LPIC</a>, <a
style="text-decoration: none; color: gray;"
href="http://www.beinrohr.sk/vca.php">VCA</a>, <br>
+421-2-62410360 +421-903-482603
<br>
</span> </div>
<img
src="http://nojsstats.appspot.com/UA-44497096-1/email.beinrohr.sk"
moz-do-not-send="true" width="1" border="0" height="1">
</div>
</body>
</html>