These are the commands to delete the environment and org for on premise Apigee installation.
Please note that in order to delete an org, you need to delete all of its environments, and all artifacts associated with the environment, including virtualhosts, keystores, servers, API Proxies, API Products, and so on.
Also note that deleting an organization does not delete the users associated with it.
1. Delete any keystores defined for the virtualhosts defined in that environment
API to get the keystores defined for an org and environment :
curl -v -u <sysadmin-creds> "http://<management-server-hostname-or-IP>:<management-server-port>/v1/o/<org-name>/e/<env-name>/keystores"
API to delete the keystores defined for an org and environment
curl -v -u <sysadmin-creds> -X DELETE "http://<management-server-hostname-or-IP>:<management-server-port>/v1/o/<org-name>/e/<env-name>/keystores/<keystore-name>"
2. Delete the virtualhosts for that environment
API call to get the virtualhosts defined for an org and environment
curl -v -u <sysadmin-creds> "http://<management-server-hostname-or-IP>:<management-server-port>/v1/o/<org-name>/e/<env-name>/virtualhosts
API call to delete the virtual hosts
curl -v -X DELETE -u <sysadmin-creds> "http://<management-server-hostname-or-IP>:<management-server-port>/v1/o/<org-name>/e/<env-name>/virtualhosts/<vhost>
3. Dissociate the servers associated with the environment.
API call to get the UUID's of the servers. This gives you the qpid, postgres and Message Processor(MP).
curl -v -u <sysadmin-creds> "http://<management-server-hostname-or-IP>:<management-server-port>/v1/organizations/<org-name>/environments/<env-name>/servers"
API call to dissociate each server
curl -v -u <sysadmin-creds> "http://<management-server-hostname-or-IP>:<management-server-port>/v1/organizations/<org-name>/environments/<env-name>/servers" -d 'action=remove&uuid=<uuid>®ion=<region-name>&pod=<pod-name>' -H "Content-Type: application/x-www-form-urlencoded" -X POST
Please note the qpid is in the central pod, postgres in the analytics pod and MP in the pod that you have defined(gateway is the pod name by default).
One can get the region name and pod name by issuing the following command (UUID you will get it from above command):
curl -v -u <sysadmin-creds> "http://<management-server-hostname-or-IP>:<management-server-port>/v1/servers/<uuid>" > GET /v1/servers/76750b80-1a3f-4e1c-b3c6-e22641b0db3f HTTP/1.1 > Authorization: Basic b3Bka0BhcGlnZWUuY29tOnNlY3JldDEy > User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2 > Host: localhost:8080 > Accept: */* > < HTTP/1.1 200 OK < Content-Type: application/json < Date: Fri, 27 Sep 2013 00:14:02 GMT < Content-Length: 613 < Server: Jetty(8.0.4.v20111024) < { "externalHostName" : "localhost", "externalIP" : "192.168.25.100", "internalHostName" : "localhost", "internalIP" : "192.168.25.100", "isUp" : true, "pod" : "central", "reachable" : true, "region" : "dc-1", "tags" : { "property" : [ { "name" : "Profile", "value" : "AXPlatformAgentService" }, { "name" : "rpc.port", "value" : "4529" }, { "name" : "http.management.port", "value" : "8083" }, { "name" : "jmx.rmi.port", "value" : "1102" } ] }, "type" : [ "qpid-server" ], "uUID" : "76750b80-1a3f-4e1c-b3c6-e22641b0db3f" }
4. Once the dissociation is done, then we can run the below command to delete the environment:
curl -v -u <sysadmin-creds> -X DELETE "http://<management-server-hostname-or-IP>:<management-server-port>/v1/o/<org-name/e/<env-name>"
5. Get the pods the org is associated to
curl -v -u <sysadmin-creds> "http://<management-server-hostname-or-IP>:<management-server-port>/v1/o/<org-name>/pods"
6. Dissociate the org from the pods that got returned from the call in Step 5.
curl -v -u <sysadmin-creds> "http://<management-server-hostname-or-IP>:<management-server-port>/v1/organizations/<org-name>/pods" -d "action=removeregion=<region-name>&pod=<pod-name>" -H "Content-Type: application/x-www-form-urlencoded" -X POST
7. Once the dissociation is done from all pods, execute the below command to delete the org
curl -v -u <sysadmin-creds> "http://<management-server-hostname-or-IP>:<management-server-port>/v1/o/<org-name>" -X DELETE
@divya@apigee.com What about the axgroups ? we need to explicitly delete the org-env from the axgroups or does that get automatically updated when you delete the qpids and pgs ?
Great Post !!
A minor correction in #3 - Dissociate the servers - <org-name> and <env-name> is missing in
curl -v -u <sysadmin-creds> "http://<management-server-hostname-or-IP>:<management-server-port>/v1/organizations/environments/servers"
Quite helpful. However, in the curl command for "API call to delete the virtual hosts", -X DELETE is missing.
@Cladius Fernando, thanks. Got it.
You're correct that axgroup scopes need to be removed as well. The API call for that would be:
curl -v -u <sysadmin-creds> "http://<management-server-hostname-or-IP>:<management-server-port>/v1/analytics/groups/ax/axgroup001/scopes?org=<org>&env=<env>" -X DELETE
Also, try this script, which attempts to implement all those steps.
Be careful! delete-org-sh.txt
(Download the script, then rename it to delete-org.sh, and chmod it, before using.)
@Dino : Looks like the delete-org.sh uses a json-parse.sh, Can you attach this file?. It throws an error that this file is not found.
Thanks
Bharath
Please find attached the json-parse.sh shell script as dependency which is needed while invoking delete-org.sh shell script
Also noticed in Step #6 "remove®ion" should probably be "removeregion".
@Dino
Encountering this error
No MSIP (management server ip-address/fqdn) found in /apigee-env.sh.
Run this script after running apigee-setup.sh.
DO you know where to get MSIP value from in verstion 4.19.0 ?