VMware Cloud Community
jarushepic
Enthusiast
Enthusiast
Jump to solution

Storage vMotion fails with not enough disk space

I built a workflow to storage vmotion a VM between storage arrays, creating or expanding destination storage volumes as needed on the target storage array.  I used Oynx to get the syntax and put together some code that seems to be building the exact same javascript that Oynx outputs, but the relocate task fails with insufficient space on the datastore.  The code processes the datastore movements in sets, so it will move a few of the disks at a time.  In the example below I'm moving the config file and disks 2000, 2001, and 2005.  All the debug output from my code indicates that it is building the spec properly.  Anyone have ideas?

The Oynx code:

// ------- RelocateVM_Task -------

var spec = new VcVirtualMachineRelocateSpec();

spec.datastore = Server.findForType("VC:Datastore", managedObject.vimHost.id + "/datastore-334");;

spec.disk = System.getModule("com.vmware.onyx").array(VcVirtualMachineRelocateSpecDiskLocator, 12);

spec.disk[0] = new VcVirtualMachineRelocateSpecDiskLocator();

spec.disk[0].diskId = 2000;

spec.disk[0].datastore = Server.findForType("VC:Datastore", managedObject.vimHost.id + "/datastore-334");;

spec.disk[1] = new VcVirtualMachineRelocateSpecDiskLocator();

spec.disk[1].diskId = 2001;

spec.disk[1].datastore = Server.findForType("VC:Datastore", managedObject.vimHost.id + "/datastore-334");;

spec.disk[2] = new VcVirtualMachineRelocateSpecDiskLocator();

spec.disk[2].diskId = 2003;

spec.disk[2].datastore = Server.findForType("VC:Datastore", managedObject.vimHost.id + "/datastore-5466");;

spec.disk[3] = new VcVirtualMachineRelocateSpecDiskLocator();

spec.disk[3].diskId = 2005;

spec.disk[3].datastore = Server.findForType("VC:Datastore", managedObject.vimHost.id + "/datastore-334");;

spec.disk[4] = new VcVirtualMachineRelocateSpecDiskLocator();

spec.disk[4].diskId = 2048;

spec.disk[4].datastore = Server.findForType("VC:Datastore", managedObject.vimHost.id + "/datastore-5457");;

spec.disk[5] = new VcVirtualMachineRelocateSpecDiskLocator();

spec.disk[5].diskId = 2032;

spec.disk[5].datastore = Server.findForType("VC:Datastore", managedObject.vimHost.id + "/datastore-5458");;

spec.disk[6] = new VcVirtualMachineRelocateSpecDiskLocator();

spec.disk[6].diskId = 2016;

spec.disk[6].datastore = Server.findForType("VC:Datastore", managedObject.vimHost.id + "/datastore-5459");;

spec.disk[7] = new VcVirtualMachineRelocateSpecDiskLocator();

spec.disk[7].diskId = 2017;

spec.disk[7].datastore = Server.findForType("VC:Datastore", managedObject.vimHost.id + "/datastore-5461");;

spec.disk[8] = new VcVirtualMachineRelocateSpecDiskLocator();

spec.disk[8].diskId = 2033;

spec.disk[8].datastore = Server.findForType("VC:Datastore", managedObject.vimHost.id + "/datastore-5462");;

spec.disk[9] = new VcVirtualMachineRelocateSpecDiskLocator();

spec.disk[9].diskId = 2049;

spec.disk[9].datastore = Server.findForType("VC:Datastore", managedObject.vimHost.id + "/datastore-5463");;

spec.disk[10] = new VcVirtualMachineRelocateSpecDiskLocator();

spec.disk[10].diskId = 2018;

spec.disk[10].datastore = Server.findForType("VC:Datastore", managedObject.vimHost.id + "/datastore-5464");;

spec.disk[11] = new VcVirtualMachineRelocateSpecDiskLocator();

spec.disk[11].diskId = 2034;

spec.disk[11].datastore = Server.findForType("VC:Datastore", managedObject.vimHost.id + "/datastore-5465");;

managedObject.relocateVM_Task(spec, VcVirtualMachineMovePriority.defaultPriority);  // VirtualMachine

The javascript code that generates the spec in my workflow:

var spec = new VcVirtualMachineRelocateSpec();

// if we're processing the datastore that holds the config file, we will move the config file too

// if we aren't processing the config datastore, this will be set to whereever the config file is

spec.datastore = configDatastore;

spec.disk = [];

var ix = 0;

for each (var device in u_vm.config.hardware.device)

{

  if (device instanceof VcVirtualDisk)

  {

  if (device.backing instanceof VcVirtualDiskFlatVer2BackingInfo)

  {

  if (device.backing.datastore.name.indexOf(volumeType) == -1)

  {

  // we aren't moving this disk, keep it where it is

  System.log('keeping ' + device.key + ' on ' + device.backing.datastore.name);

  var diskSpec = new VcVirtualMachineRelocateSpecDiskLocator();

  diskSpec.diskId = device.key;

  diskSpec.datastore = device.backing.datastore;

  spec.disk.push(diskSpec);

  }

  else

  {

  // Let's move this one

  System.log('moving ' + device.key + ' from ' + device.backing.datastore.name + ' to ' + destinationDatastores[ix].name);

  var diskSpec = new VcVirtualMachineRelocateSpecDiskLocator();

  diskSpec.diskId = device.key;

  // take the next datastore off our target array

  diskSpec.datastore = destinationDatastores[ix];

  spec.disk.push(diskSpec);

  ix++;

  // allow for multiple disks on the same datastore

  if (ix == destinationDatastores.length)

  {

  ix = 0;

  }

  }

  }

  }

}

task = u_vm.relocateVM_Task(spec);

The debug output from a workflow run:

[2017-01-15 09:57:33.061] [I] moving 2000 from tstdev_0926_vmx-001_prdodbosin_3441 to tstdev_0926_m50-001_prdodbosin_1012

[2017-01-15 09:57:33.063] [I] moving 2001 from tstdev_0926_vmx-001_prdodbosin_3441 to tstdev_0926_m50-001_prdodbosin_1012

[2017-01-15 09:57:33.064] [I] keeping 2003 on tstdev_0926_vmx-001_prdodbjrnl_3533

[2017-01-15 09:57:33.066] [I] moving 2005 from tstdev_0926_vmx-001_prdodbosin_3441 to tstdev_0926_m50-001_prdodbosin_1012

[2017-01-15 09:57:33.067] [I] keeping 2048 on tstdev_0926_vmx-001_prdodbdata_3442

[2017-01-15 09:57:33.069] [I] keeping 2032 on tstdev_0926_vmx-001_prdodbdata_3443

[2017-01-15 09:57:33.070] [I] keeping 2016 on tstdev_0926_vmx-001_prdodbdata_3444

[2017-01-15 09:57:33.071] [I] keeping 2017 on tstdev_0926_vmx-001_prdodbdata_3445

[2017-01-15 09:57:33.073] [I] keeping 2033 on tstdev_0926_vmx-001_prdodbdata_3446

[2017-01-15 09:57:33.074] [I] keeping 2049 on tstdev_0926_vmx-001_prdodbdata_3530

[2017-01-15 09:57:33.076] [I] keeping 2018 on tstdev_0926_vmx-001_prdodbdata_3531

[2017-01-15 09:57:33.077] [I] keeping 2034 on tstdev_0926_vmx-001_prdodbdata_3532

[2017-01-15 09:57:33.202] [I] RelocateVM_Task 0 %

[2017-01-15 09:57:34.204] [E] (com.vmware.library.vc.basic/vim3WaitTaskEnd) Error in (Dynamic Script Module name : vim3WaitTaskEnd#20) Task 'RelocateVM_Task' error: Insufficient disk space on datastore 'tstdev_0926_m50-001_prdodbosin_1012'.

[2017-01-15 09:57:34.268] [E] Workflow execution stack:

***

0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi,

One problem I see in the code is with the spec.disk array, which you initialize with an empty array and then push elements to it inside the loop. I think this dynamic resizing of arrays is not supported by vCenter plug-in's objects.

So instead of the pattern:

spec.disk = [];

for each (...) {

   ...

   spec.disk.push(...);

   ...

}

you should use something like (which builds a regular Javascript array at assigns it to the spec at the end with a single assignment operation)

var disks = [];

for each (...) {

   ...

   disks.push(...);

   ...

}

spec.disk = disks;

View solution in original post

0 Kudos
2 Replies
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi,

One problem I see in the code is with the spec.disk array, which you initialize with an empty array and then push elements to it inside the loop. I think this dynamic resizing of arrays is not supported by vCenter plug-in's objects.

So instead of the pattern:

spec.disk = [];

for each (...) {

   ...

   spec.disk.push(...);

   ...

}

you should use something like (which builds a regular Javascript array at assigns it to the spec at the end with a single assignment operation)

var disks = [];

for each (...) {

   ...

   disks.push(...);

   ...

}

spec.disk = disks;

0 Kudos
jarushepic
Enthusiast
Enthusiast
Jump to solution

ugh, such a simple thing!!!  Thanks a ton!

0 Kudos