Hello there.
I trying to remove VDC in vCloud Director, but can't do it. The problem with VDC network. When deleting it vCD answers "[ 42fa690c-2936-4525-9f32-5eae43f5b77e ] Entity LSW-VDC cannot be deleted, because it is in use.". All vApps in this VDC was removed, catalogs cleared.
I know that removing part of vCD infrastructure in vCenter Server brokes vCD and it will need to be reinstalled.
How to resolve isuue and/or safely remove unnecessary VDC ?
Hi,
What is the version of your vCD?
I believe the only way is manipulating vCD database, but this should be done with Tech Support assistance. I can try to send to you some queries to check what is "using" this network and you can try to delete it, but this is really dangerous and I really recommend you to ask Tech Support assistance.
I deal with this one almost daily and I have opened several cases. VMWare engineering is aware of it. I do have a REST API in powershell that will delete it. I also have SQL delete query I use. But I default to the REST API call below typically.
The items in Bold come from your specific information.
$VCDConnection = connect-ciserver -server "vcdservername"
$sessionkey = $VCDConnection.SessionId
$orgs = get-org -name "Orgname"
$vdcs = Get-OrgVdc -org $org
$vdcorgNetworks = Get-OrgVdcNetwork -OrgVdc $vdcs
$sessionkey = $VCDConnection.SessionId
foreach($vdc in $vdcs){
foreach($vdcorgNetwork in $vdcorgNetworks){
write-host ("`tDeleting OrgVDC Network: "+$vdcorgNetwork.name)
#$vdcorgNetwork.ExtensionData.Delete()
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$Headers.Add('x-vcloud-authorization', $sessionkey)
$Headers.Add('accept','application/*+xml;version=31.0')
$Headers.Add('Content-Type','application/xml')
$vdcnetURL = $vdcorgNetwork.href+'?force=true'
$wr = (Invoke-WebRequest -uri $vdcnetURL -Method Delete -Headers $Headers).content
[xml]$wrxml = $wr
$wrtaskhref= $wrxml.Task.href
Write-Verbose "wrtaskhref: $wrtaskhref"
try{
while($ts -ne 'success')
{
[xml]$taskstatus = (Invoke-WebRequest -uri $wrtaskhref -Method get -Headers $headers).content
$ts = $taskstatus.Task.Status
Write-Verbose "ts: $ts"
start-sleep -Seconds 3}
}
catch{}
Write-Verbose -Message 'Pausing for 15 seconds so system can stabilize'
start-sleep -seconds 15
}