I ran into some issues in my lab while trying to delete the entities like Org vDC, Edge gateways and Org Networks on vCloud Director(happens with all the versions) . I couldn't delete the Org vDC as it was dependent on the Edge gateway. I couldn't delete Edge Gateway as it was dependent on a routed Org Network. And Org Network would not get deleted . Things like this happen when vCD losses connectivity to vShield or some activities that are performed on vCenter directly which affect the vCD environment. The best thing to do is not to mess around with the vCenter once it is added to the vCD. But sometimes things get out of hand and everything gets messed up and we need to look for a way out of it.
I tried deleting the entities on vCenter as they had lost connectivity to vCD and that made things worse. The problem with vCD is, it does not have an option to force-delete an entity. If it looses connectivity then the entities are there in the portal in an inconsistent state and you will not be able to delete them. The whole Environment looks messy. Sometimes it so happens that after deleting all the entities in an Org vDC it still does not allow you to delete the Org vDC, though all the resources that are related to it on vCenter too are deleted.
The only way to get out of this is to either get into the database level and delete the entries for these stranded/un-deletable entities or to reset the database and configure the vCD cell all over from scratch.
Obviously someone like me who does not have knowledge about SQL would not want to go to the level of deleting the entries of tables in a database. But configuring the cell all over again would require configuring all the things again. Which is again a tedious task. So i decided i will try deleting the entries and if i screw up the database i anyway have to configure the vCD cell again which i was thinking of doing initially.
After doing a lot of research online i found couple of blogs and links that spoke about deleting the entries manually on a vCloud DB level(for MS-SQL).
Lets jump straight into it. At first you need to connect to your database server and connect to your instance through SQL Management Studio(for SQL Server, not sure how this works on Oracle)
Run the below script to get the entries of all the entities like the Org vDCs, Network pools, Edge gateways and Org vDC
/****** To List the Table entries *******/
SELECT TOP 1000 [id]
,[vdc_id]
,[lr_type]
,[name]
FROM [vcloud].[dbo].[vdc_logical_resource]
Where [vcloud] is the name of the vCloud Director database instance.
Now to move the Org Networks to other Organization vDCs you will have to run the below query:
UPDATE vcloud.dbo.vdc_logical_resource
SET vdc_id = 0xabunchofUUIDnumbersfortheorganization
WHERE id = 0xabunchofUUIDnumbersforthenetwork;
Here (vdc_id) is the organization you want the network to move to and (id) is the parameter that pertains to a particular entity which you consider to move to another vDC.
If you need to delete the entry in the database table
DELETE FROM vcloud.dbo.vdc_logical_resource
WHERE id = 0xabunchofUUIDnumbersforthenetwork;
where (id) will be the id of the entity you want to delete.
And if you are someone who is familiar with SQL Database then you can figure out more commands to modify tables and makes things right.