diff options
Diffstat (limited to 'src/onaptests/steps/instantiate')
5 files changed, 64 insertions, 17 deletions
diff --git a/src/onaptests/steps/instantiate/service_ala_carte.py b/src/onaptests/steps/instantiate/service_ala_carte.py index dd62f52..3407e8e 100644 --- a/src/onaptests/steps/instantiate/service_ala_carte.py +++ b/src/onaptests/steps/instantiate/service_ala_carte.py @@ -135,6 +135,10 @@ class YamlTemplateServiceAlaCarteInstantiateStep(YamlTemplateBaseStep): return self.parent.yaml_template @property + def model_yaml_template(self) -> dict: + return {} + + @property def service_name(self) -> str: """Service name. diff --git a/src/onaptests/steps/instantiate/service_macro.py b/src/onaptests/steps/instantiate/service_macro.py index d83d2fe..b169049 100644 --- a/src/onaptests/steps/instantiate/service_macro.py +++ b/src/onaptests/steps/instantiate/service_macro.py @@ -12,7 +12,8 @@ from onapsdk.aai.cloud_infrastructure.tenant import Tenant 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 +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 @@ -34,6 +35,7 @@ class YamlTemplateServiceMacroInstantiateStep(YamlTemplateBaseStep): """ super().__init__(cleanup=cleanup) self._yaml_template: dict = None + self._model_yaml_template: dict = None self._service_instance_name: str = None self._service_instance: str = None if not settings.ONLY_INSTANTIATE: @@ -76,6 +78,23 @@ class YamlTemplateServiceMacroInstantiateStep(YamlTemplateBaseStep): return self.parent.yaml_template @property + def model_yaml_template(self) -> dict: + """Step Model YAML template. + + Load from file if it's a root step, get from parent otherwise. + + Returns: + dict: Step YAML template + + """ + if self.is_root: + if not self._model_yaml_template: + with open(settings.MODEL_YAML_TEMPLATE, "r") as model_yaml_template: + self._model_yaml_template: dict = load(model_yaml_template) + return self._model_yaml_template + return self.parent.model_yaml_template + + @property def service_name(self) -> str: """Service name. @@ -142,6 +161,9 @@ 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 *******") @@ -163,31 +185,40 @@ class YamlTemplateServiceMacroInstantiateStep(YamlTemplateBaseStep): if distribution_completed is False: self._logger.error( - "Service Distribution for %s failed !!",service.name) + "Service Distribution for %s failed !!", service.name) raise onap_test_exceptions.ServiceDistributionException + so_service = None vnf_params_list: List[VnfParameters] = [] - for vnf_data in self.yaml_template[self.service_name].get("vnfs", []): - vnf_params_list.append(VnfParameters( - vnf_data["vnf_name"], - [InstantiationParameter(name=parameter["name"], value=parameter["value"]) for parameter in vnf_data.get("vnf_parameters", [])], - [VfmoduleParameters(vf_module_data["vf_module_name"], - [InstantiationParameter(name=parameter["name"], value=parameter["value"]) for parameter in vf_module_data.get("parameters", [])]) \ + if settings.MODEL_YAML_TEMPLATE: + so_data = self.yaml_template[self.service_name] + so_service = SoService(vnfs=so_data.get("vnfs", []), + subscription_service_type=so_data.get('subscription_service_type')) + else: + for vnf_data in self.yaml_template[self.service_name].get("vnfs", []): + vnf_params_list.append(VnfParameters( + vnf_data["vnf_name"], + [InstantiationParameter(name=parameter["name"], value=parameter["value"]) for parameter in + vnf_data.get("vnf_parameters", [])], + [VfmoduleParameters(vf_module_data["vf_module_name"], + [InstantiationParameter(name=parameter["name"], value=parameter["value"]) for + parameter in vf_module_data.get("parameters", [])]) \ for vf_module_data in vnf_data.get("vf_module_parameters", [])] - )) + )) service_instantiation = ServiceInstantiation.instantiate_macro( - service, + sdc_service=service, customer=customer, owning_entity=owning_entity, - project=settings.PROJECT, - line_of_business=settings.LINE_OF_BUSINESS, - platform=settings.PLATFORM, + project=vid_project, + line_of_business=line_of_business, + platform=platform, cloud_region=cloud_region, tenant=tenant, service_instance_name=self.service_instance_name, vnf_parameters=vnf_params_list, - enable_multicloud=settings.USE_MULTICLOUD + enable_multicloud=settings.USE_MULTICLOUD, + so_service=so_service ) try: service_instantiation.wait_for_finish(timeout=settings.ORCHESTRATION_REQUEST_TIMEOUT) @@ -197,9 +228,9 @@ class YamlTemplateServiceMacroInstantiateStep(YamlTemplateBaseStep): if service_instantiation.failed: self._logger.error("Service instantiation %s failed", self.service_instance_name) raise onap_test_exceptions.ServiceInstantiateException - else: - service_subscription: ServiceSubscription = customer.get_service_subscription_by_service_type(self.service_name) - self._service_instance: ServiceInstance = service_subscription.get_service_instance_by_name(self.service_instance_name) + + service_subscription: ServiceSubscription = customer.get_service_subscription_by_service_type(self.service_name) + self._service_instance: ServiceInstance = service_subscription.get_service_instance_by_name(self.service_instance_name) @YamlTemplateBaseStep.store_state(cleanup=True) def cleanup(self) -> None: diff --git a/src/onaptests/steps/instantiate/vf_module_ala_carte.py b/src/onaptests/steps/instantiate/vf_module_ala_carte.py index aacecc3..af569fe 100644 --- a/src/onaptests/steps/instantiate/vf_module_ala_carte.py +++ b/src/onaptests/steps/instantiate/vf_module_ala_carte.py @@ -61,6 +61,10 @@ class YamlTemplateVfModuleAlaCarteInstantiateStep(YamlTemplateBaseStep): return self.parent.yaml_template @property + def model_yaml_template(self) -> dict: + return {} + + @property def service_name(self) -> str: """Service name. diff --git a/src/onaptests/steps/instantiate/vl_ala_carte.py b/src/onaptests/steps/instantiate/vl_ala_carte.py index 3bb293a..158e437 100644 --- a/src/onaptests/steps/instantiate/vl_ala_carte.py +++ b/src/onaptests/steps/instantiate/vl_ala_carte.py @@ -56,6 +56,10 @@ class YamlTemplateVlAlaCarteInstantiateStep(YamlTemplateBaseStep): return self.parent.yaml_template @property + def model_yaml_template(self) -> dict: + return {} + + @property def service_name(self) -> str: """Service name. diff --git a/src/onaptests/steps/instantiate/vnf_ala_carte.py b/src/onaptests/steps/instantiate/vnf_ala_carte.py index b02c7ea..8dbec78 100644 --- a/src/onaptests/steps/instantiate/vnf_ala_carte.py +++ b/src/onaptests/steps/instantiate/vnf_ala_carte.py @@ -54,6 +54,10 @@ class YamlTemplateVnfAlaCarteInstantiateStep(YamlTemplateBaseStep): return self.parent.yaml_template @property + def model_yaml_template(self) -> dict: + return {} + + @property def service_name(self) -> str: """Service name. |