VMware Cloud Community
slahy
Enthusiast
Enthusiast

Upload and deploy ovf workflow

Hi,

I am looking to develop a workflow to be exported as a web view. The workflow is to allow users to upload an ova/ovf and deploy it. I would like to know what other people think is the best way to go about this.

I was thinking of calling Import-VApp or ovftool in a script through the ssh plugin.

Any suggestions/examples, advice welcome.

slahy

0 Kudos
4 Replies
cdecanini_
VMware Employee
VMware Employee

Would that be download / upload to vCenter or vCloud Director ?

If vCenter you should consider checking this plug-in : https://solutionexchange.vmware.com/store/products/9678

Christophe.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
0 Kudos
slahy
Enthusiast
Enthusiast

thanks cdecanini_

I will be using it with vCenter so that plugin looks perfect.

But I cant seem to get it to deploy an ovf, i keep getting the following error.

_________________________________________________________________________

[2013-02-12 12:20:18.508] [I] Load OVF contend
[2013-02-12 12:20:18.998] [I]
Attribute xsi:nil not allowed on element spec, which is not nillable.

while parsing call information for method ImportVApp
at line 1, column 227

while parsing SOAP body
at line 1, column 213

while parsing SOAP envelope
at line 1, column 38

while parsing HTTP request for method importVApp
on object of type vim.ResourcePool
at line 1, column 0 (Dynamic Script Module name : deployOVF#23)

__________________________________________________________________________

this line seems to cause the problem

var myVcHttpNfcLease = vmResourcePool.importVApp(myVcOvfCreateImportSpecResult.importSpec, vmFolder , vchost);

with myVcOvfCreateImportSpecParams having the offending attribute. Anyone seen this issue before ?

0 Kudos
slahy
Enthusiast
Enthusiast

can anybody tell me what is wrong with this code ?

it stays in what seems to be an infinite loop (the vcenter deploy OVF task times out ) the workflow just stays in the loop until i cancel it

it loops infinatly waiting for VcHttpNfcLeaseState to change from initalizing but as you can guess it never changes from the initailizing state, anyone got any ideas ?  Code below

//var fr = new FileReader("C://exportTest/exportTest.ovf");

//C://exportTest/exportTest.ovf

var fr = new FileReader("/tmp/test_export1.ovf");

fr.open();
var complete = fr.readAll();
//System.debug("complete file: " + complete);

var myOvfManager = vchost.parent.sdkConnection.ovfManager;

//var parseDesRes = new OvfParseDescriptorResult();

var parseDesRes = myOvfManager.parseDescriptor(complete, pd_params);

//System.debug("parseDesRes: " + parseDesRes.approximateFlatDeploymentSize);

var myVcOvfCreateImportSpecParams = new VcOvfCreateImportSpecParams();
myVcOvfCreateImportSpecParams.hostSystem = vchost;
myVcOvfCreateImportSpecParams.locale = "en-IE";
myVcOvfCreateImportSpecParams.entityName = vmname;
myVcOvfCreateImportSpecParams.deploymentOption="";

var networkMapping = new VcOvfNetworkMapping();
networkMapping.name= "Network 1";
networkMapping.network = vmnetwork;
myVcOvfCreateImportSpecParams.networkMapping = [networkMapping];
myVcOvfCreateImportSpecParams.propertyMapping = null;


var importSpecRes = new VcOvfCreateImportSpecResult();

importSpecRes = myOvfManager.createImportSpec(complete , resourcepool , datastore , myVcOvfCreateImportSpecParams);

var spec = new VcVirtualMachineImportSpec();
spec = importSpecRes.importSpec;

System.debug("No CPU: " + spec.configSpec.numCPUs  );
System.debug("Memory: " + spec.configSpec.memoryMB  );

var ovfFI = new VcOvfFileItem();
ovfFI = importSpecRes.fileItem;

for (i = 0; i < ovfFI.length ; i++){
System.debug("Array Length: " + ovfFI.length );
System.debug("File Details0: " + ovfFI[i].cimType );
System.debug("File Details1: " + ovfFI[i].create );
System.debug("File Details2: " + ovfFI[i].path );
System.debug("File Details3: " + ovfFI[i].deviceId );
System.debug("File Details4: " + ovfFI[i].size );
System.debug("File Details5: " + ovfFI[i].compressionMethod );
}

var httpNfcLease = null;

httpNfcLease = resourcepool.importVApp(spec, vmfolder, vchost);

for(;;){
     System.debug("Lease in loop state: " + httpNfcLease.state.value  );


     if( httpNfcLease.state.value == VcHttpNfcLeaseState._ready || httpNfcLease.state.value == VcHttpNfcLeaseState._error)
     {
          break;
     }

}

System.debug("Lease state: " + httpNfcLease.state.value  );
System.debug("Error: " + httpNfcLease.error.localizedMessage );

thanks

0 Kudos
slahy
Enthusiast
Enthusiast

Ok I have worked out a little bit more of the puzzel, if I run another workflow like create basic vm while i am waiting for the httpnfclease to finish inatilizing it will change to ready state and the workflow continues and completes correctly with the side effect of the addition vm being created also.

What I would like to know is what can I put in my code to have the same effect without haveing to run a second workflow? Something that would query the vcenter or poll for updates. It seems that the httpnfclease is either not reporting its new state without the second workflow being run or the lease is some how hung and the creating of another vm forces it to continue . Any help on this would be appricated.

I should also mention I have tried the plug in suggested by Christoph above but it has the httpnfclease issue also .

thanks

sean.

0 Kudos