How to use a dynamic populated drop-down list with vRA 7 default IaaS blueprints

With vRA 7, the functionality of the default IaaS blueprints are dramatically improved. One of the new cool features is the usage of dropdown lists populated by a vRealize Orchestrator action. This is something we have only seen before in ASD/XaaS blueprints.

This blog article describes how to use this new cool feature.

In my example I am going to create a drop-down list which query’s a specific vCenter folder for existing vSphere templates and returns them in the drop-down list on the request form.

  1. Create your IaaS Blueprint and drag one vsphere virtual machine on the design canvas.IaaS-blueprint-1
  2. Select the vsphere virtual machine now and you will see the General tab of it’s configuration.IaaS-blueprint-2
  3. Click on the Build Information tab and specify your vsphere template as below example. I have chosen for template name TMPL-CENTOS-VRAS because selecting a template is required in this type of blueprint. Even when it is not my intention to use this template at all.IaaS-blueprint-3
  4. Click on the Properties tab and next click on the Custom Properties sub tab. Add a new custom property with the name cloneFrom and make sure you have enabled the check box Show in Request. Otherwise you will not see this custom property on the request form.IaaS-blueprint-4
  5. You are now done with the IaaS blueprint so click Finish.
  6. Next make your blueprint available as a catalog item in your service catalog. (publish your blueprint, assign a service for this new catalog item and make sure it is part of your end users entitlement.)
  7. When you request your catalog item now, it will look like the below screenshot.Request-IaaS-blueprint-1
  8. Now it’s time to create your vRO action. So lets open your vRO client, navigate to the action section, select a folder (for where to store your action in),  click on create a new action, give it a name (in my example the name is displayTemplatesFromFolderId) and click Ok.create-vro-action-1
  9. Go to the Scripting tab of your new vRO action.                                            1. Set your Return type to Array/string                                                              2. Create two attributes. Name one attribute sdkConnection and name the other attribute vcFolderId                                                                                     3. Make sure the new attributes are of the type string                                    4. Provide the following JavaScript code:

    5. Click Save and closecreate-vro-action-2
  10. Make a note of your values for sdkConnection (fqdn of your vCenter Server) and vcFolderId (the vCenter folder group-id). In my example, I can find this information in the vRO Inventory section.action-inputsMy value for sdkConnection = pb0vcsa01.flexlab.local                              My value for vcFolderId = group-v279
  11. Now lets create a new vRA Property Definitioncreate-vra-property-definition
  12. Follow the detailed steps below                                                               1. Name your Property Definition cloneFrom (This is exactly the name as you used for your custom property configured on the IaaS blueprint)        2. For Label type Select Template                                                                       3. For Data type select String                                                                               4. For Required select Yes                                                                                     5. For Display advice select Dropdowncreate-vra-property-definition-2
  13. Instead of selecting Predefined values in the Value section, select External values.external-values
  14. A new window will open where you have to select your newly created vRO action. When selected click Ok.select-script-action
  15. Next populate the values for the Input parameters which have been captured in step 6 and finally click Ok.create-vra-property-definition-3
  16. When you now request your catalog item it will look like the below screenshot.Request-IaaS-blueprint-2
  17. Enjoy using vRA 7 !

24 thoughts on “How to use a dynamic populated drop-down list with vRA 7 default IaaS blueprints”

  1. This is great and very helpful! I was following along with your JavaScript code but I’m having trouble figuring out where you found the ‘vm’ property of ‘theVmFolder’ on line 8 which is of the object type ‘vcFolder’.

    ‘vm’ isn’t one of the listed properties of the ‘vcFolder’ scripting class, so I’m just curious.

    Thanks!

    1. Hi Chris,

      Good to hear that my post was great and very helpful. I have asked around internally and one of my colleagues came with the following answer..

      VcFolder is the base type for all folders. It corresponds directly to Folder in vCenter API and the entity type is available in childType property. vRO provides subclasses to it – you can search for VcVmFolder which has property vm. Other subclasses are VcNetworkFolder, VcHostFolder, VcDatastoreFolder and VcDatacenterFolder. None of them exists in vCenter API as such.

      I think this answers your question 😉

      Regards,

      Dennis

  2. Thank you so much! This is exactly what I am looking for. I am extremely new to JavaScript, though, and when I implement the action as written above I get this error in vRA: Unable to refresh request form from the server
    Unable to start action ‘com.webroot.util/displayTemplatesFromFolderId’. Reason ‘Action ‘displayTemplatesFromFolderId’ in module ‘com.webroot.util’ failed : TypeError: Cannot call method “getAllVmFolders” of null (unnamed script#4)’. Do you know where I could have gone wrong?

    Thanks again,
    Ann

    1. Hi Ann,

      It looks like something gets wrong with your vRO action eg. the input variabele is not populated.

      Can you try to create a new empty vRO workflow and put the action displayTemplatesFromFolderId in it. Try if you can run it from there and see what the values are of the variabele templateInFolder.. it must be something like Array[template1,template2]

      Also, did you add a vCenter host in vRO (This is your sdkConnection) ? By running the workflow “Add a vCenter Server instance” from the vCenter plugin.

      Regards,

      Dennis

      1. I have the same issue and the action completes successfully when put into a workflow and I supply the same value in the workflow as I do in the property definition. Yes the return values are Array/String.

  3. Thanks for your article!

    Though, when I clicked External Values to put in the action script, I couldn’t see the one created in Orchestrator.

      1. Hi Dennis,

        I did not set the return type as array of string. I set it as string. Does the return type matter?
        I’ll give it a try asap.

          1. Woohoo!

            I did it! Yes, it was the return type that caused the problem 😀

            Thanks in advance.

            Thang

  4. I feеl this is among the so much vital information for me.
    And i am glad studying your article. But ѕhoᥙld obseгvation on sоme general issues,
    The wеbsite taste is ideal, the articles
    is in reality nice : D. Good job, cheers

  5. It’s a pity yoᥙ don’t have a donate button! I’d witһout а dοubt donate
    to this excellent bⅼog! I guess for now i’ll settle foг book-marking and
    adɗing your RSS feed to my Google account.
    I look forward to new updates and will talk about this Ьlog with my Facebook group.
    Chat sօon!

  6. Thanks for this article! I am also having issues with actions created in orchestrator not showing up in vra. As you suggested above, i did confirm my return value says ‘array/string’, but my custom action is not showing up.

    My goal is to use this workflow to just return a list of all vm folders as we want users to select the folder to place the deployed vm in. I changed your script to simply return vcfolder rather than the template. I think this will work… if i can figure out how to select my action in vRA.

    Thanks again for a great resource

    1. Hi Matt,

      Sorry for the delay, but I am just back from my summer holidays.
      Did you manage to solve the issue? If not does the vro action works as expected in vro?

      Regards,

      Dennis

  7. Yⲟu ought to ƅe a part of a contest for one of the finest websites on the internet.
    I’m going to highly recommend this site!

  8. Hi Dennis,

    Thank you for this very useful article.
    I am trying to accomplish exactly this, but unfortunately it does no work for me.
    My issue is that after I create the vRO action I cannot access it from vRA.
    What I mean is that in the list that opens in vRA in order to choose the action, my whole container and all the actions I have created are not there.
    Do you have any ideas?

    1. Hi Dimitrios,

      Sorry for the late reply. Did you manage to solve the issue ?
      If not can you send me a screenshot of what you are seeing and could you also send me the action ?
      This shouldn’t be to hard to solve.

      Regards,

      Dennis

  9. Hi Dennis,

    I understood your concept of populating the clonefrom property. does this update the default value __clonefrom or you have to do it in the vCO using below line ?
    System.getModule(“com.vmware.library.vcac”).addUpdatePropertyFromVirtualMachineEntity(host,virtualMachineEntity,”__clonefrom”,clonefrom

    Can you please clarify

    1. Hi Vignesh,

      With my example I am generating a drop-down list with available templates in a specific vSphere folder by the usage of a vRO action (external value).
      The value you are selecting will set the value for the cloneFrom custom property. Does this make sense to you? If you are trying to set one of the values from the drop-down list as the default value, afaik that’s not possible with a vRO action only.

      Cheers,

      Dennis

  10. Hello,

    If I have two vCenter and in each vcenter have different templates. How to make work this custom properties with two vCenter and different folder-id ?

    1. Hello Mikael,

      I was on holidays so sorry for the late response.
      Did you already found a solution for your use-case?
      The key in here is the sdk connection wich is a one-to-one mapping to your vCenter server.
      Let me know if you need more assistance.

      Regards,

      Dennis

      1. Hello Dennis, great article. Can you please share how one would show all the templates on a single vCenter? I’m looking at multiple Datacenter and Folder objects. Thanks!

  11. Hi Dennis,

    Your blog posts are really helpful.

    Could you please help me get a vRA-SNOW integration vRO package which uses REST API instead of plugin where SNOW is the front end for machine provisioning requests?

    For ex: https://virtualviking.net/2015/06/15/using-servicenow-as-a-front-end-for-vrealize-automation/

    I need this vRO package for my project requirement. I tried to using the Postman POST /vco/api/workflows/{workflowid}/executions to request the machine, however ended up with

    HTTP 400 Bad Request error “The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing)”

    Request you to get me the package or some insights to write the workflow.

Leave a Reply

Your email address will not be published. Required fields are marked *