4 Replies Latest reply on May 21, 2018 3:27 PM by GarTomlon

    vRO dynamic dropdown list of vsphere tags based on category.

    GarTomlon Novice

      I am looking to generate a dynamic drop down list of tags based on tag categories.  I am using steps outlined in this post, but it is not generating my list.  When I run the workflow, it simply shows an input box instead of a drop down box of values.

       

      https://www.greenreedtech.com/vro-building-a-dynamic-drop-down-for-vsphere-tags/

        • 1. Re: vRO dynamic dropdown list of vsphere tags based on category.
          iiliev Virtuoso
          Community WarriorsVMware Employees

          The referenced blog post, and the code presented in it, are correct.

           

          The fact that you see edit box instead of dropdown likely means there is some error thrown during execution of the scripting action (for example, you might not have vAPI endpoint). Check your vRO log file server.log for errors, and also try to add some more logging statements to locate the piece of the code that breaks.

          • 2. Re: vRO dynamic dropdown list of vsphere tags based on category.
            GarTomlon Novice

            Thanks for the quick reply.  The endpoints are set.  I have run those workflows (have two vAPI endpoints).  I am able to run the List All Tagging Categories and List all Tags workflows successfully.  Now, I have a Tagging Category called "Tier."  I am assuming the only thing I need to change in the action is listed here

             

            ++++++++++

            // Modify with the name of the desired category

            var categoryName = "vROTags"   // Change "vROTags" to "Tier"

             

             

            // Set the VAPI endpoint to the first endpoint returned

            var endpoints = VAPIManager.getAllEndpoints();

            var endpoint = endpoints[0]

            ..........

            +++++++++++

             

             

            Is that correct?

            • 3. Re: vRO dynamic dropdown list of vsphere tags based on category.
              iiliev Virtuoso
              VMware EmployeesCommunity Warriors

              Correct. Keep in mind, however, that the code always uses the first endpoint (endpoints[0]), and as you have 2 endpoints, then endpoints[0] might point to your other vAPI endpoint, not the one who has 'Tier' category name. And the code in the blog doesn't handle the situation where it cannot find tagging category with the specified name.

               

              To handle this issue, you can do the following:

              1) make the endpoint an input parameter to be specified by the user, instead of accessing the first endpoint endpoints[0]

              2) add extra scripting code to the action to nicely handle the situation where the category with the given name cannot be found

              • 4. Re: vRO dynamic dropdown list of vsphere tags based on category.
                GarTomlon Novice

                I was looking at the snippet I pasted. and saw:

                 

                var endpoint = endpoints[0]

                 

                and got to thinking, that is the first endpoint.  And then I read the commented line (//set the vapi endpoint to the first endpoint returned).  Went and looked at my endpoints and sure enough, the endpoint with my tags was the second endpoint.  The first endpoint was a lab endpoint.  I figured I could change the number in the code, but I just simply removed the lab endpoint.  It worked.  Thank you very much.