VMware Cloud Community
ullbergm
Enthusiast
Enthusiast

Downloading file from a URL

So I'm trying to create a workflow that exports a VM as a OVF from one vCenter and then imports it in to several other vCenters.

I've been able to do most of it except now I'm trying to figure out the best way to download a file from a URL with vOrchestrator and where to save it.

Here are some details on what I'm doing if anyone is interested:

workflow.PNG

First i get the OVF file content using the ovfManager:

var cdp = new VcOvfCreateDescriptorParams();
cdp.name = "OVF-VM";
cdp.description = "";
cdp.includeImageFiles = true;

var descriptor = VM.sdkConnection.ovfManager.createDescriptor(VM, cdp);

OVF = descriptor.ovfDescriptor;

Then I get the lease (this creates a Export OVF task in vCenter:

var lease = VM.exportVm();

The next step is to get a list of the files:

files = new Array();

for( var i = 0; i < lease.info.deviceUrl.length; i++ )
{

   var downloadFile = new Properties();
   downloadFile.put( "Filename", lease.info.deviceUrl[i].targetId );
   downloadFile.put( "Url", lease.info.deviceUrl[i].url );
   files.push(downloadFile);
}


The next step is to download the files, this is where I need help.

One thing to keep in mind is that while it is downloading the files you need to keep updating the status of the job to keep it from timing out.

lease.httpNfcLeaseProgress(10);

When all the files are downloaded you need to release the lease (this completes the task in vCenter:

lease.httpNfcLeaseComplete();

So... Any ideas on the best way to download a file?

Check out my orchestration blog here: http://ullberg.us/orchestrate/
Reply
0 Kudos
0 Replies