VMware Cloud Community
DericVMW
Contributor
Contributor

Storage Migrating VMs with vRO

Hi i found this code in the forums. Im new with vRO, how do you specify whch VMs are to be moved? And how do you move both storage and hosts?

  1. for(var i in vmsToRelocate){ 
  2.   var vm = vmsToRelocate[i]; 
  3.   task = vm.relocateVM_Task(relocateSpec); 
  4.   var actionResult = System.getModule("com.vmware.library.vc.basic").vim3WaitTaskEnd(task,progress,pollRate) ; 
  5.   System.log("Storage vMotion performed for VM : " + vm.name); 

**This code loops through all the VMs you select to migrate one at a time, it waits for the storage vMotion to complete for each VM before it executes the loop again for the next VM.

If you do want to do the storage vMotion in parallel for some VMs you can duplicate the code and just remove the line

  1. var actionResult = System.getModule("com.vmware.library.vc.basic").vim3WaitTaskEnd(task,progress,pollRate); 

**and vRO will just execute the loop for each VM in parallel.

Thanks

Tags (1)
0 Kudos
1 Reply
iiliev
VMware Employee
VMware Employee

Hi,

In your code, the VMs to be moved are stored in vmsToRelocate, which seems to be an object of type Array/VC:VirtualMacine. They could be an input parameter for the workflow (so the user can browse the vCenter inventory and select them when starting the workflow), or a workflow attribute/temporary variable, whose content is computed by some Javascript code not shown in your sample.

Another interesting variable used in your code is relocateSpec, but it is not clear where is it coming from. This relocation spec is the specification for the moving/copying operation - see https://www.vmware.com/support/developer/converter-sdk/conv50_apireference/vim.vm.RelocateSpec.html

0 Kudos