diff options
Diffstat (limited to 'src/onaptests')
5 files changed, 88 insertions, 115 deletions
diff --git a/src/onaptests/steps/cloud/cloud_region_create.py b/src/onaptests/steps/cloud/cloud_region_create.py deleted file mode 100644 index dafd6ec..0000000 --- a/src/onaptests/steps/cloud/cloud_region_create.py +++ /dev/null @@ -1,28 +0,0 @@ -from onapsdk.aai.cloud_infrastructure import CloudRegion -from onapsdk.configuration import settings - -from ..base import BaseStep - - -class CloudRegionCreateStep(BaseStep): - """Cloud region creation step.""" - - def execute(self): - """Create cloud region. - - Use settings values: - - CLOUD_REGION_CLOUD_OWNER, - - CLOUD_REGION_ID, - - CLOUD_REGION_TYPE, - - CLOUD_REGION_VERSION. - - """ - super().execute() - CloudRegion.create( - cloud_owner=settings.CLOUD_REGION_CLOUD_OWNER, - cloud_region_id=settings.CLOUD_REGION_ID, - orchestration_disabled=False, - in_maint=False, - cloud_type=settings.CLOUD_REGION_TYPE, - cloud_region_version=settings.CLOUD_REGION_VERSION - ) 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 8b11bc1..cc0f7b7 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 @@ -5,7 +5,7 @@ from onapsdk.configuration import settings from ..base import BaseStep from .customer_service_subscription_create import CustomerServiceSubscriptionCreateStep from .link_cloud_to_complex import LinkCloudRegionToComplexStep -from .register_cloud_to_multicloud import RegisterCloudRegionToMulticloudStep +from .register_cloud import RegisterCloudRegionStep class ConnectServiceSubToCloudRegionStep(BaseStep): @@ -16,13 +16,13 @@ class ConnectServiceSubToCloudRegionStep(BaseStep): Substeps: - LinkCloudRegionToComplexStep, - - RegisterCloudRegionToMulticloudStep, + - RegisterCloudRegionStep, - CustomerServiceSubscriptionCreateStep. """ super().__init__(cleanup=cleanup) + self.add_step(RegisterCloudRegionStep(cleanup=cleanup)) self.add_step(LinkCloudRegionToComplexStep(cleanup=cleanup)) - self.add_step(RegisterCloudRegionToMulticloudStep(cleanup=cleanup)) self.add_step(CustomerServiceSubscriptionCreateStep(cleanup=cleanup)) def execute(self): @@ -45,27 +45,6 @@ class ConnectServiceSubToCloudRegionStep(BaseStep): 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) diff --git a/src/onaptests/steps/cloud/link_cloud_to_complex.py b/src/onaptests/steps/cloud/link_cloud_to_complex.py index 4da3804..a6b0a96 100644 --- a/src/onaptests/steps/cloud/link_cloud_to_complex.py +++ b/src/onaptests/steps/cloud/link_cloud_to_complex.py @@ -2,7 +2,6 @@ from onapsdk.aai.cloud_infrastructure import CloudRegion, Complex from onapsdk.configuration import settings from ..base import BaseStep -from .cloud_region_create import CloudRegionCreateStep from .complex_create import ComplexCreateStep @@ -18,7 +17,6 @@ class LinkCloudRegionToComplexStep(BaseStep): """ super().__init__(cleanup=cleanup) self.add_step(ComplexCreateStep(cleanup=cleanup)) - self.add_step(CloudRegionCreateStep(cleanup=cleanup)) def execute(self): """Link cloud region to complex. diff --git a/src/onaptests/steps/cloud/register_cloud.py b/src/onaptests/steps/cloud/register_cloud.py new file mode 100644 index 0000000..c6871b8 --- /dev/null +++ b/src/onaptests/steps/cloud/register_cloud.py @@ -0,0 +1,85 @@ +import time +from uuid import uuid4 + +from onapsdk.aai.cloud_infrastructure import CloudRegion +from onapsdk.configuration import settings + +from ..base import BaseStep + + +class RegisterCloudRegionStep(BaseStep): + """Cloud region registration step.""" + + def execute(self): + """Register cloud region + + Use settings values: + - CLOUD_REGION_CLOUD_OWNER, + - CLOUD_REGION_ID, + - CLOUD_DOMAIN, + - VIM_USERNAME, + - VIM_PASSWORD, + - VIM_SERVICE_URL, + - TENANT_NAME. + """ + super().execute() + self._logger.info("*Check if cloud region exists *") + try: + cloud_region: CloudRegion = CloudRegion.get_by_id( + cloud_owner=settings.CLOUD_REGION_CLOUD_OWNER, + cloud_region_id=settings.CLOUD_REGION_ID, + ) + except ValueError: + self._logger.info("*Create the cloud region *") + cloud_region: CloudRegion = CloudRegion.create( + cloud_owner=settings.CLOUD_REGION_CLOUD_OWNER, + cloud_region_id=settings.CLOUD_REGION_ID, + orchestration_disabled=False, + in_maint=False, + cloud_type=settings.CLOUD_REGION_TYPE, + cloud_region_version=settings.CLOUD_REGION_VERSION + ) + 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: + if not cloud_region.tenants: + time.sleep(20) + else: + break + nb_try += 1 + + # Retrieve the tenant, created by multicloud registration + # if it does not exist, create it + try: + 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) diff --git a/src/onaptests/steps/cloud/register_cloud_to_multicloud.py b/src/onaptests/steps/cloud/register_cloud_to_multicloud.py deleted file mode 100644 index 4a1b577..0000000 --- a/src/onaptests/steps/cloud/register_cloud_to_multicloud.py +++ /dev/null @@ -1,61 +0,0 @@ -import time -from uuid import uuid4 - -from onapsdk.aai.cloud_infrastructure import CloudRegion -from onapsdk.configuration import settings - -from ..base import BaseStep -from .cloud_region_create import CloudRegionCreateStep - - -class RegisterCloudRegionToMulticloudStep(BaseStep): - """Cloud region registration in multicloud step.""" - - def __init__(self, cleanup=False): - """Initialize step. - - Substeps: - - CloudRegionCreateStep. - """ - super().__init__(cleanup=cleanup) - self.add_step(CloudRegionCreateStep(cleanup=cleanup)) - - def execute(self): - """Register cloud region in multicloud. - - Use settings values: - - CLOUD_REGION_CLOUD_OWNER, - - CLOUD_REGION_ID, - - CLOUD_DOMAIN, - - VIM_USERNAME, - - VIM_PASSWORD, - - VIM_SERVICE_URL, - - TENANT_NAME. - """ - super().execute() - cloud_region = 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 - ) - cloud_region.register_to_multicloud() - - time.sleep(20) - nb_try = 0 - nb_try_max = 3 - while nb_try < nb_try_max: - if not cloud_region.tenants: - time.sleep(20) - else: - break - nb_try += 1 |