diff options
Diffstat (limited to 'src/onaptests/steps/cloud/register_cloud.py')
-rw-r--r-- | src/onaptests/steps/cloud/register_cloud.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/onaptests/steps/cloud/register_cloud.py b/src/onaptests/steps/cloud/register_cloud.py index 72da4f7..58c3e35 100644 --- a/src/onaptests/steps/cloud/register_cloud.py +++ b/src/onaptests/steps/cloud/register_cloud.py @@ -4,6 +4,7 @@ from uuid import uuid4 from onapsdk.aai.cloud_infrastructure import CloudRegion from onapsdk.configuration import settings +from onapsdk.exceptions import ResourceNotFound from ..base import BaseStep from onaptests.steps.cloud.cloud_region_create import CloudRegionCreateStep @@ -45,11 +46,11 @@ class RegisterCloudRegionStep(BaseStep): - TENANT_NAME. """ super().execute() - cloud_region: CloudRegion = CloudRegion.get_by_id( - cloud_owner=settings.CLOUD_REGION_CLOUD_OWNER, - cloud_region_id=settings.CLOUD_REGION_ID, - ) - if not list(cloud_region.esr_system_infos): + 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, @@ -78,7 +79,7 @@ class RegisterCloudRegionStep(BaseStep): # if it does not exist, create it try: cloud_region.get_tenant(settings.TENANT_ID) - except ValueError: + 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( @@ -90,7 +91,7 @@ class RegisterCloudRegionStep(BaseStep): try: cloud_region.get_availability_zone_by_name( settings.AVAILABILITY_ZONE_NAME) - except ValueError: + except ResourceNotFound: cloud_region.add_availability_zone( settings.AVAILABILITY_ZONE_NAME, settings.AVAILABILITY_ZONE_TYPE) |