com.vmware.vcloud.api.presentation.service.InvalidStateException: You must delete this Organization's Application Port Profiles before you can delete the organization.
/opt/vmware/vcloud-director/logs/vcloud-container-debug.log you can see error as below:DEBUG | task-service-activity-pool-51799 | CJob | updateFailedJob(com.vmware.vcloud.api.presentation.service.InvalidStateException) with locale=en_US | requestId=########-####-####-########,
request=DELETE https://VCD_FQDN/cloudapi/1.0.0/orgs/urn:vcloud:org:########-####-####-########,requestTime=1780981424651,remoteAddress=##.##.##.##:38788,userAgent=Mozilla/5.0 (Windows NT 10.0; Win64
; x64) AppleWebKit/537.36 ...,accept=application/json;version 40.0.0-alpha vcd=########-####-####-########,task=########-####-####-########
activity=(com.vmware.vcloud.backendbase.management.system.TaskActivity,urn:uuid:########-####-####-########)
com.vmware.vcloud.api.presentation.service.InvalidStateException: You must delete this Organization's Application Port Profiles before you can delete the org
anization.
at com.vmware.vcloud.management.system.OrgServiceImpl.validateOrgDoesNotHavePortProfilesForDelete(OrgServiceImpl.java:799)
at com.vmware.vcloud.management.system.OrgServiceImpl.validateIfOrgCanBeDeleted(OrgServiceImpl.java:767)
at com.vmware.vcloud.management.system.OrgServiceImpl.deleteOrg(OrgServiceImpl.java:730)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.sun.proxy.$Proxy608.deleteOrg(Unknown Source)This is a known issue affecting VMware Cloud Director versions 10.4.x and later.
If application port profiles are created on an edge gateway associated with an organization, attempting to delete the organization fails. The issue occurs because VMware Cloud Director deletes the edge gateways before deleting the port profiles, which causes the error.
Starting with VCD 10.3, the stale application port profiles and the organizations containing them can be force deleted via the API.
Note: API Explorer can be accessed by clicking on the ? on the top right of VCD Provider page and clicking API Explorer.
If VCD is in multisite, make sure to use the API explorer from the site of the concerned Organization.
1. Delete an organization with "force" option using API explorer:
DELETE https://<VCD-ENDPOINT>/cloudapi/1.0.0/orgs/<ORG-UUID>?force=true
2. Synchronize application port profiles:
POST https://<VCD-ENDPOINT>/cloudapi/1.0.0/applicationPortProfiles/sync
Note: POST request requires a filter to be specified. Please refer the OpenAPI documentation.
To retrieve the parameter specific to your environment, follow the steps below:
If utilization of the API is not possible, contact Broadcom Support and note this Article ID (312277) in the problem description. For more information, see Creating and managing Broadcom support cases.
For more information on connecting to VCD via API, refer to KB 320526
This is a known issue as referenced in the following release notes: