Overview
In this article we will cover how to dynamically select an IPAM Profile by using a custom property with a case/when statement on your blueprint and linking that custom property to a drop down on your blueprint ie; Environment to dynamically select the appropriate IPAM profile for your environment.
Considerations
- Have licensed and installed the SovLabs foundations modules
Procedure
Create a Property definition on which to base the IPAM selection
In this example, I have a value defined in my custom naming for environment (dev/test/preprod/prod). I will base my IPAM profile selection on this drop down selection. You can use any vRA VM property for this purpose.
- Select an existing OR create a new Property Definition for the user-selectable dropdown, for example; In this example, I have a drop down defined as part of my custom naming. This is called Naming_Environments and provides each of the different environments I need on my blueprint. This creates a dropdown selection on the request page for the blueprint.
Note: this is a vRA concept, and not a SovLabs construct.
Building your case statement
- From the property definition, make a note of your values. These values will be used to switch between the different IPAM profiles. (Make note of the property definition name)
In my example I have the following values:- D
- T
- E
- P
- Make a note of the Nic0 IPAM Name for the different IPAM profiles you wish to use. If you are unsure on what they are called please see the sub steps, else skip to step 3
- In vRA, click on Administration (1) → Property Dictionary (2) → Property Groups (3)
- On the right side, look for a group that is similar to SovLabs-IPAMProfile-<TenantName>_<IPAMProfileName>. See the image below as an example:
- The text after the <TenantName>_ is the profile name. Write these down as you will need these for the case statement. For example, mine could be ADDNS_IPAM, BTDiamon-Ipam-Profile and CustomProperty
- In vRA, click on Administration (1) → Property Dictionary (2) → Property Groups (3)
- Now you have your Property Definition name, Values and IPAM profile names. We can build the statement (Please see additional notes for a link to case/when statement usage)
The case statement should be formatted like the following:
{% case <what to compare to> %}{% when '<value>' %}Ipam Profile Name{% when '<value>' %}Ipam Profile Name{% when '<value>' %}Ipam Profile Name{% else %}Ipam Profile Name{% endcase %}
- The last statement {% else %} could also be a {% when '<value>' %} if you like, I have put this in since I have 4 different options and if the value does not evaluate the first 3 as true, then it must be false and match the last value.
Now you have your case statement, construct it based on the information you have noted. Mine will look like the following when completed:
{% case Naming_Environments %}{% when 'P' %}InfoBlox_IPAM{% when 'D' %}BTDiamon-Ipam-Profile{% when 'T' %}IPAM_BlueCat90_profile{% else %}MenMice-IPAM-Profile{% endcase %}
- Now you are ready to move onto adding this to your blueprint.
Adding a custom property with your case statement to your blueprint
NOTE: I will assume that you already have a blueprint that is ready to be modified or have started a new blueprint. I will also assume you have the properties already attached that you want to set your custom property against defined and available on your blueprint. I will start from inside the blueprint and where to add the custom property
- From inside your blueprint, click on Properties (1) → Property Groups (2)
- In the property groups make sure you do not have an IPAM Profile attached. If you do please delete this from your blueprint
- inside properties, click on Custom Properties (1) → New (2)
- In the name field, type in SovLabs_IPAMProfile_nic0 (Since we are doing this for a single Nic VM it is the first network card in VMWare)
- In the value, enter the case statement you have built then click on OK
- You now have your custom property and case statement defined in your blueprint
- Click on Finish and make sure you have published your blueprint
Example Deploying your blueprint
- When you deploy your blueprint, you will be able to use the drop down you have defined. In my example it is labelled Environments.
- A test deploy to the Environment of Test should see my VM setup on my IPAM_BlueCat90_Profile.
- In vRO browse to SovLabs → IPAM → IPAM machineBuilding
- In the logs for my VMBuild, I can see that the appropriate IPAM profile has been select and run
Additional information
Template Engine - Case/When : http://docs.sovlabs.com/latest/vmware-vra7x-plugin/framework/sovlabs-template-engine/tags/case-when/
Template Engine Intro : http://docs.sovlabs.com/latest/vmware-vra7x-plugin/framework/sovlabs-template-engine/basics/intro/
0 Comments