Prerequisites
- Ensure a recent backup of the NSX environment is available before proceeding.
- Verify that no Virtual Machines (VMs) are actively connected to the port group associated with the target segment.
Phase 1: Verification in vSphere Client
Before initiating any deletion, confirm that the segment is completely unused on the compute side.
- Log in to the vSphere Client.
- Navigate to the Networking inventory view.
- Expand the datacenter and folder structure to locate the target distributed port group/segment.
- Select the port group.
- Click on the VMs tab in the central pane.
- Verify that the list is empty (it should state "No items found"). This confirms no VMs are attached.
Phase 2: Identify the Logical Switch UUID in NSX Manager
- Log in to the NSX Manager UI.
- Ensure you are operating in Manager Mode (toggle located at the top right of the UI).
- Navigate to Inventory > Switches > Logical Switches.
- Locate the target logical switch in the list. Note that its Admin Status should indicate "Down".
- Click on the logical switch name to view its detailed properties.
- In the Summary tab, locate the ID field.
- Copy the ID
Phase 3: Force Delete via NSX API
Since the segment has stale interfaces, standard UI deletion might fail. A force delete via API is required.
Option A: Using an API Client (e.g., Postman/SoapUI)
- Open your API client and configure the authentication (Basic Auth using NSX admin credentials).
- Set the HTTP Method to DELETE.
- Construct the Endpoint URL: https://[NSX-Manager-IP]/api/v1/logical-switches/[Logical-Switch-UUID]?detach=true&cascade=true
- Navigate to the Headers section of your request.
- Add a new custom HTTP Header: Key: X-Allow-Overwrite, Value: true
| 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" |
Option B: Using cURL Command
Alternatively, execute the following command from a terminal with network access to the NSX Manager:
curl -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"
Phase 4: Verify Deletion via API and Manager UI
- In your API client, change the HTTP Method to GET.
- Request the standard logical switch endpoint: GET https://[NSX-Manager-IP]/api/v1/logical-switches/[Logical-Switch-UUID]
- Verify that the response returns a 404 Not Found status with an error message stating "The requested object could not be found."
- Return to the NSX Manager UI (Manager Mode).
- Refresh the Inventory > Switches > Logical Switches page. The switch should no longer be present in the list.
Phase 5: Cleanup Segment in Policy Mode
- In the NSX UI, toggle the view from Manager Mode back to Policy Mode.
- Navigate to Networking > Connectivity > Segments.
- Expand the segment list and locate the target segment that was just force-deleted on the backend.
- Click the three vertical dots (Actions menu) next to the segment name.
- Select Delete from the dropdown menu.
- A warning prompt will appear stating: "Are you sure you want to delete [Segment-Name]? This action is permanent and cannot be recovered."
- Click the DELETE button to confirm and remove the stale policy object.