In this article described about Delete Org VDC network in vCloud Director for hung network.
My experience with VMware vCloud Director 10.2 is that you cannot delete an organization network, even if it is definitely no longer in use. When I tried deleting the network, the following error message appeared.
Brief overview about network concept in VMware vCloud Director.
Symptoms Delete Org VDC network:
Deleting Org VDC networks from the vCloud Director UI fails with the error. Entity Dev_87test cannot be deleted, because it is in use.
Cause
This issue occurs due to stale child entries in the VMware vCloud Director database.
Resolution
This is a known issue affecting all versions of VMware Cloud Director. unable to delete network in vdc from VMware vCloud Director.
Prerequisites:
Backup of the Cloud Director database must be taken before attempting to make any changes to it directly.
Workaround for Delete Org VDC network:
To work around the issue, the stale entries will need to be removed from the VMware vCloud Director database.
To verify and remove the stale entries, follow the steps below:
Step1. Take a backup of the VMware Cloud Director database before making any changes.
Step2. Get the details of the Organization Virtual Data Center (OVDC) Network by running the following query:
select * from logical_network where name like '%YOUR_NETWORK_NAME%' and scope_type = 2;
Note: The scope_type defines the type of network as below.
scope_type 1 is for External Networks
scope_type 2 is for Org VDC Networks
scope_type 3 is for vApp Networks
Step3. Verify the Org VDC Network we got in the above output is the affected one with:
select * from logical_network where id = 'ID_OF_THE_NETWORK_FROM_STEP_2';
Note: This step will confirm the network as it is possible to use the same name for multiple networks. Be aware that if an Org VDC Network’s name was changed the Direct vApp Networks which are copies of this Org VDC network will not change name.
Step4. Verify if there are any vApp Networks connected to the Org VDC Network:
select * from logical_network where link_lnet_id = 'ID_OF_THE_NETWORK_FROM_STEP_2' and scope_type = '3';
Step5. Verify if there are any vApps connected to the Org VDC Network:
select * from vm_container where sg_id IN (select scope_id from logical_network where link_lnet_id = 'ID_OF_THE_NETWORK_FROM_STEP_2' and scope_type = '3');
Note: If vApps or vApp Templates are listed these should be removed from the vCloud Director UI, the Org VDC Network deletion retried from the UI, and if the issue persists restart the from step 1 above.
Be aware that vApps or vApp Templates may be present as Expired or Stranded Items in the vCloud Director user interface (UI).
Step6. If any vApp Networks were returned in Step 4, verify if any VMs or Edges are connected to each vApp Network.
For VM(s): select count(1) from network_interface where lnet_id = 'ID_OF_THE_VAPP_NETWORK_FROM_STEP_4';
For Edge(s): select count(1) from gateway_interface where logical_network_id = 'ID_OF_THE_VAPP_NETWORK_FROM_STEP_4';
a. If the Steps 5 and 6 returned no results, then the vApp Networks can be safely removed from the database. Run the below command for each vApp Network respectively:
delete from logical_network where id = 'ID_OF_THE_VAPP_NETWORK_FROM_STEP_4' and scope_type = '3';
b. If the Step 6 returns a result for Edges these Edges will need to be removed using the following steps:
I. List the Edge Gateway Interfaces connected to the vApp Network:
select * from gateway_interface where logical_network_id = 'ID_OF_THE_VAPP_NETWORK_FROM_STEP_4';
II. List the Edge Gateway which owns these interfaces:
select * from gateway where id in (select gateway_id from gateway_interface where logical_network_id = 'ID_OF_THE_VAPP_NETWORK_FROM_STEP_4');
III. List the IP addresses on these Edge Gateway Interfaces:
select * from gateway_assigned_ip where gateway_interface_id in (select id from gateway_interface where logical_network_id = 'ID_OF_THE_VAPP_NETWORK_FROM_STEP_4');
select * from allocated_ip_address where id in (select allocated_ip_address_id from gateway_assigned_ip where gateway_interface_id in (select id from gateway_interface where logical_network_id = 'ID_OF_THE_VAPP_NETWORK_FROM_STEP_4'));
IV. List the MAC addresses on these Edge Gateway Interfaces:
select * from gateway_assigned_mac where gateway_id in (select gateway_id from gateway_interface where logical_network_id = 'ID_OF_THE_VAPP_NETWORK_FROM_STEP_4');
V. Delete the assigned MAC from Edge if returned in step D. above:
delete from gateway_assigned_mac where gateway_id in (select gateway_id from gateway_interface where logical_network_id = 'ID_OF_THE_VAPP_NETWORK_FROM_STEP_4');
VI. Delete the IP addresses on these Edge Gateway Interfaces if returned in step C. above:
delete from gateway_assigned_ip where id = <gateway_assigned_ip.id values from Step C. above>;
delete from allocated_ip_address where id ='<allocated_ip_address.id values from Step C. above>';
VII. Delete the Edge Gateway Interfaces connected to the vApp Network:
delete from gateway_interface where gateway_id = '<gateway.id from Step B. above>';
7. Verify if the vApp Networks have been successfully deleted by confirming the following statement gives not results:
select * from logical_network where link_lnet_id = 'ID_OF_THE_NETWORK_FROM_STEP_2';
8. Delete the Organization VDC network from the VMware Cloud Director UI.
conclusion:
Delete Org VDC network in vCloud Director has been explained in this article. please let me know if you have any questions.