VMware Cloud Community
GarTomlon
Enthusiast
Enthusiast
Jump to solution

vRO dynamic dropdown list of vsphere tags based on category.

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/

Reply
0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

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

View solution in original post

Reply
0 Kudos
4 Replies
iiliev
VMware Employee
VMware Employee
Jump to solution

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.

Reply
0 Kudos
GarTomlon
Enthusiast
Enthusiast
Jump to solution

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?

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

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

Reply
0 Kudos
GarTomlon
Enthusiast
Enthusiast
Jump to solution

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.

Reply
0 Kudos