While attempting to delete a logical port, that is you detached a VM from the segment, but the port is still present in the NSX-T UI.
VMware NSX
VMware NSX-T Data Center
This is a known issue Impacting NSX-T.
Future enhancements are planned to NSX to auto cleanup existing stale ports.
Please see additional info for scripted workaround if there are very large numbers of ports present. Below workaround is suited for low numbers of known ports..
Workaround:
In the NSX-T manager UI, under Policy view, find the port (Networking > Segments > click on blue number of Ports for Segment), click the ellipsis (3 vertical dots) of the port, and select the Delete option.
If this operation fails, you can use the below API call the with the HEADER x-allow-overwrite = true to remove the logical port:
DELETE /api/v1/logical-ports/<Logical-Port-UUID>?detach=true
Steps:
Login to the NSX-T manager as user admin.
Switch to root account using the command "st en"
Run the following command to delete the logical-port(s)
curl -l -k -u 'admin' -H 'Content-Type:application/json' -H 'X-Allow-Overwrite: true' -X DELETE "https://<nsx-manager-ip>/api/v1/logical-ports/<Logical Port UUID>?detach=true"
Where Logical Port UUID is the port id to be deleted.
For example the below highlighted is the port id for VM <VM-name>.
The port uuid we can be obtained from the Manager view in NSX
ie Networking ---> Logical Switches ---> Click on the Logical Switch
Alternatively, you can force delete the logical switch with the following API call directly, or in curl format:
DELETE /api/v1/logical-switches/<logical-switch-UUID>?detach=true&cascade=true
curl -l -k -u 'admin' -H 'Content-Type:application/json' -H 'X-Allow-Overwrite: true' -X DELETE "https://<nsx-manager-ip>/api/v1/logical-switches/<logical-switch-UUID>?detach=true&cascade=true"
Name |
Description |
Type | Notes |
---|---|---|---|
cascade | Delete a Logical Switch and all the logical ports in it, if none of the logical ports have any attachment. | boolean | Default: "False" |
detach | Force delete a logical switch If this is set to true, then logical switch is deleted regardless of whether or not it is added to NSGroup. If cascade is set to true in the meantime, then logical switch and all logical ports are deleted regardless of whether any logical port in this switch has attachments. |
boolean | Default: "False" |
For additional information on the API details: NSX-T Data Center REST API
Related Knowledge Base articles
Scripted cleanup of stale ports - Scripted cleanup of stale logical ports on NSX segments