top of page

Dynamic Fields in VCF Automation Blueprints

Writer: Brock Peterson
Brock Peterson
2 minutes ago
3 min read

I've created lots of VCF Automation Blueprints, but none of them have used Dynamic Fields. Let's create one!


We'll start with one of my Generic VM Blueprints, and riff on it. I'd like my Blueprint to do the following:

  • Ask the user which vCenter they'd like the VM in

  • Once a vCenter is selected, ask the user which Cluster they'd like to put it in

  • Once the Cluster is selected, ask the user which ESX Host they'd like it put in

  • Once the Cluster is selected, ask the user what vDPG they'd like to use


Each of these will require a vRO Action, which will be run once the user has made their selections. I'm using the embedded instance of vRO in this case, on my VCFA 8.18.1 environment. I created found vRO Actions, once for each step above.



They are aptly named as follows (created in the com.lab.vra.inputs module):

  • getVcenters

  • getClusters

  • getHosts

  • getPortGroups


The vRO Action getVcenters looks like this.



When run, it returns a string as defined.



The vRO Action getClusters looks like this:



You'll notice it takes the vcenter string as input. When run it looks like this.



The result is string vcfops, which is the only Cluster I have in this vCenter. The getHosts vRO Action looks like this:



When run, it returns an Array of my available ESX Hosts in that Cluster.



Finally, here's the getPortgroups vRO Action which takes vcenter and cluster as inputs.



When run it looks like this.



With a return array listing all available DPGs for the selected vCenter/Cluster.


I packaged these four vRO Actions up into a vRO Package called com.lab.vra.inputs, which is available here.


Next, we need to call these vRO Actions from our Blueprint inputs, they look like this.


# Created by Brock Peterson.

formatVersion: 1

inputs:

vcenter:

type: string

title: vCenter

description: Target vCenter

$dynamicEnum: /data/vro-actions/com.lab.vra.inputs/getVcenters

cluster:

type: string

title: Cluster

description: Clusters in the selected vCenter

$dynamicEnum: /data/vro-actions/com.lab.vra.inputs/getClusters?vcenter={{vcenter}}

host:

type: string

title: ESXi Host

description: Pick a host, or Any to let DRS decide

$dynamicEnum: /data/vro-actions/com.lab.vra.inputs/getHosts?vcenter={{vcenter}}&cluster={{cluster}}

portgroup:

type: string

title: Distributed Port Group

description: Distributed port groups available to the selected cluster

$dynamicEnum: /data/vro-actions/com.lab.vra.inputs/getPortGroups?vcenter={{vcenter}}&cluster={{cluster}}


You'll notice each Blueprint input calls $dynamicEnum with the necessary Action inputs. In practice it looks like this.



I only have a single vCenter and Cluster in this lab, so it auto-selected those, then presented me with ESX Host and DPG options based on them.


Later in the Blueprint, I use the inputs like this.


resources:

Cloud_Network_1:

properties:

name: QSNetwork

networkType: existing

constraints:

# network tagged with its own name

- tag: ${input.portgroup}

Cloud_vSphere_Machine_1:

type: Cloud.vSphere.Machine

properties:

image: ${input.os}

cpuCount: ${input.vcpuCount}

totalMemoryMB: ${input.totalMemoryMB}

name: ${input.vm_display_name}

hostname: ${input.vm_dns_name}

# Placement: compute resources (clusters) must have these tags

constraints:

- tag: vcenter:${input.vcenter}

- tag: cluster:${input.cluster}

targetHost: ${input.host}

vm_snapshot: ${input.vm_snapshot}

notes: ${input.notes}

owner: ${input.owner}

description: ${input.description}

category: ${input.category}

vcpu: ${input.vcpuCount}

memoryMB: ${input.totalMemoryMB}

networks:

- network: ${resource.Cloud_Network_1.id}

assignment: static


One thing to note here, your Compute in your Cloud Zone must have the tags referenced in constraints.



Another thing to note is that when deploying a VM into a DRS Cluster, the Host will be chosen for you unless you have a Subscription defined calling a vRO Workflow to vMotion the VM to the selected ESX Host. This is beyond the scope of this blog, but could be done. I just wanted to show you how Dynamic Fields work in Blueprints.



Now when requesting a VM via my Blueprint, it looks like this. As previously indicated, I only have a single vCenter and Cluster in this lab, but I was able to select the ESX Host and DPG from the dropdown.


If you'd like the Blueprint being referenced in this blog you can get it here. Dynamically populated fields in VCFA Blueprints are powerful with all sorts of use cases, this is just one of them. Hope it was helpful, enjoy!



Comments


    bottom of page