aboutsummaryrefslogtreecommitdiffstats
path: root/src/onaptests/steps
diff options
context:
space:
mode:
Diffstat (limited to 'src/onaptests/steps')
-rw-r--r--src/onaptests/steps/base.py11
-rw-r--r--src/onaptests/steps/cloud/register_cloud.py62
-rw-r--r--src/onaptests/steps/instantiate/service_macro.py47
-rw-r--r--src/onaptests/steps/onboard/cds.py30
-rw-r--r--src/onaptests/steps/onboard/vf.py11
5 files changed, 110 insertions, 51 deletions
diff --git a/src/onaptests/steps/base.py b/src/onaptests/steps/base.py
index 8c67e5d..6d43fbc 100644
--- a/src/onaptests/steps/base.py
+++ b/src/onaptests/steps/base.py
@@ -5,7 +5,7 @@ import logging.config
import time
from abc import ABC, abstractmethod
-from typing import Iterator, List
+from typing import Iterator, List, Optional
from onapsdk.aai.business import Customer
from onapsdk.configuration import settings
from onapsdk.exceptions import SDKException, SettingsError
@@ -168,14 +168,15 @@ class BaseStep(ABC):
try:
if cleanup:
self._start_cleanup_time = time.time()
+ execution_status: Optional[ReportStepStatus] = None
ret = fun(self, *args, **kwargs)
- execution_status: ReportStepStatus = ReportStepStatus.PASS
+ execution_status = ReportStepStatus.PASS
return ret
except SubstepExecutionException:
- execution_status: ReportStepStatus = ReportStepStatus.PASS if cleanup else ReportStepStatus.NOT_EXECUTED
+ execution_status = ReportStepStatus.PASS if cleanup else ReportStepStatus.NOT_EXECUTED
raise
except (OnapTestException, SDKException):
- execution_status: ReportStepStatus = ReportStepStatus.FAIL
+ execution_status = ReportStepStatus.FAIL
raise
finally:
if cleanup:
@@ -191,7 +192,7 @@ class BaseStep(ABC):
self._start_execution_time = time.time()
self._execution_report = Report(
step_description=f"[{self.component}] {self.name}: {self.description}",
- step_execution_status=execution_status,
+ step_execution_status=execution_status if execution_status else ReportStepStatus.FAIL,
step_execution_duration=time.time() - self._start_execution_time
)
return wrapper
diff --git a/src/onaptests/steps/cloud/register_cloud.py b/src/onaptests/steps/cloud/register_cloud.py
index 58c3e35..3065461 100644
--- a/src/onaptests/steps/cloud/register_cloud.py
+++ b/src/onaptests/steps/cloud/register_cloud.py
@@ -46,34 +46,37 @@ class RegisterCloudRegionStep(BaseStep):
- TENANT_NAME.
"""
super().execute()
- try:
- cloud_region: CloudRegion = CloudRegion.get_by_id(
- cloud_owner=settings.CLOUD_REGION_CLOUD_OWNER,
- cloud_region_id=settings.CLOUD_REGION_ID)
- except ResourceNotFound:
- cloud_region.add_esr_system_info(
- esr_system_info_id=str(uuid4()),
- user_name=settings.VIM_USERNAME,
- password=settings.VIM_PASSWORD,
- system_type="VIM",
- service_url=settings.VIM_SERVICE_URL,
- ssl_insecure=False,
- system_status="active",
- cloud_domain=settings.CLOUD_DOMAIN,
- default_tenant=settings.TENANT_NAME
- )
- if settings.USE_MULTICLOUD:
- self._logger.info("*Multicloud registration *")
- cloud_region.register_to_multicloud()
- time.sleep(20)
- nb_try = 0
- nb_try_max = 3
- while nb_try < nb_try_max:
+ cloud_region: CloudRegion = 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="VIM",
+ service_url=settings.VIM_SERVICE_URL,
+ ssl_insecure=False,
+ system_status="active",
+ cloud_domain=settings.CLOUD_DOMAIN,
+ default_tenant=settings.TENANT_NAME
+ )
+ if settings.USE_MULTICLOUD:
+ self._logger.info("*Multicloud registration *")
+ cloud_region.register_to_multicloud()
+ time.sleep(20)
+ nb_try = 0
+ nb_try_max = 3
+ while nb_try < nb_try_max:
+ try:
if not cloud_region.tenants:
+ self._logger.debug("No tenats available, check one more time")
time.sleep(20)
else:
break
- nb_try += 1
+ except ResourceNotFound:
+ self._logger.debug("No tenats available, check one more time")
+ time.sleep(20)
+ nb_try += 1
# Retrieve the tenant, created by multicloud registration
# if it does not exist, create it
@@ -81,10 +84,13 @@ class RegisterCloudRegionStep(BaseStep):
cloud_region.get_tenant(settings.TENANT_ID)
except ResourceNotFound:
self._logger.warning("Impossible to retrieve the Specificed Tenant")
- self._logger.debug("If no multicloud selected, add the tenant")
- cloud_region.add_tenant(
- tenant_id=settings.TENANT_ID,
- tenant_name=settings.TENANT_NAME)
+ self._logger.debug("If no multicloud selected, add the tenant, reraise otherwise")
+ if not settings.USE_MULTICLOUD:
+ cloud_region.add_tenant(
+ tenant_id=settings.TENANT_ID,
+ tenant_name=settings.TENANT_NAME)
+ else:
+ raise
# be sure that an availability zone has been created
# if not, create it
diff --git a/src/onaptests/steps/instantiate/service_macro.py b/src/onaptests/steps/instantiate/service_macro.py
index 14470f8..1264dd8 100644
--- a/src/onaptests/steps/instantiate/service_macro.py
+++ b/src/onaptests/steps/instantiate/service_macro.py
@@ -1,5 +1,6 @@
import time
+from typing import List
from uuid import uuid4
from onapsdk.aai.business.service import ServiceInstance
from yaml import load
@@ -11,7 +12,7 @@ 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 ServiceInstantiation
+from onapsdk.so.instantiation import InstantiationParameter, ServiceInstantiation, VfmoduleParameters, VnfParameters
from onapsdk.vid import LineOfBusiness, Platform, Project
from onaptests.steps.cloud.customer_service_subscription_create import CustomerServiceSubscriptionCreateStep
@@ -39,13 +40,12 @@ class YamlTemplateServiceMacroInstantiateStep(YamlTemplateBaseStep):
if not settings.ONLY_INSTANTIATE:
self.add_step(YamlTemplateServiceOnboardStep(cleanup))
- are_pnfs: bool = "pnfs" in self.yaml_template[self.service_name]
if any(
filter(lambda x: x in self.yaml_template[self.service_name].keys(),
["vnfs", "networks"])):
# can additionally contain "pnfs", no difference
self.add_step(ConnectServiceSubToCloudRegionStep(cleanup))
- elif are_pnfs: # only pnfs
+ else: # only pnfs
self.add_step(CustomerServiceSubscriptionCreateStep(cleanup))
@@ -126,7 +126,9 @@ class YamlTemplateServiceMacroInstantiateStep(YamlTemplateBaseStep):
super().execute()
service = Service(self.service_name)
customer: Customer = Customer.get_by_global_customer_id(settings.GLOBAL_CUSTOMER_ID)
- if any(["networks", "vnfs"]) in self.yaml_template[self.service_name]:
+ if any(
+ filter(lambda x: x in self.yaml_template[self.service_name].keys(),
+ ["vnfs", "networks"])):
cloud_region: CloudRegion = CloudRegion.get_by_id(
cloud_owner=settings.CLOUD_REGION_CLOUD_OWNER,
cloud_region_id=settings.CLOUD_REGION_ID,
@@ -168,6 +170,16 @@ class YamlTemplateServiceMacroInstantiateStep(YamlTemplateBaseStep):
"Service Distribution for %s failed !!",service.name)
raise onap_test_exceptions.ServiceDistributionException
+ 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", [])]) \
+ for vf_module_data in vnf_data.get("vf_module_parameters", [])]
+ ))
+
service_instantiation = ServiceInstantiation.instantiate_macro(
service,
customer=customer,
@@ -177,7 +189,9 @@ class YamlTemplateServiceMacroInstantiateStep(YamlTemplateBaseStep):
platform=platform,
cloud_region=cloud_region,
tenant=tenant,
- service_instance_name=self.service_instance_name
+ service_instance_name=self.service_instance_name,
+ vnf_parameters=vnf_params_list,
+ enable_multicloud=settings.USE_MULTICLOUD
)
try:
service_instantiation.wait_for_finish(timeout=settings.ORCHESTRATION_REQUEST_TIMEOUT)
@@ -199,15 +213,16 @@ class YamlTemplateServiceMacroInstantiateStep(YamlTemplateBaseStep):
Exception: Service cleaning failed
"""
- service_deletion = self._service_instance.delete()
- try:
- service_deletion.wait_for_finish(timeout=settings.ORCHESTRATION_REQUEST_TIMEOUT)
- except TimeoutError:
- self._logger.error("Service deletion %s timed out", self._service_instance_name)
- raise onap_test_exceptions.ServiceCleanupException
- if service_deletion.finished:
- self._logger.info("Service %s deleted", self._service_instance_name)
- else:
- self._logger.error("Service deletion %s failed", self._service_instance_name)
- raise onap_test_exceptions.ServiceCleanupException
+ if self._service_instance:
+ service_deletion = self._service_instance.delete()
+ try:
+ service_deletion.wait_for_finish(timeout=settings.ORCHESTRATION_REQUEST_TIMEOUT)
+ except TimeoutError:
+ self._logger.error("Service deletion %s timed out", self._service_instance_name)
+ raise onap_test_exceptions.ServiceCleanupException
+ if service_deletion.finished:
+ self._logger.info("Service %s deleted", self._service_instance_name)
+ else:
+ self._logger.error("Service deletion %s failed", self._service_instance_name)
+ raise onap_test_exceptions.ServiceCleanupException
super().cleanup()
diff --git a/src/onaptests/steps/onboard/cds.py b/src/onaptests/steps/onboard/cds.py
index 185753b..f137adb 100644
--- a/src/onaptests/steps/onboard/cds.py
+++ b/src/onaptests/steps/onboard/cds.py
@@ -151,8 +151,8 @@ class CbaEnrichStep(CDSBaseStep):
"""
super().execute()
blueprint: Blueprint = Blueprint.load_from_file(settings.CDS_CBA_UNENRICHED)
- blueprint.enrich()
- blueprint.save(settings.CDS_CBA_ENRICHED)
+ enriched: Blueprint = blueprint.enrich()
+ enriched.save(settings.CDS_CBA_ENRICHED)
@BaseStep.store_state(cleanup=True)
def cleanup(self) -> None:
@@ -163,3 +163,29 @@ class CbaEnrichStep(CDSBaseStep):
"""
super().cleanup()
Path(settings.CDS_CBA_ENRICHED).unlink()
+
+
+class CbaPublishStep(CDSBaseStep):
+ """Publish CBA file step."""
+
+ def __init__(self, cleanup=False) -> None:
+ """Initialize CBA publish step."""
+ super().__init__(cleanup=cleanup)
+ self.add_step(CbaEnrichStep(cleanup=cleanup))
+
+ @property
+ def description(self) -> str:
+ """Step description."""
+ return "Publish CBA file."
+
+ @BaseStep.store_state
+ def execute(self) -> None:
+ """Enrich CBA file.
+
+ Use settings values:
+ - CDS_DD_FILE.
+
+ """
+ super().execute()
+ blueprint: Blueprint = Blueprint.load_from_file(settings.CDS_CBA_ENRICHED)
+ blueprint.publish()
diff --git a/src/onaptests/steps/onboard/vf.py b/src/onaptests/steps/onboard/vf.py
index 817b412..5f5fc4d 100644
--- a/src/onaptests/steps/onboard/vf.py
+++ b/src/onaptests/steps/onboard/vf.py
@@ -85,4 +85,15 @@ class YamlTemplateVfOnboardStep(YamlTemplateBaseStep):
for vnf in self.yaml_template["vnfs"]:
vsp: Vsp = Vsp(name=f"{vnf['vnf_name']}_VSP")
vf: Vf = Vf(name=vnf['vnf_name'], vsp=vsp)
+ if all([x in vnf for x in ["vnf_artifact_type",
+ "vnf_artifact_name",
+ "vnf_artifact_label",
+ "vnf_artifact_file_path"]]):
+ vf.create()
+ vf.add_deployment_artifact(
+ artifact_type=vnf["vnf_artifact_type"],
+ artifact_name=vnf["vnf_artifact_name"],
+ artifact_label=vnf["vnf_artifact_label"],
+ artifact=vnf["vnf_artifact_file_path"]
+ )
vf.onboard()