diff options
author | mrichomme <morgan.richomme@orange.com> | 2020-09-04 17:03:23 +0200 |
---|---|---|
committer | mrichomme <morgan.richomme@orange.com> | 2020-09-08 11:03:28 +0200 |
commit | 076a0030b70a875535f7fcabb7acafe7cf478746 (patch) | |
tree | 0f5a62fad16fa4fb930ae0436bf158c20d9ff6b1 /src/onaptests/steps/cloud | |
parent | 6022ac2e68ece3720bcfa57b290d73ac0eb238c1 (diff) |
Support non multicloud configuration
Add tenant and availability zone manually
It is done by multicloud in multicloud mode
Use settings.py as the main settings and specific
settings per use case
Issue-ID: TEST-256
Signed-off-by: mrichomme <morgan.richomme@orange.com>
Change-Id: I3a66a8416cddb546780f784568e7a88f2bd1781b
Signed-off-by: mrichomme <morgan.richomme@orange.com>
Diffstat (limited to 'src/onaptests/steps/cloud')
-rw-r--r-- | src/onaptests/steps/cloud/connect_service_subscription_to_cloud_region.py | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/onaptests/steps/cloud/connect_service_subscription_to_cloud_region.py b/src/onaptests/steps/cloud/connect_service_subscription_to_cloud_region.py index 23ba994..8b11bc1 100644 --- a/src/onaptests/steps/cloud/connect_service_subscription_to_cloud_region.py +++ b/src/onaptests/steps/cloud/connect_service_subscription_to_cloud_region.py @@ -36,11 +36,38 @@ class ConnectServiceSubToCloudRegionStep(BaseStep): """ super().execute() - customer: Customer = Customer.get_by_global_customer_id(settings.GLOBAL_CUSTOMER_ID) - service_subscription: ServiceSubscription = customer.get_service_subscription_by_service_type(settings.SERVICE_NAME) + customer: Customer = Customer.get_by_global_customer_id( + settings.GLOBAL_CUSTOMER_ID) + service_subscription: ServiceSubscription = customer.get_service_subscription_by_service_type( + settings.SERVICE_NAME) cloud_region: CloudRegion = CloudRegion.get_by_id( cloud_owner=settings.CLOUD_REGION_CLOUD_OWNER, cloud_region_id=settings.CLOUD_REGION_ID, ) + + # Retrieve the tenant + # if it does not exist, create it + try: + tenant: Tenant = cloud_region.get_tenant(settings.TENANT_ID) + except ValueError: + self._logger.warning("Impossible to retrieve the Specificed Tenant") + self._logger.debug("If no multicloud selected, add the tenant") + cloud_region.add_tenant( + tenant_id=settings.TENANT_ID, + tenant_name=settings.TENANT_NAME) + + # be sure that an availability zone has been created + # if not, create it + try: + cloud_region.get_availability_zone_by_name( + settings.AVAILABILITY_ZONE_NAME) + except ValueError: + cloud_region.add_availability_zone( + settings.AVAILABILITY_ZONE_NAME, + settings.AVAILABILITY_ZONE_TYPE) + + # retrieve tenant + # for which we are sure that an availability zone has been created tenant: Tenant = cloud_region.get_tenant(settings.TENANT_ID) + service_subscription.link_to_cloud_region_and_tenant(cloud_region=cloud_region, tenant=tenant) |