diff options
author | Bin Yang <bin.yang@windriver.com> | 2019-08-28 07:36:13 +0000 |
---|---|---|
committer | Bin Yang <bin.yang@windriver.com> | 2019-08-28 07:53:34 +0000 |
commit | b2f07363e85cb731488da9e4f6e2dec916f587b1 (patch) | |
tree | 3b2b4311dd9bbf5a8345e76fb29d36613e7d28a3 | |
parent | 5478615a08971455605dcb1c35a73872ffd82f4c (diff) |
Unregistry removes AZ and its relationshipdublin
Change-Id: I1362f92eb3762aa7fbdeb495c40394c825225d75
Issue-ID: MULTICLOUD-793
Signed-off-by: Bin Yang <bin.yang@windriver.com>
(cherry picked from commit 3f9d312fabb805bb16e89b662d5c70efe91c6b79)
-rw-r--r-- | share/newton_base/registration/registration.py | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/share/newton_base/registration/registration.py b/share/newton_base/registration/registration.py index 51e2eb4c..1f113dd9 100644 --- a/share/newton_base/registration/registration.py +++ b/share/newton_base/registration/registration.py @@ -337,13 +337,13 @@ class RegistryHelper(MultiCloudAAIHelper): resource_url = ("/cloud-infrastructure/cloud-regions/" "cloud-region/%(cloud_owner)s/%(cloud_region_id)s/" - "%(resource_type)ss/%(resource_type)s/%(resoure_id)s/" + "%(resource_type)ss/%(resource_type)s/%(resource_id)s/" "?resource-version=%(resource-version)s" % { "cloud_owner": cloud_owner, "cloud_region_id": cloud_region_id, "resource_type": "tenant", - "resoure_id": tenant["tenant-id"], + "resource_id": tenant["tenant-id"], "resource-version": tenant["resource-version"] }) # remove tenant @@ -359,14 +359,14 @@ class RegistryHelper(MultiCloudAAIHelper): if hpa_capabilities else []: resource_url = ("/cloud-infrastructure/cloud-regions/" "cloud-region/%(cloud_owner)s/%(cloud_region_id)s/" - "%(resource_type)ss/%(resource_type)s/%(resoure_id)s/" + "%(resource_type)ss/%(resource_type)s/%(resource_id)s/" "hpa-capabilities/hpa-capability/%(hpa-capability-id)s/" "?resource-version=%(resource-version)s" % { "cloud_owner": cloud_owner, "cloud_region_id": cloud_region_id, "resource_type": "flavor", - "resoure_id": flavor["flavor-id"], + "resource_id": flavor["flavor-id"], "hpa-capability-id": hpa_capability["hpa-capability-id"], "resource-version": hpa_capability["resource-version"] }) @@ -377,13 +377,13 @@ class RegistryHelper(MultiCloudAAIHelper): # remove flavor resource_url = ("/cloud-infrastructure/cloud-regions/" "cloud-region/%(cloud_owner)s/%(cloud_region_id)s/" - "%(resource_type)ss/%(resource_type)s/%(resoure_id)s/" + "%(resource_type)ss/%(resource_type)s/%(resource_id)s/" "?resource-version=%(resource-version)s" % { "cloud_owner": cloud_owner, "cloud_region_id": cloud_region_id, "resource_type": "flavor", - "resoure_id": flavor["flavor-id"], + "resource_id": flavor["flavor-id"], "resource-version": flavor["resource-version"] }) @@ -395,13 +395,13 @@ class RegistryHelper(MultiCloudAAIHelper): for image in images.get("image", []) if images else []: resource_url = ("/cloud-infrastructure/cloud-regions/" "cloud-region/%(cloud_owner)s/%(cloud_region_id)s/" - "%(resource_type)ss/%(resource_type)s/%(resoure_id)s/" + "%(resource_type)ss/%(resource_type)s/%(resource_id)s/" "?resource-version=%(resource-version)s" % { "cloud_owner": cloud_owner, "cloud_region_id": cloud_region_id, "resource_type": "image", - "resoure_id": image["image-id"], + "resource_id": image["image-id"], "resource-version": image["resource-version"] }) # remove image @@ -409,6 +409,32 @@ class RegistryHelper(MultiCloudAAIHelper): restcall.req_to_aai(resource_url, "DELETE") # remove all az + azs = cloudregiondata.get("availability-zones", None) + for az in azs.get("availability-zone", []) if azs else []: + # delete az relationship first + resource_url = ("/cloud-infrastructure/cloud-regions/" + "cloud-region/%(cloud_owner)s/%(cloud_region_id)s/" + "%(resource_type)ss/%(resource_type)s/%(resource_id)s" + % { + "cloud_owner": cloud_owner, + "cloud_region_id": cloud_region_id, + "resource_type": "availability-zone", + "resource_id": az["availability-zone-name"] + }) + + rs = az.get("relationship-list", []).get("relationship", []) + for r in rs: + retcode, content, status_code = \ + restcall.req_to_aai( + resource_url+"/relationship-list/relationship", + "DELETE", content=r) + + # delete az + resource_url2 = (resource_url + "?resource-version=%(resource-version)s" + % {"resource-version": az["resource-version"]}) + retcode, content, status_code = \ + restcall.req_to_aai(resource_url2, "DELETE") + # remove all vg @@ -417,13 +443,13 @@ class RegistryHelper(MultiCloudAAIHelper): for snapshot in snapshots.get("snapshot", []) if snapshots else []: resource_url = ("/cloud-infrastructure/cloud-regions/" "cloud-region/%(cloud_owner)s/%(cloud_region_id)s/" - "%(resource_type)ss/%(resource_type)s/%(resoure_id)s/" + "%(resource_type)ss/%(resource_type)s/%(resource_id)s/" "?resource-version=%(resource-version)s" % { "cloud_owner": cloud_owner, "cloud_region_id": cloud_region_id, "resource_type": "snapshot", - "resoure_id": snapshot["snapshot-id"], + "resource_id": snapshot["snapshot-id"], "resource-version": snapshot["resource-version"] }) # remove snapshot |