KB: vCloud Director 9.5 – Publish UI Plugin to specific organizations

Use these (with caution) commands to publish a vCloud Director's UI plugin to specific organisations of your deployment:

 1# Prepare settings
 2vcloud_host="vcd.vuptime.io" # specify your vcd host
 3vcloud_token="ff27f9fde1784b4289c58e7f848190c7" # specify an auth token for a system administrator account
 5# Get the plugin ID
 6curl -ks -H "x-vcloud-authorization: $vcloud_token" https://$vcloud_host/cloudapi/extensions/ui | python -m json.tool # get the appropriate ID
 7plugin_id="urn%3Avcloud%3AuiPlugin%3Ace095910-f925-4de3-ae98-8a6c868d62f5" # You can use an url encoder tool like https://www.urlencoder.org/
 9# Unpublish UI Plugin for ALL organizations
10curl -ks -H "x-vcloud-authorization: $vcloud_token" -H "Accept: application/json" -X POST "https://$vcloud_host/cloudapi/extensions/ui/$plugin_id/tenants/unpublishAll"
12# Get target org's URN ID+name:
13curl -ks -H "x-vcloud-authorization: $vcloud_token" -H "Accept: application/*+xml;version=31.0" "https://$vcloud_host/api/query?type=organization&format=references&pageSize=128"
15# Send the correct data for UI publication
16curl -ks -H "x-vcloud-authorization: $vcloud_token" -H "Accept: application/json" -H "Content-Type: application/json" -X POST "https://$vcloud_host/cloudapi/extensions/ui/$plugin_id/tenants/publish" -d '[
17  {
18    "name": "Org1",
19    "id": "urn:vcloud:org:82e52bcd-bcfa-4d7a-b0b8-25b0f246d5c3"
20  },{
21    "name": "Org2",
22    "id": "urn:vcloud:org:8c4617d3-7705-48d3-a389-e9e3729dc9ee"
23  }
26# Check publication
27curl -ks -H "x-vcloud-authorization: $vcloud_token" -H "Accept: application/json" "https://$vcloud_host/cloudapi/extensions/ui/$plugin_id/tenants/"

To (re-)publish UI plugin for all organizations back:

1# Publish for ALL
2curl -ks -H "x-vcloud-authorization: $vcloud_token" -H "Accept: application/json" -X POST "https://$vcloud_host/cloudapi/extensions/ui/$plugin_id/tenants/publishAll"