VMware Cloud Director 10 - Network cannot be deleted, because it is in use

A problem I ran into a couple of times in VMware Cloud Director 10 is that you can't delete an organization network, despite it is definitely no longer in use by anything. When you try to delete the network, the following error message is displayed:

Error: Network 172.16.1.0-24 cannot be deleted, because it is in use by the following vApp Networks: 172.16.1.0-24.

From my observation, this happens quite often when you work with Datacenter Groups, which has been implemented in VCD 10.2. But I've also seen it before. As stated in the error message, the network was added to a vApp, but actually, the vApp does no longer exist.

In this article, I'm explaining how to remove undeletable networks without messing with the VCD Database.

Before you start, double-check that the network actually no longer in use. It is easy to forget a reference.

  • Check IP Usage within the network. Only the Edge should be displayed
  • Check vApps (You can add a network to a vApp without using it)
  • Check Catalogs (The Network might be configured in Templates)
  • Check Ports in NSX-T (Networking > Segments)
  • Check Logical Ports in NSX-T Manager Mode (Networking > Logical Switches)

When there is no reference and the network is still not deletable, you can use this API to force the deletion.

If you are not sure what you are doing and this is a production environment, please consider asking VMware GSS for help.

To force the deletion, you need the network URN which can be easily copied from the URL:

There are plenty of other options like using PowerShell, or the VCD Cloud API:

# Get Network ID with PowerShell
PS> Get-OrgVdcNetwork [NAME] |select Name,Id

# Get Network ID using CloudAPI:
GET {{vcd_url}}/cloudapi/1.0.0/orgVdcNetworks/

With the network URN, you can force to delete the Network with the following API call.

DELETE /cloudapi/1.0.0/orgVdcNetworks/[URN]?force=true

Example using curl:

# curl --silent -i -k -H "Accept:application/*+xml;version=33.0" -u 'administrator@system:********' -X POST https://vcloud.virten.lab/api/sessions |grep x-vcloud-authorization
x-vcloud-authorization: 30f4276fc39e48a7a4c4e5197bb9c236
# curl -i -k -H "Accept:application/json;version=33.0" -H "x-vcloud-authorization:30f4276fc39e48a7a4c4e5197bb9c236" -X DELETE https://vcloud.virten.lab/cloudapi/1.0.0/orgVdcNetworks/urn:vcloud:network:3efc06cf-2bce-4f36-b8b9-46c8ef47ebef?force=true

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.