How to utilize the Yaml and Custom form & add Multiple disks during provisioning in VRA8.X

As we all know VRA8 has introduced lot of feature and capabilities and Designing the blueprint using code is one of the them .

In VRA8.X yaml play very critical role in designing the blueprint . Recently I have come across the situation where we want to add disk during the provisioning time .

This can be accomplished in many ways like VRO workflow or ABX action and so on
,One of the way I have found is use the custom form and yaml.

To set up the blueprint for the first time , Make sure we have configured Content Source, Content sharing and Content .

Here is the my Form looks like .

Note: Once we choose the Required value as Yes – end user can enter disk size ,
If end user clicked No, then automatically 1 value will appear for both disk.
To do that I have set the conditional value in the form .

To create the disk during the provisioning time we need to get Cloud Volume object for each disk and then map it to Cloud machine object on attached disk property

Here is the Yaml Code for the same.

formatVersion: 1
#-------------------Input Start Here----------------#
inputs:
  image:
    type: string
    description: <b>Choose the OS to deploy</b>
    default: VMW-PhotonOS
    title: Choose Image
    oneOf:
      - title: CentOS
        const: VMW-CentOS
      - title: PhotonOS
        const: VMW-PhotonOS
      - title: DB Machine
        const: VMW-DB
      - title: Ubentu Machine
        const: VMW-Ubuntu
      - title: Web Server
        const: VMW-Web
  Flavor:
    type: string
    enum:
      - VMW-Large
      - VMW-Medium
      - VMW-Small
    title: Choose the size of VM
  Disk1Size:
    type: integer
  Disk2Size:
    type: integer
#----------------Input End Here------------#
resources:
  Cloud_Machine_1:
    type: Cloud.Machine
    properties:
      name: PhotonOS
      flavor: '${input.Flavor}'
      image: '${input.image}'
      customizationSpec: Lin-Cust
      attachedDisks:
        - source: '${resource.Cloud_Volume_1.id}'
        - source: '${resource.Cloud_Volume_2.id}'
      networks:
        - network: '${resource.Cloud_vSphere_Network_1.id}'
  Cloud_vSphere_Network_1:
    type: Cloud.vSphere.Network
    properties:
      name: VMW-Production
      networkType: existing
  Cloud_Volume_1:
    type: Cloud.Volume
    properties:
      capacityGb: '${input.Disk1Size}'
  Cloud_Volume_2:
    type: Cloud.Volume
    properties:
      capacityGb: '${input.Disk2Size}'

Line 27-30 , we are defining the type of input from the user which is Integer
Line 40-42 , we are mapping the Cloud.Volume object to Cloud.machine object
Line 50-57 , we are mapping the input variable to Cloud.Volume object.

Lets switch to custom form side now to see how we are passing the default value when end user chooses No for extra disk

Caution: If you try to specify the value 0 , your build will get failed with below error.
Disk size should be greater than 1024 MB

To avoid this ,I have setup the minimum and maximum constraint on my form.

2 responses to “How to utilize the Yaml and Custom form & add Multiple disks during provisioning in VRA8.X”

  1. Thank you for a great post!
    I would add information, that if you want to skip creating an additional disk, the size should be set equal to 0, then it won’t be provisioned.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at WordPress.com

%d bloggers like this: