Created
January 14, 2022 21:06
-
-
Save Zsoldier/0b6f6187948f889890713eb75ff610c0 to your computer and use it in GitHub Desktop.
A way to forcefully delete a route advertisement filter in NSX-T. Use w/ extreme caution.
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
echo -n Enter NSX Manager IP: | |
read nsxmgr | |
echo -n Enter NSX Manager admin password: | |
read -s secret | |
# The below curl command will display logical router id's and display names for those id's. | |
curl -k -u admin:$secret https://$nsxmgr/api/v1/logical-routers/ | awk -F ': ' '/"id"/{print substr($2,2, length($2)-3)} /"display_name"/{print substr($2,2, length($2)-3)}' | |
echo -n Enter target router id: | |
read routerid | |
rulesbackup=$(curl -k -u admin:$secret --request GET --url https://$nsxmgr/api/v1/logical-routers/$routerid/routing/advertisement/rules) | |
revision=$(curl -k -u admin:$secret --request GET --url https://$nsxmgr/api/v1/logical-routers/$routerid/routing/advertisement/rules | awk -F ': ' '/"_revision"/{print substr($2,1)}') | |
#Backup of existing rules just in case ;) | |
echo $rulesbackup >> rulesbackup.txt | |
# Uncomment line below if you would like to verify data was recorded. | |
#cat rulesbackup.txt | |
# Below curl call will clear out any rules associated w/ the routerid provided. | |
curl -k -u admin:$secret -H "X-Allow-Overwrite: true" --header 'Content-Type: application/json' --request PUT --url https://$nsxmgr/api/v1/logical-routers/$routerid/routing/advertisement/rules --data '{ | |
"rules" : [ | |
], | |
"logical_router_id" : "'$routerid'", | |
"resource_type" : "AdvertiseRuleList", | |
"id" : "'$routerid'", | |
"_revision" : "'$revision'" | |
}' | |
secret='' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment