VMware Cloud Community
aslk5
Enthusiast
Enthusiast

copyDatastoreFile_Task not creating copy correctly

I tried to used the copyDatastoreFile_Task() method and while it seems to be working, it's creating a small (less than 1KB) file on the destination datastore instead of a vmdk that is full size. Anyone seen this before and know the cause?

Related to this, if a disk is thin, lazy zeroed or eager zeroed, does the format remain the same after the copy ? (assuming I can get the copy to work)

0 Kudos
3 Replies
aslk5
Enthusiast
Enthusiast

Looks like I partially solved my own problem. I was using the wrong method. To copy a disk it should be copyVirtualDisk_Task()

There's a comment on the VcVirtualDiskManager saying most of the APIs will be deprecated and to use VStorageObjectManager instead. Anyone have a sample code to share on this new API? I'm not even sure how to get the ID it wants.

From what I have read this new API is for managing first class disks.... would that apply a normal disk that is attached to a vm?

0 Kudos
Alex_Romeo
Leadership
Leadership

Hi,

what version are you using it on?

https://pubs.vmware.com/vi-sdk/visdk250/ReferenceGuide/vim.FileManager.html

CopyDatastoreFile_Task

Faults 

  Type  Description
CannotAccessFileThrown if the source cannot be accessed because of insufficient permissions.
FileAlreadyExistsThrown if a file with the given name already exists at the destination, and the force flag is false.
FileFault
FileLockedThrown if the source file is currently locked or in use.
FileNotFoundThrown if the file specified by sourceName is not found, or, any intermediate level folder specified by the destinationName is not found.
InvalidDatastoreThrown if the operation cannot be performed on the source or destination datastores. Typically, a specific subclass of this exception is thrown.
NoDiskSpaceThrown if there is not enough space available at the destination datastore.
RuntimeFaultThrown if any type of runtime fault is thrown that is not covered by the other faults; for example, a communication error.

can you post the 1kb file? inside there may be information that helps to understand.

ARomeo

Blog: https://www.aleadmin.it/
0 Kudos
Alex_Romeo
Leadership
Leadership

Hi,

it seems to be fine also for the vm.

https://vdc-download.vmware.com/vmwb-repository/dcr-public/b525fb12-61bb-4ede-b9e3-c4a1f8171510/99ba...

Managed Object - VcenterVStorageObjectManager(vim.vslm.vcenter.VStorageObjectManager)

Extends
VStorageObjectManagerBase
See also
CryptoSpec, Datastore, ID, RetrieveVStorageObjSpec, VirtualMachineProfileSpec, VslmCloneSpec, VslmCreateSpec, vslmInfrastructureObjectPolicy, vslmInfrastructureObjectPolicySpec, VslmRelocateSpec, VslmTagEntry, VStorageObject, VStorageObjectAssociations, VStorageObjectSnapshotInfo, VStorageObjectStateInfo
Since
vSphere API 6.5

Managed Object Description

Interface to manage virtual storage object on a vCenter. VStorageObjectManager and SPBM policy support: All of the VStorageObjectManager APIs requiring ESXi host uses "Programatically selected" host to perform the actual operation. If the selected host is of 6.5 version then policy would not be passed down to host. In that case, user operation would succeed but if user checks SPBM Entity Compliance, it will show "Mismatch" / "Non Compliant" as a compliance result.

ARomeo

Blog: https://www.aleadmin.it/
0 Kudos