Skip to content

Commit 07c7f40

Browse files
NSX-T Overview info in VMC
1 parent 2e70b08 commit 07c7f40

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

shell/list_vmc_nsxt_overview.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
# Author: William Lam (@lamw)
3+
# Description: Using cURL to inteact with the new NSX-T Policy API in VMC to list Overview
4+
5+
if [ ${#} -ne 3 ]; then
6+
echo -e "Usage: \n\t$0 [REFRESH_TOKEN] [ORGID] [SDDCID]\n"
7+
exit 1
8+
fi
9+
10+
type jq > /dev/null 2&>1
11+
if [ $? -eq 1 ]; then
12+
echo "It does not look like you have jq installed. This script uses jq to parse the JSON output"
13+
exit 1
14+
fi
15+
16+
REFRESH_TOKEN=$1
17+
ORGID=$2
18+
SDDCID=$3
19+
20+
RESULTS=$(curl -s -X POST -H "application/x-www-form-urlencoded" "https://console.cloud.vmware.com/csp/gateway/am/api/auth/api-tokens/authorize" -d "refresh_token=$REFRESH_TOKEN")
21+
CSP_ACCESS_TOKEN=$(echo $RESULTS | jq -r .access_token)
22+
23+
curl -s -X GET -H "Content-Type: application/json" -H "csp-auth-token: ${CSP_ACCESS_TOKEN}" -o SDDC_RESULTS "https://vmc.vmware.com/vmc/api/orgs/${ORGID}/sddcs/${SDDCID}"
24+
25+
NSXT_PROXY_URL=$(cat SDDC_RESULTS|jq -r .resource_config.nsx_api_public_endpoint_url)
26+
NSXT_OVERVIEW_URL="${NSXT_PROXY_URL}/cloud-service/api/v1/infra/sddc-user-config"
27+
RESULTS=$(curl -s -X GET -H "Content-Type: application/json" -H "csp-auth-token: ${CSP_ACCESS_TOKEN}" ${NSXT_OVERVIEW_URL})
28+
echo ${RESULTS} | jq

0 commit comments

Comments
 (0)