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,
21 - CLOUD_REGION_VERSION,
22 - CLOUD_OWNER_DEFINED_TYPE,
23 - COMPLEX_PHYSICAL_LOCATION_ID,
30 self._logger.info("*Check if cloud region exists *")
32 cloud_region: CloudRegion = CloudRegion.get_by_id(
33 cloud_owner=settings.CLOUD_REGION_CLOUD_OWNER,
34 cloud_region_id=settings.CLOUD_REGION_ID,
37 self._logger.info("*Create the cloud region *")
38 cloud_region: CloudRegion = CloudRegion.create(
39 cloud_owner=settings.CLOUD_REGION_CLOUD_OWNER,
40 cloud_region_id=settings.CLOUD_REGION_ID,
41 orchestration_disabled=False,
43 cloud_type=settings.CLOUD_REGION_TYPE,
44 cloud_region_version=settings.CLOUD_REGION_VERSION,
45 owner_defined_type=settings.CLOUD_OWNER_DEFINED_TYPE,
46 complex_name=settings.COMPLEX_PHYSICAL_LOCATION_ID
48 cloud_region.add_esr_system_info(
49 esr_system_info_id=str(uuid4()),
50 user_name=settings.VIM_USERNAME,
51 password=settings.VIM_PASSWORD,
53 service_url=settings.VIM_SERVICE_URL,
55 system_status="active",
56 cloud_domain=settings.CLOUD_DOMAIN,
57 default_tenant=settings.TENANT_NAME
59 if settings.USE_MULTICLOUD:
60 self._logger.info("*Multicloud registration *")
61 cloud_region.register_to_multicloud()
65 while nb_try < nb_try_max:
66 if not cloud_region.tenants:
72 # Retrieve the tenant, created by multicloud registration
73 # if it does not exist, create it
75 cloud_region.get_tenant(settings.TENANT_ID)
77 self._logger.warning("Impossible to retrieve the Specificed Tenant")
78 self._logger.debug("If no multicloud selected, add the tenant")
79 cloud_region.add_tenant(
80 tenant_id=settings.TENANT_ID,
81 tenant_name=settings.TENANT_NAME)
83 # be sure that an availability zone has been created
86 cloud_region.get_availability_zone_by_name(
87 settings.AVAILABILITY_ZONE_NAME)
89 cloud_region.add_availability_zone(
90 settings.AVAILABILITY_ZONE_NAME,
91 settings.AVAILABILITY_ZONE_TYPE)