There are a couple of older posts about limitations to the situations in which CloneVirtualDisk_Task will work. I thought I would post my recent findings for the benefit of all.
This is against vSphere 4.0 u1 / ESX 4.0 u1 using VMware-vSphere-SDK-for-Perl-4.0.0-161974
1. Calling the method against VC still doesn't work
The VirtualDiskManager object on which you call the method is no longer null, but when you call the method the task fails with the error "The requested operation is not implemented by the server". Thus you must still call the method against an ESX server instead.
2. Force still doesn't work
Despite setting the 'force' property in the task to 1, the task still fails with an error that the file exists
3. When the destination file exists, the error message contains the name of the source file
In discovering 2, I found 3. I checked loads, and I was definitely specifying the source and destination files the right way around. Here's the out put of my script:
Copying data from [VDI1-00006] VUKMH1-005_1/VUKMH1-005-vdm-user-disk-D.vmdk to [VDI1-00003] VUKMI-004/VUKMI-004-vdm-user-disk-D.vmdk... UDD at destination is attached to a VirtualLsiLogicController VM VUKMH1-005 is running on host gbldcvdi06.emea.cbre.net Connecting to ESX at https://server/sdk with user root and password ********...done Starting Clone... ERROR: Clone task has failed. Error text: Cannot complete the operation because the file or folder /vmfs/volumes/49108494-f0558240-3705-001f296371fa/VUKMH1-005_1/VUKMH1-005-vdm-user-disk-D.vmdk already exists
Err...what? Then I checked the hostd.log:
[2010-04-08 14:59:27.217 F52E7B90 info 'TaskManager'] Task Created : haTask--vim.VirtualDiskManager.copyVirtualDisk-1519385748 [2010-04-08 14:59:27.556 F57D2B90 info 'DiskLib'] DISKLIB-VMFS : "/vmfs/volumes/49108494-f0558240-3705-001f296371fa/VUKMH1-005_1/VUKMH1-005-vdm-user-disk-D-flat.vmdk" : open successful (29) size = 7516192768, hd = 0. Type 3 [2010-04-08 14:59:27.556 F57D2B90 info 'DiskLib'] DISKLIB-VMFS : "/vmfs/volumes/49108494-f0558240-3705-001f296371fa/VUKMH1-005_1/VUKMH1-005-vdm-user-disk-D-flat.vmdk" : closed. [2010-04-08 14:59:27.556 F57D2B90 verbose 'VdisksvcPlugin'] Destination disk format: VMFS thin-provisioned [2010-04-08 14:59:27.560 F57D2B90 info 'DiskLib'] DISKLIB-VMFS : "/vmfs/volumes/49108494-f0558240-3705-001f296371fa/VUKMH1-005_1/VUKMH1-005-vdm-user-disk-D-flat.vmdk" : open successful (6) size = 7516192768, hd = 221642927. Type 3 [2010-04-08 14:59:27.560 F57D2B90 info 'DiskLib'] DISKLIB-DSCPTR: Opened [0]: "VUKMH1-005-vdm-user-disk-D-flat.vmdk" (0x6) [2010-04-08 14:59:27.560 F57D2B90 info 'DiskLib'] DISKLIB-LINK : Opened '/vmfs/volumes/49108494-f0558240-3705-001f296371fa/VUKMH1-005_1/VUKMH1-005-vdm-user-disk-D.vmdk' (0x6): vmfs, 14680064 sectors / 7 GB. [2010-04-08 14:59:27.561 F57D2B90 info 'DiskLib'] DISKLIB-LIB : Opened "/vmfs/volumes/49108494-f0558240-3705-001f296371fa/VUKMH1-005_1/VUKMH1-005-vdm-user-disk-D.vmdk" (flags 0x6). [2010-04-08 14:59:27.561 F57D2B90 info 'DiskLib'] DISKLIB-LIB : CREATE: "/vmfs/volumes/490b57af-f284a297-763d-001f296371fa/VUKMI-004/VUKMI-004-vdm-user-disk-D.vmdk" -- vmfs capacity=0 (0 bytes) adapter=lsilogic cowGran=0 [2010-04-08 14:59:27.563 F57D2B90 info 'DiskLib'] DISKLIB-LIB : DiskLib_CreateChildCreateParam: grain size set to : 1 [2010-04-08 14:59:27.563 F57D2B90 info 'DiskLib'] DISKLIB-LIB : CREATE: "/vmfs/volumes/490b57af-f284a297-763d-001f296371fa/VUKMI-004/VUKMI-004-vdm-user-disk-D.vmdk" -- vmfs capacity=14680064 (7 GB) adapter=buslogic cowGran=1 [2010-04-08 14:59:27.568 F57D2B90 info 'DiskLib'] DISKLIB-LINK : File '/vmfs/volumes/490b57af-f284a297-763d-001f296371fa/VUKMI-004/VUKMI-004-vdm-user-disk-D-flat.vmdk' already exists. [2010-04-08 14:59:27.568 F57D2B90 info 'DiskLib'] DISKLIB-LIB : Failed to clone : The file already exists (39). [2010-04-08 14:59:27.568 F57D2B90 warning 'VdisksvcPlugin'] Failed to clone disk : The file already exists (39). [2010-04-08 14:59:27.569 F57D2B90 info 'DiskLib'] DISKLIB-VMFS : "/vmfs/volumes/49108494-f0558240-3705-001f296371fa/VUKMH1-005_1/VUKMH1-005-vdm-user-disk-D-flat.vmdk" : closed. [2010-04-08 14:59:27.569 F57D2B90 warning 'VdisksvcPlugin'] Got Methodfault exception: vim.fault.FileAlreadyExists [2010-04-08 14:59:27.569 F57D2B90 info 'TaskManager'] Task Completed : haTask--vim.VirtualDiskManager.copyVirtualDisk-1519385748 Status error
Riiight. The line stating that my destination file exists kind of gives away that I specified them the right way round. The error message, however, says different. So don't believe the error messages...