VMware Cloud Community
GarTomlon
Enthusiast
Enthusiast
Jump to solution

Flow of Workflow - Parameters, Presentation, Predefined List of Elements.

This is an amazing group.  My questions have been answered for the most part and have been very helpful.  I have just started using Orchestrator  since Dec.  Knowledge I have gotten has all been trial and error and this group.  I have been able to figure most things out, more importantly I have been able to figure out HOW and WHY the solutions I have gotten from here work.  One area I am having trouble with is with Presentation.  Maybe because I have only used Presentation limited basis.  What I have used is creating drop down boxes or check boxes a few times.  Those have been using the Predefined list of elements, calling an action and there I am lost. Not sure what the flow is.  I see what I was told to do - I am just not grasping the HOW or WHY it works.  I see the components of the action and the Presentation calling the action, but it is just not clear. 

An example that I am working with is I have an input parameter called ISO (it is a string).  I know that I need to configure the Presentation components.  Just not sure how (more importantly the why).  The goal is that I want a dropdown list of ISO filenames.  Those files will be contained in an array.  That array is created by compiling a list of filenames on [DatastoreName]ISOFILES\

I think I am close, but the structure of the flow in how Predefined List of Elements works.  I have created one (with this groups help) and it works great.  I am just not sure why it works.  The one I created in the past allows me to select multiple VMs.  The predefined list of element for Select Virtual Machines (my Input parameter) the value is GetAction("com.test.vmudate","getDynamicVMS").call(#VMs)

My limited knowledge states that it is calling action getDynamicVMS from the com.test.vmupdate module.  As far as what call(#VMs) is, I have no idea.  Again, thanks so much for the help.

0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

Assuming chosenISO attribute is of the same type string as the isoFile input parameter, one option is to add a scriptable task item to your workflow, then add isoFile input parameter on scriptable task's IN tab, add chosen ISO attribute on scriptable task's OUT tab, and add the following code in the scriptable task's Scripting tab:

chosenISO = isoFile;

View solution in original post

10 Replies
manfriday
Enthusiast
Enthusiast
Jump to solution

#VMs is the parameter being passed to getDynamicVMS.

If you look at your input values or attributes, you should see a variable called VMs.

The contents of that is what it is passing to getDynamicVMS.

iiliev
VMware Employee
VMware Employee
Jump to solution

When you launch a workflow in the vRO client, there are 2 phases:

- presentation execution, which should collect some inputs from the user and prepare input for the next phase

- workflow execution, which should execute the actual workflow code, using the collected inputs from the previous phase

When you design the workflow in the vRO client workflow designer, you have the option to add 'properties' to the input fields. vRO uses a language called OGNL (you can google about it if you are interested) to allow a more complex logic/relations to be defined between fields. In this context, '#' character is used to reference another input or attribute, so if your workflow has an input named myinput, then #myinput would be a reference to this field.

At runtime, when you launch the workflow and presentation execution starts, vRO builds a dependency graph between all input parameters/attributes, and tracks what should happen if some dependant field value is changed. In you example, changes of VMs value will cause all presentation properties which are defined as dependant on its reference #VMs to be reevaluated. As an effect, in your case the field which has a property predefined list of elements with OGNL GetAction("com.test.vmudate","getDynamicVMS").call(#VMs) will cause the action getDynamicVMs in module com.test.vmudate to be called with input value the current value of VMs, and the result of this action invocation to be assigned as possible input values to choose from for the filed Select Virtual Machines (note that the type of the property determines how to interpret the result of the OGNL call evaluation).

Hopefully the above makes sense Smiley Happy It is a bit hard to describe what hapens internally, but you should start to feel more comfortable after you try and use it in practice.

GarTomlon
Enthusiast
Enthusiast
Jump to solution

Well, in this example, like I said, I am wanting to to be presented with a list of ISO file names.  These files are on a path on a data store. USer will be able to select one item (think radio button).  Here is what I have:

1.)  Workflow has an Input Parameter - isoFile [string]

pastedImage_0.png

2.)  I have an attribute named ds with type vc:Datastore  (I have it set to the datastore).

pastedImage_2.png

3.)  I have an action called getAPGISOs with the following script:

pastedImage_5.png

If its hard to read, it is (it has a return type of array/string.

var dsPath = "[VMDISCS]APGISO"; 

var task = ds.browser.searchDatastore_Task(dsPath); 

var searchResult = System.getModule("com.vmware.library.vc.basic").vim3WaitTaskEnd(task, null, 2); 

var retStrings = new Array();

for (var f in searchResult.file) { 

retStrings[f] = searchResult[f].file;

//System.log(file.path); 

return retString

4.)For Presentation, I have the input parameter property of Predefined list of elements, calling the action.

pastedImage_7.png

The syntax is GetAction("com.TL.apgiso","getAPGISOs").call( #ds )

I am pretty sure I am not even close.  But I would have expected/wishing to be presented with a list of the files in the datastore/folder.   Any help is appreciated.

0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

Actually, you are quite close Smiley Happy

The only problem is in the way you process the results from the search task. This line in your code:

retStrings[f] = searchResult[f].file;

should be replaced with:

retStrings[f] = searchResult.file[f].path;

The error was that the array with found files is not stored in searchResult but in searchResult.file, and after that for each enumerated file you need to retrieve its path and put it into the return array.

GarTomlon
Enthusiast
Enthusiast
Jump to solution

Thanks for the quick response.  I made that change.  (replacing with retStrings[f] = searchResult.file[f].path; ) and when I run (getting the same result)  I get a screen that states "Processing Presentation.....Pleae wait."  It then displays a screen prompting for you to input manually, instead of displaying the list of files (actually, just a single file now).

pastedImage_0.png

0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

Check vRO log files (eg. /var/log/vco/app-server/server.log); it seems that your action code might have thrown an error.

BTW, the first line of your action code looks suspicious.

var dsPath = "[VMDISCS]APGISO"; 

Usually, there is a space between datastore name and folder name, so could you change it to something like the following and try again?

var dsPath = "[VMDISCS] APGISO"; 

GarTomlon
Enthusiast
Enthusiast
Jump to solution

Well, being green, I saw that space between the datastore and the folder and thought, no that cant be right.  So, I had removed the space.  Then realize (from other workflows) that the space is valid and put the space back in.  However, I had taken the screenshot prior to changing it back.  Looked at the logs and it stated that I had not defined retStrings.  I defined it, and it worked.  Thanks so much.

0 Kudos
GarTomlon
Enthusiast
Enthusiast
Jump to solution

Ok, following the flow, I now understand how to display the files from the datastore, how can I pass the selected file to the attribute chosenISO? 

0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

Assuming chosenISO attribute is of the same type string as the isoFile input parameter, one option is to add a scriptable task item to your workflow, then add isoFile input parameter on scriptable task's IN tab, add chosen ISO attribute on scriptable task's OUT tab, and add the following code in the scriptable task's Scripting tab:

chosenISO = isoFile;

GarTomlon
Enthusiast
Enthusiast
Jump to solution

Getting clearer.  As soon as I posted that comment, I realized that very thing.  Thanks for all.

0 Kudos