VMware Cloud Community
msmoritz
Contributor
Contributor

Alter vCloud Task Parameters on the Fly?

I'm building a workflow to apply mandatory customization to a vApp Template based on the username, organization, etc.  (similar to the Customize VM Sample workflow).  I trigger the workflow on the blocking task of vdcInstantiateVapp.

I'm having an issue that if when the vApp Template is added to the cloud, the "Power on after instantiation" checkbox is marked, the workflows doesn't complete before the vApp VMs power on, which results in them running first time customization with incorrect values (hostname, arguments/options to the postcustomization script).

I've found that I can tell if the user has cheched this option by using VctlTask.getParams() to retrieve the VclInstantiateVAppParams object, however, I can't seem to figure out a way to change the powerOn true to false and then have the workflow issue the deploy command after the VM customization is complete.  I looked at VclTask.update(), however it expects a VclTaskParam object, not a VclInstantiateVAppParam object. 

Is there a way to convert the VAppParam to a TaskParam, or some other way to make sure that the workflow completes before the powerOn happens?

I've already tried adding Deploy vApp as a blocking task, but that doesn't work, as the vdcInstantiateVapp task doesn't trigger a second blocking task for Deploy vApp.

e.g:

taskRef = blockingTask.getTask();

task = vcdHost.getEntityByReference(VclFinderType.TASK, taskReference);

taskParams = task.getParams(new VclInstantiateVAppParams());

if ( taskParams.powerOn == true ) {

   taskParams.powerOn=false;

   deployAfterWorkflow=true;

}

Reply
0 Kudos
3 Replies
msmoritz
Contributor
Contributor

I worked on this down a different path.  I inserted an action to set the vApp to maintenance mode before resuming the blocking task, and then exit maintenance mode when the workflow completes.  Not entirely convinced this will resolve the race condition, but seems to be the best option available.

Reply
0 Kudos
thechaos
Enthusiast
Enthusiast

Ich bin voraussichtlich ab dem 2.12.2013 wieder zu erreichen, E-Mails werden nicht weitergeleitet

Reply
0 Kudos
msmoritz
Contributor
Contributor

I'm trying to solve the issue of how to change the parameters of a pending vCloud task.

I've figured out that a VclInstantiateVappParams object needs to be shoved into the params property of a VclTaskParams object in order to use the update() method of the task.  Problem is that I can't seem to create a valid VclTaskParams object.

I've tried the utility method as well as the Scripting Class object:

code option 1

var newTaskParams=new VclTaskParams();

newTaskParams.property=value

...

code option 2

var newTaskParams=System.getModule("com.vmware.library.vCloud.schema.objects").createTaskParams( ... );

In both cases, calling task.update(newTaskParams) gives the error that the document is incomplete, and newTaskParams.toXml() is null.

Reply
0 Kudos