aboutsummaryrefslogtreecommitdiffstats
path: root/heat
diff options
context:
space:
mode:
Diffstat (limited to 'heat')
-rwxr-xr-xheat/vFW_CNF_CDS/automation/config.py3
-rwxr-xr-xheat/vFW_CNF_CDS/automation/create_cloud_regions.py31
2 files changed, 22 insertions, 12 deletions
diff --git a/heat/vFW_CNF_CDS/automation/config.py b/heat/vFW_CNF_CDS/automation/config.py
index c0f7b1b4..2c1c96e1 100755
--- a/heat/vFW_CNF_CDS/automation/config.py
+++ b/heat/vFW_CNF_CDS/automation/config.py
@@ -14,8 +14,6 @@
# limitations under the License.
#
# ============LICENSE_END=========================================================
-from uuid import uuid4
-
class Config:
SCENARIO = 1
@@ -117,7 +115,6 @@ class Config:
"cloud_type": "k8s",
"availability_zone": "k8s-availability-zone",
"tenant": {
- "id": str(uuid4()),
"name": K8S_REGION + "-tenant"
},
"customer_resource_definitions": [
diff --git a/heat/vFW_CNF_CDS/automation/create_cloud_regions.py b/heat/vFW_CNF_CDS/automation/create_cloud_regions.py
index d4b318f9..eb3e95bb 100755
--- a/heat/vFW_CNF_CDS/automation/create_cloud_regions.py
+++ b/heat/vFW_CNF_CDS/automation/create_cloud_regions.py
@@ -17,6 +17,7 @@
import logging
import os
+from uuid import uuid4
from onapsdk.so.so_db_adapter import SoDbAdapter, IdentityService
@@ -109,17 +110,29 @@ def add_availability_zone(cloud_region):
def add_tenant(cloud_region):
logger.info("******** Tenant *******")
region_id = cloud_region.cloud_region_id
- tenant_id = Config.CLOUD_REGIONS[region_id]["tenant"]["id"]
+ is_k8s = is_k8s_region(region_id)
tenant_name = Config.CLOUD_REGIONS[region_id]["tenant"]["name"]
- try:
- cloud_region.get_tenant(tenant_id)
- logger.info("Tenant exists")
- except ResourceNotFound:
- logger.info("Tenant does not exist")
- cloud_region.add_tenant(tenant_id=tenant_id,
- tenant_name=tenant_name)
- logger.info("Tenant added to region")
+ if is_k8s:
+ try:
+ next(_tenant for _tenant in cloud_region.tenants if _tenant.name == tenant_name)
+ logger.info("Tenant exists")
+ except (StopIteration, ResourceNotFound):
+ tenant_id = str(uuid4())
+ logger.info("Tenant does not exist")
+ cloud_region.add_tenant(tenant_id=tenant_id,
+ tenant_name=tenant_name)
+ logger.info(f"Tenant {tenant_name} added to region")
+ else:
+ tenant_id = Config.CLOUD_REGIONS[region_id]["tenant"]["id"]
+ try:
+ cloud_region.get_tenant(tenant_id)
+ logger.info("Tenant exists")
+ except ResourceNotFound:
+ logger.info("Tenant does not exist")
+ cloud_region.add_tenant(tenant_id=tenant_id,
+ tenant_name=tenant_name)
+ logger.info(f"Tenant {tenant_name} added to region")
def create_customer():