VMware Cloud Community
GarTomlon
Enthusiast
Enthusiast
Jump to solution

Create an array of VMS from a Predefinied array of VMs

I am not even sure if that makes sense.  Hope that it is clear.  What I would like to accomplish is have a predefined array of VMs.  I am assuming that this can be an attribute that I create as Name - vmsList with a type of ArrayVC:VirtualMachine.  I would then populate the array with the VMs I would like to select from.  I would also think I would create another attribute called selectedVMs.  This would also be an ArrayVC:VirtualMachine.  I would like to be able to be presented with the vmsList array and select the VMs I want and it be populated to selectedVMs array.  I am guessing that I am just missing the middle part.  Any help would be appreciated.  Thanks

0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

Yes, this can be done.

Add an input parameter to your workflow, let's say parameter with name arg_in, of type Array/VC:VirtualMachine. Go to presentation tab in the vRO client, select this input parameter, and add the property Predefined list of elements with a value #vmList. This will limit to set of VMs you can choose from when you start the workflow presentation to those available in the vmList attribute.

Then, you'll need to copy the list of VMs selected by the user at runtime to the selectedVMs attribute. To do so, add a new scriptable task to your workflow, add arg_in input parameter on IN tab, add selectedVMs attribute on OUT tab, and inside the scriptable task, add the following code:

selectedVMs = arg_in;

View solution in original post

3 Replies
iiliev
VMware Employee
VMware Employee
Jump to solution

Yes, this can be done.

Add an input parameter to your workflow, let's say parameter with name arg_in, of type Array/VC:VirtualMachine. Go to presentation tab in the vRO client, select this input parameter, and add the property Predefined list of elements with a value #vmList. This will limit to set of VMs you can choose from when you start the workflow presentation to those available in the vmList attribute.

Then, you'll need to copy the list of VMs selected by the user at runtime to the selectedVMs attribute. To do so, add a new scriptable task to your workflow, add arg_in input parameter on IN tab, add selectedVMs attribute on OUT tab, and inside the scriptable task, add the following code:

selectedVMs = arg_in;

sbeaver
Leadership
Leadership
Jump to solution

I am going to take a shot at this without having my computer in front of me...

I believe you are going to have the best results by really taking advantage of the presentation layer of vRO.

If you are using the vCheck workflows, i am going to recommend using part of that process.  There is a helper workflow called vSphereObjects.  What this workflow does is it gathers up different arrays of information like all virtual machines, all host systems, all vCenter servers, datastores and such and stores that information in a Configuration Element.So lets say you have a vmList attribute of an array of VC:VcVirtualMachineP

In your new workflow you have an input parameter of selectedVMs that is an array of VC:VcVirtualMachine and in the presentation tab you configure a "Predefined answers" that list all the vm's iin the configuration element.  While your at it you can also other Properties like "Allow same values" :No so you don't add duplicate values.

I think this should help get you started with what you are looking to do.

Cheers!!

Steve

Steve Beaver
VMware Communities User Moderator
VMware vExpert 2009 - 2020
VMware NSX vExpert - 2019 - 2020
====
Co-Author of "VMware ESX Essentials in the Virtual Data Center"
(ISBN:1420070274) from Auerbach
Come check out my blog: [www.virtualizationpractice.com/blog|http://www.virtualizationpractice.com/blog/]
Come follow me on twitter http://www.twitter.com/sbeaver

**The Cloud is a journey, not a project.**
GarTomlon
Enthusiast
Enthusiast
Jump to solution

I am sure that both of these would have worked, but I just happened to get to this suggestion first and it worked like a champ.

0 Kudos