File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ # Author: William Lam (@lamw)
3
+ # Description: Using cURL to inteact with the new NSX-T Policy API in VMC using NSX-T Private IP
4
+
5
+ if [ ${# } -ne 2 ]; then
6
+ echo -e " Usage: \n\t$0 [REFRESH_TOKEN] [NSXT_PRIVATE_IP\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
+ NSXT_PRIVATE_IP=$2
18
+
19
+ 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 " )
20
+ CSP_ACCESS_TOKEN=$( echo $RESULTS | jq -r .access_token)
21
+
22
+ 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} "
23
+
24
+ NSXT_SEGMENTS_URL=" https://${NSXT_PRIVATE_IP} /policy/api/v1/infra/tier-1s/cgw/segments"
25
+
26
+ RESULTS=$( curl -s -k -X GET -H " Content-Type: application/json" -H " Authorization: Bearer ${CSP_ACCESS_TOKEN} " ${NSXT_SEGMENTS_URL} )
27
+ echo ${RESULTS} | jq
You can’t perform that action at this time.
0 commit comments