VMware {code} Community
derekrodrigues
Enthusiast
Enthusiast
Jump to solution

Copying remote files to a datastore

The following posting suggests HTTP PUT as the bonafide method of pushing remote files to a datastore:

http://communities.vmware.com/thread/117504

However, the ServiceContent::CopyDatastoreFile_Task( ) method seems to promise the same functionality:

http://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/index.html

Are there any code samples that illustrate the use of the CopyDatastoreFile_Task method that someone can point me to?

Thanks

Reply
0 Kudos
1 Solution

Accepted Solutions
tos2k
Expert
Expert
Jump to solution

Hi!

These are two different techniques. You choose one of them basically depending on where the data to copy is. If it is located on a datastore accessible through the ESX/VC then you choose CopyDatastoreFile, if it is "outside" of your VI you have to upload it with HTTP PUT.

VimApi.ManagedObjectReference mo =

servEsx.CopyDatastoreFile_Task(servEsx.RetrieveServiceContent(ServiceInstance).fileManager, "\[ds]/folder/sourceFile", sourceDatacenter,

"\[ds]/folder/TargetFile", targetDatacenter, true, true)

As you see, one of the arguments is "FileManager" which can currently just be found on the ESX server directly. So you have to establish a session with the ESX in addition to your VC session.

gives you the reference to the task copying the file for you.

Tos2k

View solution in original post

Reply
0 Kudos
3 Replies
tos2k
Expert
Expert
Jump to solution

Hi!

These are two different techniques. You choose one of them basically depending on where the data to copy is. If it is located on a datastore accessible through the ESX/VC then you choose CopyDatastoreFile, if it is "outside" of your VI you have to upload it with HTTP PUT.

VimApi.ManagedObjectReference mo =

servEsx.CopyDatastoreFile_Task(servEsx.RetrieveServiceContent(ServiceInstance).fileManager, "\[ds]/folder/sourceFile", sourceDatacenter,

"\[ds]/folder/TargetFile", targetDatacenter, true, true)

As you see, one of the arguments is "FileManager" which can currently just be found on the ESX server directly. So you have to establish a session with the ESX in addition to your VC session.

gives you the reference to the task copying the file for you.

Tos2k

Reply
0 Kudos
derekrodrigues
Enthusiast
Enthusiast
Jump to solution

Some follow up questions:

1. HTTP PUT appears to be the only means of uploading remote files onto an ESX datastore from a different physical machine via the API. Is this correct?

2. What is the maximum file size (if any) that may be uploaded via HTTP PUT?

Reply
0 Kudos
tos2k
Expert
Expert
Jump to solution

Hi!

1) When having a VI based 100% on ESXi servers, this is the only way to upload files. All other ESX versions provide the service console and so a bunch of other methods, like SSH/SCP...

2) I am using this for vmx files only, but I am assuming that VMware has not build in a limitation in there.

Tos2k

Reply
0 Kudos