summaryrefslogtreecommitdiffstats
path: root/share/newton_base
diff options
context:
space:
mode:
authorXiaohua Zhang <xiaohua.zhang@windriver.com>2018-09-21 16:39:08 +0000
committerXiaohua Zhang <xiaohua.zhang@windriver.com>2018-09-21 16:53:00 +0000
commit050812c9ae2b85348b2ff29d4fa3e2ac2fb4fec7 (patch)
treee7f34920cae78566e03a443cdcb8b53abcf67d39 /share/newton_base
parentea803b961e4d5ae108183ebd2b5c6eaa1a1be4d6 (diff)
Implement heatdelete to remove vservers from AAI
Change-Id: I5c81fb3f01e08ee5c43107d7d59fdf4bf3a1d803 Issue-ID: MULTICLOUD-361 Signed-off-by: Xiaohua Zhang <xiaohua.zhang@windriver.com>
Diffstat (limited to 'share/newton_base')
-rw-r--r--share/newton_base/registration/registration.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/share/newton_base/registration/registration.py b/share/newton_base/registration/registration.py
index afcd0761..84f40d71 100644
--- a/share/newton_base/registration/registration.py
+++ b/share/newton_base/registration/registration.py
@@ -1027,6 +1027,40 @@ class Registry(APIView):
# step 1. remove all tenants
tenants = cloudregiondata.get("tenants", None)
for tenant in tenants.get("tenant", []) if tenants else []:
+ # common prefix
+ aai_cloud_region = "/cloud-infrastructure/cloud-regions/cloud-region/%s/%s/tenants/tenant/%s" \
+ % (cloud_owner, cloud_region_id, tenant['tenant-id'])
+
+ # remove all vservers
+ try:
+ # get list of vservers
+ vservers = tenant['vservers']['vserver']
+ for vserver in vservers:
+ try:
+ # iterate vport, except will be raised if no l-interface exist
+ for vport in vserver['l-interfaces']['l-interface']:
+ # delete vport
+ vport_delete_url = aai_cloud_region + "/vservers/vserver/%s/l-interfaces/l-interface/%s?resource-version=%s" \
+ % (vserver['vserver-id'], vport['interface-name'],
+ vport['resource-version'])
+ restcall.req_to_aai(vport_delete_url, "DELETE")
+ except Exception as e:
+ pass
+
+ try:
+ # delete vserver
+ vserver_delete_url = aai_cloud_region + "/vservers/vserver/%s?resource-version=%s" \
+ % (
+ vserver['vserver-id'], vserver['resource-version'])
+ restcall.req_to_aai(vserver_delete_url, "DELETE")
+ except Exception as e:
+ continue
+
+ except Exception:
+ self._logger.error(traceback.format_exc())
+ return None
+ pass
+
resource_url = ("/cloud-infrastructure/cloud-regions/"
"cloud-region/%(cloud_owner)s/%(cloud_region_id)s/"
"%(resource_type)ss/%(resource_type)s/%(resoure_id)s/"