VMware Cloud Community
pascallaroche99
Enthusiast
Enthusiast
Jump to solution

Change workflow input during the execution of the workflow

Hi all,

I created a workflow to deploy a virtual machine for one of my customer. The workflow deploy a VM from a template, connect the nic to a DVportgroup, run sysprep if needed, add disk if needed, change ram if needed, change CPU if needed and install a bunch of software for the VM to be compliant in the customer environment.

During the deployment, if the user want to add a disk to his VMs, he needs to answer a simple question and enter the size of his disk. The format (thick or thin) is automatically selected as per as their standard.

My workflow is running and work well but they want to add an option for a number of disk. Let's say a user want to add three disks! I add this fields : How many disks you want to add? And put the answer in a Number variable. I added a counter after the add disk workflow as you can see in the picture below.

adddisk.JPG

When the counter reach the number of disk the user wants, it will go to the next steps.

This work but always create the disk with the same variable of size, so all disk have the same size! That's not very handy! Smiley Happy 

I want to know what is the best way to have a size variable for each drive to be created? The number will never be the same. Let's say i want to add 3 disks, one of 250Gb, 300Gb and 350Gb. I want to let my user enter 3 sizes variable.

I guess i will have to ask my user to enter the different size separated by a ; or , and in the code read those numbers. This will be stored in one variable. But, is there other way?

Thanks for taking time to read and helping!

Tags (3)
1 Solution

Accepted Solutions
Burke-
VMware Employee
VMware Employee
Jump to solution

You can prompt for how many drives do you wish to have, then depending on the answer, prompt for the size of each drive. Once you have the variables you can update your loop for adding drives to use the correct size for each drive. Not terribly complex actually and it provides for nicer input than having user delimit sizes with colons, commas or whatever.

Take the drive size inputs and put them into an array. This way, as you add each drive, the index should match for each drive... for example:

Inputs:

driveCount (number)

driveSize1(number)

driveSize2(number)

driveSize3(number)

// Create array to store drive size inputs

var drives = new Array();

// Only store drive size if it has been defined. I went simple, from the top of my head here and chose > 0 to determine..

if (driveSize1 > 0) drives.push(driveSize1);

if (driveSize2 > 0) drives.push(driveSize2);

if (driveSize3 > 0) drives.push(driveSize3);

.... now, as you loop through to add your drives:

before your add Disk sub-workflow, put in a scriptable task that sets current disk size:

// something along the lines of:

var diskSize = drives[loopCounter];

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 vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter

View solution in original post

0 Kudos
5 Replies
Burke-
VMware Employee
VMware Employee
Jump to solution

You can prompt for how many drives do you wish to have, then depending on the answer, prompt for the size of each drive. Once you have the variables you can update your loop for adding drives to use the correct size for each drive. Not terribly complex actually and it provides for nicer input than having user delimit sizes with colons, commas or whatever.

Take the drive size inputs and put them into an array. This way, as you add each drive, the index should match for each drive... for example:

Inputs:

driveCount (number)

driveSize1(number)

driveSize2(number)

driveSize3(number)

// Create array to store drive size inputs

var drives = new Array();

// Only store drive size if it has been defined. I went simple, from the top of my head here and chose > 0 to determine..

if (driveSize1 > 0) drives.push(driveSize1);

if (driveSize2 > 0) drives.push(driveSize2);

if (driveSize3 > 0) drives.push(driveSize3);

.... now, as you loop through to add your drives:

before your add Disk sub-workflow, put in a scriptable task that sets current disk size:

// something along the lines of:

var diskSize = drives[loopCounter];

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 vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
0 Kudos
cdecanini_
VMware Employee
VMware Employee
Jump to solution

From where is the customer starting the workflow.

If this is from vCAC / vRA the following works:

You can define an array of composite type of type Disk that has for field Name (string), Size (number)

Screen Shot 2015-01-13 at 20.46.42.png

Screen Shot 2015-01-13 at 20.47.07.png

Screen Shot 2015-01-13 at 20.48.01.png

If the customer start the workflow from a UI not supporting composite types then you can have a first field with the number of disks (nbDisk) then create diskName1 diskSize1 ... diskNameN diskSize N inputs. Then put each inputs under a different presentation section, then for each section put a show presentation properties with a condition #nbDisk >=1 for the first one, #nbDisk >=2 for the second and so on.

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
pascallaroche99
Enthusiast
Enthusiast
Jump to solution

Thanks for your fast answer, ill try this!

0 Kudos
cdecanini_
VMware Employee
VMware Employee
Jump to solution

And I forgot to mention that if you use composite types you can access to the array elements like this:

for each (var element in arrayOfCompositeType) {

     var name = element.get("Name");

     var size = element.get("Size");

}

Using composite types is the solution IF the number of disks is not known (and usually can get high enough so you do not want to have too many inputs). If the number is low then using inputs for each name and size is going to be more convenient in terms of scripting and for validating inputs.

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
pascallaroche99
Enthusiast
Enthusiast
Jump to solution

You guys are awsome and so responsive!

That work like a charm, thank you very much!

Smiley Happy