diff options
author | Michal Jagiello <michal.jagiello@t-mobile.pl> | 2020-07-16 19:16:42 +0200 |
---|---|---|
committer | Michal Jagiello <michal.jagiello@t-mobile.pl> | 2020-08-24 17:39:38 +0000 |
commit | f9b0c349a5c83f9278f6b115d334598201d9d7e6 (patch) | |
tree | 474e0928dda4a7fd8340f27ab72bb5bee7683fce /src/onaptests/steps/cloud | |
parent | 9d674116f24285d68a80597202d393b74ac544ce (diff) |
First proposal for the structure for pythonsdk based scenarios
Issue-ID: TEST-240
Change-Id: Ic989b26442b868363af7b3872bff49dd70d78be0
Signed-off-by: Michal Jagiello <michal.jagiello@t-mobile.pl>
Diffstat (limited to 'src/onaptests/steps/cloud')
8 files changed, 230 insertions, 0 deletions
diff --git a/src/onaptests/steps/cloud/__init__.py b/src/onaptests/steps/cloud/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/onaptests/steps/cloud/__init__.py diff --git a/src/onaptests/steps/cloud/cloud_region_create.py b/src/onaptests/steps/cloud/cloud_region_create.py new file mode 100644 index 0000000..dafd6ec --- /dev/null +++ b/src/onaptests/steps/cloud/cloud_region_create.py @@ -0,0 +1,28 @@ +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/complex_create.py b/src/onaptests/steps/cloud/complex_create.py new file mode 100644 index 0000000..37ad49f --- /dev/null +++ b/src/onaptests/steps/cloud/complex_create.py @@ -0,0 +1,23 @@ +from onapsdk.aai.cloud_infrastructure import Complex +from onapsdk.configuration import settings + +from ..base import BaseStep + + +class ComplexCreateStep(BaseStep): + """Complex creation step.""" + + def execute(self): + """Create complex. + + Use settings values: + - COMPLEX_PHYSICAL_LOCATION_ID, + - COMPLEX_DATA_CENTER_CODE. + + """ + super().execute() + Complex.create( + physical_location_id=settings.COMPLEX_PHYSICAL_LOCATION_ID, + data_center_code=settings.COMPLEX_DATA_CENTER_CODE, + name=settings.COMPLEX_PHYSICAL_LOCATION_ID + ) 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 new file mode 100644 index 0000000..23ba994 --- /dev/null +++ b/src/onaptests/steps/cloud/connect_service_subscription_to_cloud_region.py @@ -0,0 +1,46 @@ +from onapsdk.aai.business import Customer, ServiceSubscription +from onapsdk.aai.cloud_infrastructure import CloudRegion, Tenant +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 + + +class ConnectServiceSubToCloudRegionStep(BaseStep): + """Connect service subscription to cloud region step.""" + + def __init__(self, cleanup=False): + """Initialize step. + + Substeps: + - LinkCloudRegionToComplexStep, + - RegisterCloudRegionToMulticloudStep, + - CustomerServiceSubscriptionCreateStep. + + """ + super().__init__(cleanup=cleanup) + self.add_step(LinkCloudRegionToComplexStep(cleanup=cleanup)) + self.add_step(RegisterCloudRegionToMulticloudStep(cleanup=cleanup)) + self.add_step(CustomerServiceSubscriptionCreateStep(cleanup=cleanup)) + + def execute(self): + """Connect service subsription to cloud region and tenant. + + Use settings values: + - GLOBAL_CUSTOMER_ID, + - SERVICE_NAME, + - CLOUD_REGION_CLOUD_OWNER, + - CLOUD_REGION_ID. + + """ + super().execute() + customer: Customer = Customer.get_by_global_customer_id(settings.GLOBAL_CUSTOMER_ID) + service_subscription: ServiceSubscription = customer.get_service_subscription_by_service_type(settings.SERVICE_NAME) + cloud_region: CloudRegion = CloudRegion.get_by_id( + cloud_owner=settings.CLOUD_REGION_CLOUD_OWNER, + cloud_region_id=settings.CLOUD_REGION_ID, + ) + tenant: Tenant = cloud_region.get_tenant(settings.TENANT_ID) + service_subscription.link_to_cloud_region_and_tenant(cloud_region=cloud_region, tenant=tenant) diff --git a/src/onaptests/steps/cloud/customer_create.py b/src/onaptests/steps/cloud/customer_create.py new file mode 100644 index 0000000..2bdf312 --- /dev/null +++ b/src/onaptests/steps/cloud/customer_create.py @@ -0,0 +1,16 @@ +from onapsdk.aai.business import Customer +from onapsdk.configuration import settings + +from ..base import BaseStep + + +class CustomerCreateStep(BaseStep): + """Customer creation step.""" + + def execute(self): + """Create cutomer. + + Use settings values: + - GLOBAL_CUSTOMER_ID. + """ + Customer.create(settings.GLOBAL_CUSTOMER_ID, settings.GLOBAL_CUSTOMER_ID, "INFRA") diff --git a/src/onaptests/steps/cloud/customer_service_subscription_create.py b/src/onaptests/steps/cloud/customer_service_subscription_create.py new file mode 100644 index 0000000..c797d56 --- /dev/null +++ b/src/onaptests/steps/cloud/customer_service_subscription_create.py @@ -0,0 +1,30 @@ +from onapsdk.aai.business import Customer +from onapsdk.sdc.service import Service +from onapsdk.configuration import settings + +from ..base import BaseStep +from .customer_create import CustomerCreateStep + + +class CustomerServiceSubscriptionCreateStep(BaseStep): + """Cutomer service subsription creation step""" + + def __init__(self, cleanup=False): + """Initialize step. + + Substeps: + - CustomerCreateStep. + """ + super().__init__(cleanup=cleanup) + self.add_step(CustomerCreateStep(cleanup=cleanup)) + + def execute(self): + """Create customer service subsription. + + Use settings values: + - GLOBAL_CUSTOMER_ID, + - SERVICE_NAME. + """ + service = Service(name=settings.SERVICE_NAME) + customer = Customer.get_by_global_customer_id(settings.GLOBAL_CUSTOMER_ID) + customer.subscribe_service(service) diff --git a/src/onaptests/steps/cloud/link_cloud_to_complex.py b/src/onaptests/steps/cloud/link_cloud_to_complex.py new file mode 100644 index 0000000..4da3804 --- /dev/null +++ b/src/onaptests/steps/cloud/link_cloud_to_complex.py @@ -0,0 +1,40 @@ +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 + + +class LinkCloudRegionToComplexStep(BaseStep): + """Link cloud region to complex step""" + + def __init__(self, cleanup=False): + """Initialize step. + + Substeps: + - ComplexCreateStep, + - CloudRegionCreateStep. + """ + super().__init__(cleanup=cleanup) + self.add_step(ComplexCreateStep(cleanup=cleanup)) + self.add_step(CloudRegionCreateStep(cleanup=cleanup)) + + def execute(self): + """Link cloud region to complex. + + Use settings values: + - COMPLEX_PHYSICAL_LOCATION_ID, + - CLOUD_REGION_CLOUD_OWNER, + - CLOUD_REGION_ID. + """ + super().execute() + cmplx = Complex( + physical_location_id=settings.COMPLEX_PHYSICAL_LOCATION_ID, + name=settings.COMPLEX_PHYSICAL_LOCATION_ID + ) + cloud_region = CloudRegion.get_by_id( + cloud_owner=settings.CLOUD_REGION_CLOUD_OWNER, + cloud_region_id=settings.CLOUD_REGION_ID, + ) + cloud_region.link_to_complex(cmplx) diff --git a/src/onaptests/steps/cloud/register_cloud_to_multicloud.py b/src/onaptests/steps/cloud/register_cloud_to_multicloud.py new file mode 100644 index 0000000..c3a001c --- /dev/null +++ b/src/onaptests/steps/cloud/register_cloud_to_multicloud.py @@ -0,0 +1,47 @@ +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_REGION_TYPE, + - CLOUD_DOMAIN, + - VIM_USERNAME, + - VIM_PASSWORD, + - VIM_SERVICE_URL. + """ + 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=settings.CLOUD_REGION_TYPE, + service_url=settings.VIM_SERVICE_URL, + cloud_domain=settings.CLOUD_DOMAIN + ) + cloud_region.register_to_multicloud() |