Encountered this error today, while trying to get rid of an old vDC that wasn’t in use anymore. That vDC had a organization network, which was shared and used in another vDC within the same organization. Looking at the organization view in networking, you can see a column named “owner”, and there the vDC that was used when creating that organization network. This option can’t be changed with the GUI, and as far as i know it can’t be changed using cli neither. Trying to delete a vDC with nothing left than these networks will give you the following error:
“- You must remove all edge gateways, networks, vApps, media, and disks from this VDC before you can delete it.”
To fix this, you need to modify your database.
NOTE! This is by no means supported by VMware, and should be done with care. Do not blame me if you end up breaking something. This worked for me and might not work for you!
That being, said, open up your database and lets search for the network in question.
SELECT TOP 100 [id] ,[vdc_id] ,[lr_type] ,[fo_handle_id] ,[fo_id] ,[prov_vdc_lr_id] ,[lr_limit] ,[is_enabled] ,[is_default] ,[version_number] ,[name] FROM [vcloud].[dbo].[vdc_logical_resource] where name like '%enter your network name here%'
From this query, note the following columns:
- id
- vdc_id
- name
And make a second query to the same database, but this time search for your vDC in question, by changing the last line in the query to your vDC name that currently owns the network.
Once you have the result from that, note that vdc_id is the same as fo_id on your vDC query that returned your vDC information. The column vdc_id tells vCloud Director, which vDC owns this network.
Now, change your query yet again and change what to look for to the vDC you want to own this network. Make note of the fo_id column (which is the same as vdc_id when searchingof vDC objects.
What we need to do is update the network with the new vdc_ic, as following:
UPDATE [vcloud].[dbo].[vdc_logical_resource] SET vdc_id = 0xENTER_YOUR_NEW_VDC_FO_ID_HERE where id = 0xENTER_THE_ID_OF_THE_NETWORK_HERE AND name = 'Your Networks Friendly Name Here'
Execute the query, and the result must be (1 row(s) affected), or otherwise something has gone wrong. Now when you look at your vCloud Director vDC Organization Network list, the owner has been changed. Now you can delete the old vDC, if you so want to :)