Property Toolkit Using SovLabs_createProperties_

Sam Richards
by Sam Richards

Categories


Overview

In this how to, we will cover how to use the property toolkit using the SovLabs_createProperties_ method as a custom property.  

This method allows you to define multiple properties as part of a single custom property on your blueprint and pass them through into your payload for use.  Such uses could be for dynamic site selection, dynamic folder placement or even dynamic allocation in your naming just to name a few. Since this is on a single blueprint it means that these properties can not be re used against multiple blueprints unless you create the same custom property again.

There is a second method you can use which is to create a property definition and prefix it with SVL_ .  The property definition would contain all the properties you wish to define with their values and you would dynamically select these different property definitions based on user selection. This also means creating multiple property definitions and maintaining these but this can be used against multiple blueprints easily.

Please search through our articles for this other methods example if you wish to learn more.

 

Considerations

  • Have licensed the property toolkit

 

Scenario

You have a requirement to set additional attributes based on a user driven selection in the form of a drop down on the blueprint.

You have a property definition created with the following:

Definition name: My.RequestForm.Prop
Possible values:

Name Value
A A
B B
C C

The properties that we want to set based on the selection from the drop down are as follows:

If My.RequestForm.Prop == A
      Test.Prop.Foo1 == "A"
      Test.Prop.Foo2 == "blah"
      Test.Prop.Foo3 == "0"
      Test.Prop.Foo4 == "trees"
      Test.Prop.Foo5 == "prod"

 

if My.RequestForm.Prop == B
      Test.Prop.Foo1 == "Z"
      Test.Prop.Foo2 == "blahblah"
      Test.Prop.Foo3 == "1"
      Test.Prop.Foo4 == "flowers"
      Test.Prop.Foo5 == "dev"

 

if My.RequestForm.Prop == C
      Test.Prop.Foo1 == "Q"
      Test.Prop.Foo2 == "blahblahblah"
      Test.Prop.Foo3 == "2"
      Test.Prop.Foo4 == "bees"
      Test.Prop.Foo5 == "qa"

 

And if the value is none of these, set the values of Test.Prop.Foo1 → 5 to "UNKNOWN"

Template Engine

This template uses an array of name/value pairs.  The name is the name of the VM property you want to set, and the value is a valid SovLabs Template Engine template.  (See the SovLabs Template Engine article for more information)

In the example below, the Template Engine statement is a case statement which evaluates the value of My.RequestForm.Prop and outputs the desired string based on that value.

The SovLabs Template Engine we will use in our custom property is as follows:

 

[
   {
     "name": "Test.Prop.Foo1",
     "value": "AZQUNKNOWN"
   },
   {
     "name": "Test.Prop.Foo2",
     "value": "blahblahblahblahblahblahUNKNOWN"
   },
   {
     "name": "Test.Prop.Foo3",
     "value": "012UNKNOWN"
   },
   {
     "name": "Test.Prop.Foo4", "value": "treesflowersbeesUNKNOWN"
   },
   {
     "name": "Test.Prop.Foo5",
     "value": "proddevqaUNKNOWN"
   }
 ]

 

Procedure

Creating the property definition called My.RequestForm.Prop

  1. In vRA click on Administration (1) → Property Dictionary (2) → Property Definitions (3) and click on New (4)


  2. Enter the name as My.RequestForm.Prop


  3. Set the Data Type as String and required can be left as default


  4. set the display type as Dropdown


  5. Setup the static list as A,B and C (see below)


  6. Click on OK

 

Add the property definition to your blueprint

  1. In your vRA Blueprint click on Properties  (1) → Custom Properties (2) and click on New (3)


  2. Under name, enter the property definition we created


  3. Place a check in Show in Request


  4. Click on OK

Create the SovLabs_CreateProperties

  1. While still in your blueprint in Custom Properties, click on New


  2. Type in SovLabs_CreateProperties_<name>, in this example i will set this to SovLabs_CreateProperties_myFooProps


  3. In the value area, paste in the Template text from the scenario section

    [{"name":"Test.Prop.Foo1","value":"AZQUNKNOWN"},{"name":"Test.Prop.Foo2","value":"blahblahblahblahblahblahUNKNOWN"},{"name":"Test.Prop.Foo3","value":"012UNKNOWN"},{"name":"Test.Prop.Foo4","value":"treesflowersbeesUNKNOWN"},{"name":"Test.Prop.Foo5","value":"proddevqaUNKNOWN"}]



  4. Click on OK


  5. Click on Finish


  6. You now have a new drop down property on your blueprint

 

Test your blueprint

  1. On your blueprint, when you deploy you will now see a drop down, for this test we will select A


  2. Once the machine has deployed, we can look in vRO and browse to SovLabs → property Toolkit → Property Toolkit machineBuilding


  3. Scroll down until you see the machine you are building.  If the property toolkit has executed correctly we should see the following
    If My.RequestForm.Prop == A
          Test.Prop.Foo1 == "A"
          Test.Prop.Foo2 == "blah"
          Test.Prop.Foo3 == "0"
          Test.Prop.Foo4 == "trees"
          Test.Prop.Foo5 == "prod"



  4. I have run a second deployment with B selected so we can validate the following
    if My.RequestForm.Prop == B
          Test.Prop.Foo1 == "Z"
          Test.Prop.Foo2 == "blahblah"
          Test.Prop.Foo3 == "1"
          Test.Prop.Foo4 == "flowers"
          Test.Prop.Foo5 == "dev"


  5. As a test I added the option of D into my Property Definition and selected this.  We should see all of these go to Unknown as we have set this as the else component of our template text


How to see properties on the VM using Manage Properties (SovLabs Property Toolkit) on your deployed VM

  1. You can check the properties on a deployed VM.  Locate the machine you have deployed and click on the name



  2. Under components click on the VM Name (1) and click on Actions (2)


  3. Scroll down and click on Manage Properties (SovLabs Property Toolkit) - VMName


  4. Next to action, select Update Existing Property


  5. Next to Propert Picker, scroll down until you see the properties we created, in this case Test.Prop.FooN (Where N is 1 → 5), Select Test.Prope.Foo1


  6. You will see the property value that has been set


Additional information

SovLabs property toolkit : http://docs.sovlabs.com/latest/vRA/7.6/modules/vra-toolkits/property-toolkit/
SovLabs template engine : http://docs.sovlabs.com/latest/vRA/7.6/framework/sovlabs-template-engine/basics/intro/

The first step in providing reliable self-service automation for your CMP is starting a free trial.

Free Trial
Wave One Wave One
Wave Two Wave Two