Skip to content

Instantly share code, notes, and snippets.

@dlinsley
Created April 20, 2018 17:39
Show Gist options
  • Save dlinsley/fe86bd5595b1b3a6db1d316c549ecd38 to your computer and use it in GitHub Desktop.
Save dlinsley/fe86bd5595b1b3a6db1d316c549ecd38 to your computer and use it in GitHub Desktop.
Move VM to root ResourcePool of Cluster
// VMware vRealize Orchestrator action sample
// Determines the ComputeResource or ClusterComputeResource of the VM.
// Assumes the VM is part of a DRS Cluster and a member of a child resoure pool in the cluster.
//
// Moves / Migrates the VM to the root ResourcePool of the Cluster.
//
//Action Inputs:
// vm - VC:VirtualMachine
//
//Return type: void
var cluster = System.getModule("com.vmware.library.vc.cluster").getComputeResourceOfVm(vm);
System.log("Migrating VM: "+vm.name+" to root resource pool of cluster: "+cluster.name);
var task = vm.migrateVM_Task(cluster.resourcePool, null, VcVirtualMachineMovePriority.defaultPriority, null);
var actionResult = System.getModule("com.vmware.library.vc.basic").vim3WaitTaskEnd(task,true,2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment