diff options
Diffstat (limited to 'src/onaptests/steps/cloud')
-rw-r--r-- | src/onaptests/steps/cloud/register_cloud.py | 62 |
1 files changed, 34 insertions, 28 deletions
diff --git a/src/onaptests/steps/cloud/register_cloud.py b/src/onaptests/steps/cloud/register_cloud.py index 58c3e35..3065461 100644 --- a/src/onaptests/steps/cloud/register_cloud.py +++ b/src/onaptests/steps/cloud/register_cloud.py @@ -46,34 +46,37 @@ class RegisterCloudRegionStep(BaseStep): - TENANT_NAME. """ super().execute() - try: - cloud_region: CloudRegion = CloudRegion.get_by_id( - cloud_owner=settings.CLOUD_REGION_CLOUD_OWNER, - cloud_region_id=settings.CLOUD_REGION_ID) - except ResourceNotFound: - cloud_region.add_esr_system_info( - esr_system_info_id=str(uuid4()), - user_name=settings.VIM_USERNAME, - password=settings.VIM_PASSWORD, - system_type="VIM", - service_url=settings.VIM_SERVICE_URL, - ssl_insecure=False, - system_status="active", - cloud_domain=settings.CLOUD_DOMAIN, - default_tenant=settings.TENANT_NAME - ) - if settings.USE_MULTICLOUD: - self._logger.info("*Multicloud registration *") - cloud_region.register_to_multicloud() - time.sleep(20) - nb_try = 0 - nb_try_max = 3 - while nb_try < nb_try_max: + cloud_region: CloudRegion = CloudRegion.get_by_id( + cloud_owner=settings.CLOUD_REGION_CLOUD_OWNER, + cloud_region_id=settings.CLOUD_REGION_ID) + cloud_region.add_esr_system_info( + esr_system_info_id=str(uuid4()), + user_name=settings.VIM_USERNAME, + password=settings.VIM_PASSWORD, + system_type="VIM", + service_url=settings.VIM_SERVICE_URL, + ssl_insecure=False, + system_status="active", + cloud_domain=settings.CLOUD_DOMAIN, + default_tenant=settings.TENANT_NAME + ) + if settings.USE_MULTICLOUD: + self._logger.info("*Multicloud registration *") + cloud_region.register_to_multicloud() + time.sleep(20) + nb_try = 0 + nb_try_max = 3 + while nb_try < nb_try_max: + try: if not cloud_region.tenants: + self._logger.debug("No tenats available, check one more time") time.sleep(20) else: break - nb_try += 1 + except ResourceNotFound: + self._logger.debug("No tenats available, check one more time") + time.sleep(20) + nb_try += 1 # Retrieve the tenant, created by multicloud registration # if it does not exist, create it @@ -81,10 +84,13 @@ class RegisterCloudRegionStep(BaseStep): cloud_region.get_tenant(settings.TENANT_ID) except ResourceNotFound: 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) + self._logger.debug("If no multicloud selected, add the tenant, reraise otherwise") + if not settings.USE_MULTICLOUD: + cloud_region.add_tenant( + tenant_id=settings.TENANT_ID, + tenant_name=settings.TENANT_NAME) + else: + raise # be sure that an availability zone has been created # if not, create it |