Today’s troubleshooting tidbit – If you have issues removing a NSX Segment that got removed from NSX Policy UI but NSX Manager UI still shows that the segment is being used and active and cannot delete, well no problem at all. We will clean it up.
For More Reference VMware has a published KB for this here.
Below you will see that my vmw-vsan-segment that was stuck and said it was dependent on another configuration, but it was not. This segment was created from within VMware Cloud Director.
Confirm that there are no ports in use with the Logical Switch which was not deleted
Lets SSH into one of your NSX Managers, then we will execute the command below Run get logical-switches on the Local Manager CLI and confirm the stale Logical Switch is listed, and note its UUID
get logical-switches
Elevate to root shell with command below
Engineering Mode
Use st en to enter engineering mode which is root privileged mode
st en
Confirm the Logical Switch info can be polled with API:
curl -k -v -H “Content-Type:application/json” -u admin -X GET “https://{mgr_IP}/api/v1/logical-switches/(LS_UUID)“
Example of my command below:
curl -k -v -H "Content-Type:application/json" -u admin -X GET "https://172.16.2.201/api/v1/logical-switches/e2f51ece-99fe-417a-b7db-828a6a39234b"
Remove stale Logical Switch objects via API:
curl -k -v -H “Content-Type:application/json” -H “X-Allow-Overwrite:true” -u admin -X DELETE “https://{mgr_IP}/api/v1/logical-switches/{LS_UUID}?cascade=true&detach=true“
Example of my command below:
curl -k -v -H "Content-Type:application/json" -H "X-Allow-Overwrite:true" -u admin -X DELETE "https://172.16.2.201/api/v1/logical-switches/e2f51ece-99fe-417a-b7db-828a6a39234b?cascade=true&detach=true"
Now you should see a return ‘200’ response code if deletion is successful
That is all, we successfully cleaned up our NSX Segment that was stuck!