We've just started building servers in our vSphere with NSX-T environment using VRA to deploy the servers. The security group placement is controlled via NSX policies that are determined by the machine's tagging. I wanted to provide a dynamic dropdown in VRA so that I did not have to recode the cloud template and subsequent service broker custom form each time a new tag value was added to vSphere. I noticed in VRA that the NSX tags were being discovered there.
This routine runs from VRO to read the tags in VRA (/iaas/api/tags) with a specific KEY, and returns the VALUE in a sorted array.
Prerequisites:
- VRO server integrated with VRA-Cloud Assembly.
- VRA Plug-in to VRO (reference: here) - need to download and install on your VRO server.
- Cloud template that needs a dropdown of tag values.
Warning: Without a filter, we have over 7,000 tags coming from NSX. When I tried to query all our tags, I crashed my VRO server and needed to reboot it to kill the query.
- Set default VRA host
- VRO - select Configurations - vRA plug-in
- Variables tab - click on defaultHost
- Click on the value field and select the VRA host you want to query.
- Save
- Create new Action
- VRO - select Library - Actions menu item
- New Action
- type in a name and module name
- typing in a 'new' name for the module will create a new module.
- Click on the Script tab and make sure Javascript is selected for Runtime.
- On the right, click Add New Input button and create a new input
- name: tagFilter
- type: string
- Change the Return type to string and check the checkbox for Array.
- Paste the code below.
- Save.
Replication:
- Log into your VRA instance
- Scroll down to Integrations and open the VRO integration
- Click the Start Data Collection button and wait...
Use:
- Log into your VRA instance
- Open a cloud template
- Browse to the Inputs menu.
- Locate or create a new input. Mine:
- Name: ApplicationTag
- Display name: Application
- Type: string
- Default Value: leave blank.
- Scroll to the bottom of the screen and expand More Options
- Pairs: External Source
- Action: click Select and search for the name you input into 2.3 in VRO above.
- Unselect BIND and type in the tag KEY value to filter on.
- SAVE to save select.
- SAVE to close Input properties
- Test cloud template - The dropdown should load for a few seconds then complete.
No comments:
Post a Comment