diff options
author | Lukasz Rajewski <lukasz.rajewski@orange.com> | 2021-12-23 13:40:11 +0100 |
---|---|---|
committer | Michal Jagiello <michal.jagiello@t-mobile.pl> | 2022-01-12 22:09:13 +0000 |
commit | 22664610f99038223f996ef1c1661872a92e4ee4 (patch) | |
tree | 081ea2904008e25718f4bf5cf4ed17f73d3a4782 /src/onaptests/steps/instantiate | |
parent | 2bd16f8898e6fd74e64b1500eb5fbc4448517d1a (diff) |
[TEST] Basic CNF macro
Basic CNF macro added with refactoring that enables debugging under IDE
Also SDK upgraded to 9.2 what required adaptation in existing tests
Issue-ID: TEST-376
Signed-off-by: Lukasz Rajewski <lukasz.rajewski@orange.com>
Change-Id: I697857bc0c13e86b88b71c3b46e0c4b59751939c
Signed-off-by: mrichomme <morgan.richomme@orange.com>
Diffstat (limited to 'src/onaptests/steps/instantiate')
6 files changed, 23 insertions, 23 deletions
diff --git a/src/onaptests/steps/instantiate/k8s_profile_create.py b/src/onaptests/steps/instantiate/k8s_profile_create.py index d09d924..a5c8552 100644 --- a/src/onaptests/steps/instantiate/k8s_profile_create.py +++ b/src/onaptests/steps/instantiate/k8s_profile_create.py @@ -1,6 +1,6 @@ from typing import Iterable from uuid import uuid4 -from yaml import load +from yaml import load, SafeLoader from onapsdk.aai.business import Customer, ServiceInstance, ServiceSubscription from onapsdk.configuration import settings @@ -48,7 +48,7 @@ class K8SProfileStep(BaseStep): if self.is_root: if not self._yaml_template: with open(settings.SERVICE_YAML_TEMPLATE, "r") as yaml_template: - self._yaml_template: dict = load(yaml_template) + self._yaml_template: dict = load(yaml_template, SafeLoader) return self._yaml_template return self.parent.yaml_template @@ -124,8 +124,8 @@ class K8SProfileStep(BaseStep): for vf_module in vnf_instance.vnf.vf_modules: # Define profile (rb_profile) for resource bundle definition # Retrieve resource bundle definition (rbdef) corresponding to vf module - rbdef_name = vf_module.metadata["vfModuleModelInvariantUUID"] - rbdef_version = vf_module.metadata["vfModuleModelCustomizationUUID"] + rbdef_name = vf_module.model_invariant_uuid + rbdef_version = vf_module.model_customization_id rbdef = Definition.get_definition_by_name_version(rbdef_name, rbdef_version) # Get k8s profile name from yaml service template vnf_parameters = self.get_vnf_parameters(vnf_instance.vnf.name) @@ -160,8 +160,8 @@ class K8SProfileStep(BaseStep): # possible to have several modules for 1 VNF for vf_module in vnf_instance.vnf.vf_modules: # Retrieve resource bundle definition (rbdef) corresponding to vf module - rbdef_name = vf_module.metadata["vfModuleModelInvariantUUID"] - rbdef_version = vf_module.metadata["vfModuleModelCustomizationUUID"] + rbdef_name = vf_module.model_invariant_uuid + rbdef_version = vf_module.model_customization_id rbdef = Definition.get_definition_by_name_version(rbdef_name, rbdef_version) # Get k8s profile name from yaml service template vnf_parameters = self.get_vnf_parameters(vnf_instance.vnf.name) diff --git a/src/onaptests/steps/instantiate/service_ala_carte.py b/src/onaptests/steps/instantiate/service_ala_carte.py index 3407e8e..a2e1812 100644 --- a/src/onaptests/steps/instantiate/service_ala_carte.py +++ b/src/onaptests/steps/instantiate/service_ala_carte.py @@ -1,6 +1,6 @@ import time from uuid import uuid4 -from yaml import load +from yaml import load, SafeLoader from onapsdk.aai.cloud_infrastructure import CloudRegion, Tenant from onapsdk.aai.business import Customer, ServiceInstance, ServiceSubscription @@ -130,7 +130,7 @@ class YamlTemplateServiceAlaCarteInstantiateStep(YamlTemplateBaseStep): if self.is_root: if not self._yaml_template: with open(settings.SERVICE_YAML_TEMPLATE, "r") as yaml_template: - self._yaml_template: dict = load(yaml_template) + self._yaml_template: dict = load(yaml_template, SafeLoader) return self._yaml_template return self.parent.yaml_template @@ -188,6 +188,7 @@ class YamlTemplateServiceAlaCarteInstantiateStep(YamlTemplateBaseStep): super().execute() service = Service(self.service_name) customer: Customer = Customer.get_by_global_customer_id(settings.GLOBAL_CUSTOMER_ID) + service_subscription: ServiceSubscription = customer.get_service_subscription_by_service_type(service.name) cloud_region: CloudRegion = CloudRegion.get_by_id( cloud_owner=settings.CLOUD_REGION_CLOUD_OWNER, cloud_region_id=settings.CLOUD_REGION_ID, @@ -230,6 +231,7 @@ class YamlTemplateServiceAlaCarteInstantiateStep(YamlTemplateBaseStep): customer, owning_entity, settings.PROJECT, + service_subscription, service_instance_name=self.service_instance_name ) try: diff --git a/src/onaptests/steps/instantiate/service_macro.py b/src/onaptests/steps/instantiate/service_macro.py index b169049..dc2ce89 100644 --- a/src/onaptests/steps/instantiate/service_macro.py +++ b/src/onaptests/steps/instantiate/service_macro.py @@ -3,7 +3,7 @@ import time from typing import List from uuid import uuid4 from onapsdk.aai.business.service import ServiceInstance -from yaml import load +from yaml import load, SafeLoader from onapsdk.aai.business.customer import Customer, ServiceSubscription from onapsdk.aai.business.owning_entity import OwningEntity @@ -13,7 +13,6 @@ from onapsdk.configuration import settings from onapsdk.exceptions import ResourceNotFound from onapsdk.sdc.service import Service from onapsdk.so.instantiation import InstantiationParameter, ServiceInstantiation, VfmoduleParameters, VnfParameters, SoService -from onapsdk.vid import LineOfBusiness, Platform, Project from onaptests.steps.cloud.customer_service_subscription_create import CustomerServiceSubscriptionCreateStep import onaptests.utils.exceptions as onap_test_exceptions @@ -73,7 +72,7 @@ class YamlTemplateServiceMacroInstantiateStep(YamlTemplateBaseStep): if self.is_root: if not self._yaml_template: with open(settings.SERVICE_YAML_TEMPLATE, "r") as yaml_template: - self._yaml_template: dict = load(yaml_template) + self._yaml_template: dict = load(yaml_template, SafeLoader) return self._yaml_template return self.parent.yaml_template @@ -144,6 +143,7 @@ class YamlTemplateServiceMacroInstantiateStep(YamlTemplateBaseStep): super().execute() service = Service(self.service_name) customer: Customer = Customer.get_by_global_customer_id(settings.GLOBAL_CUSTOMER_ID) + service_subscription: ServiceSubscription = customer.get_service_subscription_by_service_type(service.name) if any( filter(lambda x: x in self.yaml_template[self.service_name].keys(), ["vnfs", "networks"])): @@ -161,9 +161,6 @@ class YamlTemplateServiceMacroInstantiateStep(YamlTemplateBaseStep): except ResourceNotFound: self._logger.info("Owning entity not found, create it") owning_entity = OwningEntity.create(settings.OWNING_ENTITY) - vid_project: Project = Project(settings.PROJECT) - line_of_business: LineOfBusiness = LineOfBusiness(settings.LINE_OF_BUSINESS) - platform: Platform = Platform(settings.PLATFORM) # Before instantiating, be sure that the service has been distributed self._logger.info("******** Check Service Distribution *******") @@ -210,11 +207,12 @@ class YamlTemplateServiceMacroInstantiateStep(YamlTemplateBaseStep): sdc_service=service, customer=customer, owning_entity=owning_entity, - project=vid_project, - line_of_business=line_of_business, - platform=platform, + project=settings.PROJECT, + line_of_business=settings.LINE_OF_BUSINESS, + platform=settings.PLATFORM, cloud_region=cloud_region, tenant=tenant, + service_subscription=service_subscription, service_instance_name=self.service_instance_name, vnf_parameters=vnf_params_list, enable_multicloud=settings.USE_MULTICLOUD, diff --git a/src/onaptests/steps/instantiate/vf_module_ala_carte.py b/src/onaptests/steps/instantiate/vf_module_ala_carte.py index af569fe..38bdee9 100644 --- a/src/onaptests/steps/instantiate/vf_module_ala_carte.py +++ b/src/onaptests/steps/instantiate/vf_module_ala_carte.py @@ -1,6 +1,6 @@ from typing import Iterable from uuid import uuid4 -from yaml import load +from yaml import load, SafeLoader from onapsdk.aai.cloud_infrastructure import CloudRegion, Tenant from onapsdk.aai.business import Customer, ServiceInstance, ServiceSubscription @@ -56,7 +56,7 @@ class YamlTemplateVfModuleAlaCarteInstantiateStep(YamlTemplateBaseStep): if self.is_root: if not self._yaml_template: with open(settings.SERVICE_YAML_TEMPLATE, "r") as yaml_template: - self._yaml_template: dict = load(yaml_template) + self._yaml_template: dict = load(yaml_template, SafeLoader) return self._yaml_template return self.parent.yaml_template diff --git a/src/onaptests/steps/instantiate/vl_ala_carte.py b/src/onaptests/steps/instantiate/vl_ala_carte.py index 3f81228..7186c24 100644 --- a/src/onaptests/steps/instantiate/vl_ala_carte.py +++ b/src/onaptests/steps/instantiate/vl_ala_carte.py @@ -1,7 +1,7 @@ import re from typing import Iterable from uuid import uuid4 -from yaml import load +from yaml import load, SafeLoader from onapsdk.aai.business import Customer, ServiceInstance, ServiceSubscription from onapsdk.configuration import settings @@ -51,7 +51,7 @@ class YamlTemplateVlAlaCarteInstantiateStep(YamlTemplateBaseStep): if self.is_root: if not self._yaml_template: with open(settings.SERVICE_YAML_TEMPLATE, "r") as yaml_template: - self._yaml_template: dict = load(yaml_template) + self._yaml_template: dict = load(yaml_template, SafeLoader) return self._yaml_template return self.parent.yaml_template diff --git a/src/onaptests/steps/instantiate/vnf_ala_carte.py b/src/onaptests/steps/instantiate/vnf_ala_carte.py index 8dbec78..eb9896f 100644 --- a/src/onaptests/steps/instantiate/vnf_ala_carte.py +++ b/src/onaptests/steps/instantiate/vnf_ala_carte.py @@ -1,5 +1,5 @@ from uuid import uuid4 -from yaml import load +from yaml import load, SafeLoader from onapsdk.aai.cloud_infrastructure import CloudRegion, Tenant from onapsdk.aai.business import Customer, ServiceInstance, ServiceSubscription @@ -49,7 +49,7 @@ class YamlTemplateVnfAlaCarteInstantiateStep(YamlTemplateBaseStep): if self.is_root: if not self._yaml_template: with open(settings.SERVICE_YAML_TEMPLATE, "r") as yaml_template: - self._yaml_template: dict = load(yaml_template) + self._yaml_template: dict = load(yaml_template, SafeLoader) return self._yaml_template return self.parent.yaml_template |