Created
March 24, 2021 14:51
-
-
Save Zsoldier/4a99dc07e267e8782ec1d95bb94fef77 to your computer and use it in GitHub Desktop.
Gets NSX-T BGP Route Table via curl and jq.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Have not figured out how to have jq output an array for bash to loop through. | |
nsxt=DNSnameORIPAddressofNSXTManager | |
username=admin | |
password='superduperSecure!' | |
endpoint='policy/api/v1' | |
#Checks to see if you have jq installed. | |
if ! command -v jq &> /dev/null | |
then | |
echo "jq is needed for code for below code to work. Download or use brew/apt/packagemanager to install. https://stedolan.github.io/jq/" | |
exit | |
fi | |
t0path=$(curl -k -u $username:$password --request GET --url https://$nsxt/$endpoint/infra/tier-0s/ | jq -r '.results[].path'); | |
localepath=$(curl -k -u $username:$password --request GET --url https://$nsxt/${endpoint}${t0path}/locale-services | jq -r '.results[].path') | |
bgpneighborpaths=$(curl -k -u $username:$password --request GET --url https://$nsxt/${endpoint}${localepath}/bgp/neighbors | jq -r '.results[].path') | |
echo $bgpneighborpaths | |
echo "Copy one of the paths from above and put it into a variable, like neighbor=entryfromEcho, then run the curl command below." | |
echo "curl -k -u $username:$password --request GET --url https://$nsxt/${endpoint}${neighbor}/routes | jq" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment