4 from onapsdk.aai.cloud_infrastructure import CloudRegion
5 from onapsdk.configuration import settings
7 from ..base import BaseStep
10 class RegisterCloudRegionStep(BaseStep):
11 """Cloud region registration step."""
15 """Register cloud region
18 - CLOUD_REGION_CLOUD_OWNER,
27 self._logger.info("*Check if cloud region exists *")
29 cloud_region: CloudRegion = CloudRegion.get_by_id(
30 cloud_owner=settings.CLOUD_REGION_CLOUD_OWNER,
31 cloud_region_id=settings.CLOUD_REGION_ID,
34 self._logger.info("*Create the cloud region *")
35 cloud_region: CloudRegion = CloudRegion.create(
36 cloud_owner=settings.CLOUD_REGION_CLOUD_OWNER,
37 cloud_region_id=settings.CLOUD_REGION_ID,
38 orchestration_disabled=False,
40 cloud_type=settings.CLOUD_REGION_TYPE,
41 cloud_region_version=settings.CLOUD_REGION_VERSION
43 cloud_region.add_esr_system_info(
44 esr_system_info_id=str(uuid4()),
45 user_name=settings.VIM_USERNAME,
46 password=settings.VIM_PASSWORD,
48 service_url=settings.VIM_SERVICE_URL,
50 system_status="active",
51 cloud_domain=settings.CLOUD_DOMAIN,
52 default_tenant=settings.TENANT_NAME
54 if settings.USE_MULTICLOUD:
55 self._logger.info("*Multicloud registration *")
56 cloud_region.register_to_multicloud()
60 while nb_try < nb_try_max:
61 if not cloud_region.tenants:
67 # Retrieve the tenant, created by multicloud registration
68 # if it does not exist, create it
70 cloud_region.get_tenant(settings.TENANT_ID)
72 self._logger.warning("Impossible to retrieve the Specificed Tenant")
73 self._logger.debug("If no multicloud selected, add the tenant")
74 cloud_region.add_tenant(
75 tenant_id=settings.TENANT_ID,
76 tenant_name=settings.TENANT_NAME)
78 # be sure that an availability zone has been created
81 cloud_region.get_availability_zone_by_name(
82 settings.AVAILABILITY_ZONE_NAME)
84 cloud_region.add_availability_zone(
85 settings.AVAILABILITY_ZONE_NAME,
86 settings.AVAILABILITY_ZONE_TYPE)