VMware {code} Community
aparajirSG
Contributor
Contributor

Copy a thin provisioned disk between datastores, via web/REST API

I have a 10-GB thin-provisoned virtual disk - with ~1GB of actual data in it. I want to copy this from one datastore to another. When I do this via the vCenter, the copy is also thin provisioned - UI shows the size as 1GB, and the copy is quite fast. I would like an API that can do the same.

I have tried -

  • `copyDatastoreFile_Task`: This API performed a thick copy. I can't find any way to request a thin copy in the documentation.
  • `copyVirtualDiskTask`: I received an 'invalid-request' when I attempted it from the API. It seems like it is available only when connected directly to an ESX as per previous community threads. Using the PowerShell's Copy-HardDisk command also says "This operation is not supported when connected to a vCenter"
  • Clone VM - this doesn't really meet my use-case, since I want to copy the original VMDK of a VM running from a snapshot. [Without the changes that are present in the snapshot]

The only solution I found in previous posts was to use `vmkfstools` - but I need to achieve this through the API (REST is preferable, but the SOAP web services is fine too). Surely there has to be a simple way of doing that I'm missing? If someone can point me to an API doc, or Java code sample for this, I'll be very grateful!

moderator edit by wila: moved to VMware{code} Forums discussions

Reply
0 Kudos
0 Replies