views

Search This Blog

Thursday, December 31, 2020

How to use custom form for Single Pattern (Blueprint) for Widows and Linux and add additional resource during deployment

 

In this post I am going to describe , How to create single  Pattern (Blueprint) for Widows and Linux  using custom form  to achieve client use cases. 

As all you know  VRA8.X yaml play very critical role in designing the blueprint . I am going to describe 3 very common use cases which all customers ask to develop in simple Pattern.

First I would like to introduce about my environment and  customer use cases . 

 My environment details :

vCenter with two templates Windows and Linux 7.x

Two customization spec for Windows and Linux

One vRA 8 with vCenter Endpoint and one Project  and two network profile ( One for production and Second for Management)

 

Use cases –

1-    The client  want to see the dedicated network as per the environment .   Client can see  either   production  or  Management  network  during deployment time ,  I decided to set the network  as per production  and Management  environment selection .

 

2-    The client wants to have a choice to select between Windows and Linux in same blueprint.  In this case  we need to create two patters and assign an appropriate Image to each of them but  I have decided to set the system selection as an option and assign appropriate  customization spec to Image .

 

3-    The client want to have a choice to add extra disk during the provisioning time.

This use case can  be done in many other ways like VRO workflow and so on but I have decided  to create  custom form and yaml to accomplish this use case . 

 

 

Let’s Start ……….

My Blueprint form looks in that way.

 


 















👆 

Note:  1- When client  select Zone as “production” then network name “MTO-PROD-Net01” get assign as per zone . I have set the conditional value .

2- . when client select OS-Image as Windows 2016 (MTO-PROD-Win16) then Customization name “vra8win” get assign as per OS-Image . I have set the conditional value here as well.

3-Once client want to add additional disk and  choose the Required value as Yes then client  can enter disk size .


 











👆

Note:  1- When client  select Zone as “Management” then network name “MTO-DEV-Net01” get assign as per zone . I have set the conditional value .

 2- . when client select OS-Image as Linux 7.X (MTO-PROD-LIN7) then Customization name “vra8Lin” get assign as per OS-Image . I have set the conditional value here as well.

 3-If  client do not want to add additional disk and  choose the Required value as NO  then automatically 1 value will appear for both disk.

To do that I have set the conditional value in the custom form for optional disk.

 Now we need to create YAML code  in blueprint .

 I have created a blueprint which have one vsphere machine , one network and two Optional disk  . Here is the my Blueprint  looks like.


 






 

 

My code looks like this:-

 

formatVersion: 1
inputs: {}
resources:
  Cloud_vSphere_Machine_1:
    type: Cloud.vSphere.Machine
    properties:
      image: MTO-PROD-LIN7
      cpuCount: 1
      totalMemoryMB: 1024
      networks:
        - network: '${resource.Cloud_vSphere_Network_1.id}'
      attachedDisks:
        - source: '${resource.Cloud_vSphere_Disk_1.id}'
        - source: '${resource.Cloud_vSphere_Disk_2.id}'
  Cloud_vSphere_Network_1:
    type: Cloud.vSphere.Network
    properties:
      networkType: existing
  Cloud_vSphere_Disk_2:
    type: Cloud.vSphere.Disk
    properties:
      capacityGb: 1
  Cloud_vSphere_Disk_1:
    type: Cloud.vSphere.Disk
    properties:
      capacityGb: 1


This is a standard  blueprint  but I want to do more  customize  as much as I can that I have created t-shirt size  for   CPU and memory as an selection option for client . We need to create flavour mapping for this request 

 

SelectFlavor:

    type: string

    enum:

      - MTO-PROD-LARGE

      - MTO-PROD-MEDIUM

      - MTO-PROD-SMALL

 

Now we have given option to select  the CPU and memory but it is not enough to achieve simple pattern . If  client wants to have a choice between Windows and Linux in single blueprint along with their associate customization spec.    I decided to set the system selection as an option  and attached respective  customization spec.

 

os-image:

    type: string

    oneOf:

      - title: MTO-PROD-LIN7

        const: MTO-PROD-LIN7

      - title: MTO-PROD-LIN8

        const: MTO-PROD-LIN8

      - title: MTO-PROD-Win16

        const: MTO-PROD-Win16

  custom_spec:

    type: string

    enum:

      - vra8win

      - vra8Lin

    default: vra8win

    title: Customization Name

    description: Customization Name

 

The next use case is the network, we should also give the user a choice to select network  as per their deployment .


net_name:
    type: string
    enum:
      - MTO-PROD-Net01
      - MTO-DEV-Net01
    default: MTO-PROD-Net01
    title: Network Name
    description: Network Name
 
Next use case is optional disk  , we should also give the user a choice
 to select addition disk during VM deployment time . 
 
title: Choose the size of VM
  Disk1Size:
    type: integer
  Disk2Size:
    type: integer
Cloud_vSphere_Disk_1:
    type: Cloud.vSphere.Disk
    properties:
      capacityGb: '${input.Disk1Size}'
  Cloud_vSphere_Disk_2:
    type: Cloud.vSphere.Disk
    properties:
      capacityGb: '${input.Disk2Size}'
 
Here is the Yaml Code for the same which going to cover above use case .
 
 

 
 
 
  
 
 
  
 
 
 
 
 





 









 

 Our YAML code for blueprint  is completed . Now time to  pass it on the Service Broker portal.

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

Sometime  client  unknowingly choose values that do not match  and it create problem during or after deployment  (e.g. Linux  customization for Windows . Management (DEV) IP for Production VM  ) . I decided to limit the choice of customization and network  only by informing what was chosen by using custom forms.

Now we need to select custom form   in service broker .

Click on Content & Policies and go to content.


 



 



 


On Custom_Spec  we need to marked this field as read only but it will visible to client over the form . 

 


 







 

 

 

We need to  setup a Values which depends what user is going to setup in Image.


 

 








 

 

Same way need to setup value for network selecting  while selecting Zone .




 


 



 

 

 

 

To create the disk during the provisioning time we need to get Cloud_vSphere_Disk object for each disk and then map it to Cloud_vSphere_Machine.

Now we can define  default value when end user choose  No for extra disk  over the form.

 


 





 

Now we have finished the topic of simple pattern and as you can see it is not so hard as it is  simple configuration we achieve our goal.

I hope you enjoy reading this blog as much as I enjoyed writing it. Feel free to share this on social media if it is worth sharing

No comments:

Post a Comment

Deploy Windows VMs for vRealize Automation Installation using vRealize Suite Lifecycle Manager 2.0

Deploy Windows VMs for vRealize Automation Installation using vRealize Suite Lifecycle Manager 2.0 In this post I am going to describe ...