VMware Cloud Community
VaultTec13
Contributor
Contributor
Jump to solution

vm.relocateVM_Task doesn't work when moving between clusters

Hello everyone,

I have a Scriptable Task that suppose to migrate VMs(datastore and host) to another cluster. When I'm testing it within the cluster, everything works perfectly. But when I'm trying to move a VM between clusters, I'm getting:

"specified parameter not correct"

I can move the VM manually via vSphere Web Client with no problem.

This is the code in the scriptable task:

//Get VM's number of VMDKs

diskIDArray = new Array();

var devices = vm.config.hardware.device;

for (var j in devices) {

    if (devices[j] instanceof VcVirtualDisk)

  {

         diskIDArray.push(devices[j].key);

  System.log("VM Disk ID:" + devices[j].key);

     }

}

//Migrate

var spec = new VcVirtualMachineRelocateSpec();

spec.datastore = destDatastore;

spec.host = destHost;

spec.disk = new Array();

for (var i=0;i< diskIDArray.length;i++)

  {

  var disk = new VcVirtualMachineRelocateSpecDiskLocator();

  disk.diskId = diskIDArray[i];

  disk.datastore = destDatastore;

  spec.disk[i] = disk;

  }

//vcTask = System.getModule("dk.atea.extra").XvMotion(vm,destHost,destDatastore);

vcTask = vm.relocateVM_Task(spec, VcVirtualMachineMovePriority.defaultPriority);  // VirtualMachine

Any ideas?

Dan.

0 Kudos
1 Solution

Accepted Solutions
maaca
Enthusiast
Enthusiast
Jump to solution

Hi Dan,

you should define target resourcepool (spec.pool).

maaca

View solution in original post

0 Kudos
2 Replies
maaca
Enthusiast
Enthusiast
Jump to solution

Hi Dan,

you should define target resourcepool (spec.pool).

maaca

0 Kudos
VaultTec13
Contributor
Contributor
Jump to solution

It works! Thanks maaca!

Btw, Is there a way to find out myself which parameter is causing the problem next time I'm getting "parameter not correct"?

0 Kudos