NSX Bytes: Unable to Remove Logical Switch: Resources are still in use

I came across an situation today where I was doing a clean up of Logical Switches in my NSX Lab where I was unable to remove a logical switch due to it apparently still being in use.

Not a very helpful error however this was due to the fact I had provisioned a few NSX Edges and vShield Edges for use with vCloud Director Virtual Datacenters I needed a way to work out what resource was still hooked up to this Logical Switch.

Heading to the NSX Manager via SSH I followed the Manager Log and tried to remove the logical switch again:

Taking a look through the log output the important information is contained in this line:

So, lets search for this PortGroup via PowerCLI:

In my case the PortGroup in question was part of a vCD OrgvDC Network that still had a VM connected to it. Once I removed the VM, took sharing off and deleted the Direct Network from vCD I was able to go back into the Web Client and successfully remove the Logical Switch.

Of course…there is an easier way than that to see which resources where attached to the Logical Switch…By taking note of the Logical Switch Segment ID you should be able to search through vCenter for the PortGroup that has that Segment ID number in the name and trace back by that…

 

But where is the fun in that? 🙂