VMware {code} Community
jas123
Contributor
Contributor

CopyDatastoreFile_Task: VC 2.5, ESXi 3.5

Hi

I am using CopyDatastoreFile_Task to copy virtual disk file (vmdk) between datastores. API call succeeds, but the destination file is very small in size and is shown as type File in Datastore browser.

Is this the right API for copying virtual disks?

Regards

Jas

0 Kudos
4 Replies
lamw
Community Manager
Community Manager

When dealing with VMDK(s), you should not be using standard copy such as 'cp' or in your case CopyDatastoreFile_Task() which is explained here:

You should be using CloneVM_Task() if you wan to copy a VM(s) disk OR use vmkfstools, which is the correct tool to be using when dealing with vmdks, all other non-vmdks can use the copy task or *vifs' which is a implementation of HTTP PUT/GETS.

Also you might be interested in taking a look at VDDK: which is specifically created for working with VMDK(s), its part or will be part of the so call vStorage APIs

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

VMware Code Central - Scripts/Sample code for Developers and Administrators

If you find this information useful, please award points for "correct" or "helpful".

0 Kudos
tos2k
Expert
Expert

Hi!

Virtual disks consist at least of two files, the descriptor file and the data. F.e. for 2gbsparse, the data file will be splitted in several more parts.

Try to use CopyVirtualDisk instead, or copy all necessary files related to a virtual disk.

Tos2k

0 Kudos
jas123
Contributor
Contributor

Thank you for the reply. I am not sure all virtual disks have at least two files. What is the descriptior file, what extension does it have? Will that be shown in Datastore Browser or hidden file?

CopyVirtualDisk does not work with VC only with direct ESX sessions. I would like to have a VC centeric solution if thats possible.

Regards

Jasmeer

0 Kudos
tos2k
Expert
Expert

Hi!

CopyVirtualDisk works from vCenter starting by version 4. Before you had to call that function on one of the ESX hosts, right.

What a virtual disk consists of you can easily check by connecting to a ESX host via ssh, and browse the data from there. DatastoreBrowser in the VI-client shows a virtual disk probably as "one file", yeah...

Tos2k

0 Kudos