aboutsummaryrefslogtreecommitdiffstats
path: root/src/onaptests/steps/onboard
diff options
context:
space:
mode:
Diffstat (limited to 'src/onaptests/steps/onboard')
-rw-r--r--src/onaptests/steps/onboard/cds.py38
-rw-r--r--src/onaptests/steps/onboard/clamp.py8
-rw-r--r--src/onaptests/steps/onboard/cps.py22
-rw-r--r--src/onaptests/steps/onboard/msb_k8s.py14
-rw-r--r--src/onaptests/steps/onboard/pnf.py26
-rw-r--r--src/onaptests/steps/onboard/service.py43
-rw-r--r--src/onaptests/steps/onboard/vendor.py11
-rw-r--r--src/onaptests/steps/onboard/vf.py26
-rw-r--r--src/onaptests/steps/onboard/vsp.py26
9 files changed, 142 insertions, 72 deletions
diff --git a/src/onaptests/steps/onboard/cds.py b/src/onaptests/steps/onboard/cds.py
index 5256eac..2074296 100644
--- a/src/onaptests/steps/onboard/cds.py
+++ b/src/onaptests/steps/onboard/cds.py
@@ -14,7 +14,6 @@ from onapsdk.configuration import settings
import urllib3
from onaptests.steps.base import BaseStep
-
from onaptests.utils.exceptions import OnapTestException
@@ -30,9 +29,9 @@ class CDSBaseStep(BaseStep, ABC):
class ExposeCDSBlueprintprocessorNodePortStep(CDSBaseStep):
"""Expose CDS blueprintsprocessor port."""
- def __init__(self, cleanup: bool) -> None:
+ def __init__(self) -> None:
"""Initialize step."""
- super().__init__(cleanup=cleanup)
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
self.service_name: str = "cds-blueprints-processor-http"
if settings.IN_CLUSTER:
config.load_incluster_config()
@@ -92,6 +91,7 @@ class ExposeCDSBlueprintprocessorNodePortStep(CDSBaseStep):
else:
self._logger.debug("Service already patched, skip")
+ @BaseStep.store_state(cleanup=True)
def cleanup(self) -> None:
"""Step cleanup.
@@ -129,15 +129,15 @@ class ExposeCDSBlueprintprocessorNodePortStep(CDSBaseStep):
class BootstrapBlueprintprocessor(CDSBaseStep):
"""Bootstrap blueprintsprocessor."""
- def __init__(self, cleanup: bool = False) -> None:
+ def __init__(self) -> None:
"""Initialize step.
Substeps:
- ExposeCDSBlueprintprocessorNodePortStep.
"""
- super().__init__(cleanup=cleanup)
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
if settings.EXPOSE_SERVICES_NODE_PORTS:
- self.add_step(ExposeCDSBlueprintprocessorNodePortStep(cleanup=cleanup))
+ self.add_step(ExposeCDSBlueprintprocessorNodePortStep())
@property
def description(self) -> str:
@@ -154,10 +154,10 @@ class BootstrapBlueprintprocessor(CDSBaseStep):
class DataDictionaryUploadStep(CDSBaseStep):
"""Upload data dictionaries to CDS step."""
- def __init__(self, cleanup: bool = False) -> None:
+ def __init__(self) -> None:
"""Initialize data dictionary upload step."""
- super().__init__(cleanup=cleanup)
- self.add_step(BootstrapBlueprintprocessor(cleanup=cleanup))
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
+ self.add_step(BootstrapBlueprintprocessor())
@property
def description(self) -> str:
@@ -180,10 +180,10 @@ class DataDictionaryUploadStep(CDSBaseStep):
class CbaEnrichStep(CDSBaseStep):
"""Enrich CBA file step."""
- def __init__(self, cleanup=False) -> None:
+ def __init__(self) -> None:
"""Initialize CBA enrichment step."""
- super().__init__(cleanup=cleanup)
- self.add_step(DataDictionaryUploadStep(cleanup=cleanup))
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
+ self.add_step(DataDictionaryUploadStep())
@property
def description(self) -> str:
@@ -217,14 +217,14 @@ class CbaEnrichStep(CDSBaseStep):
class CbaPublishStep(CDSBaseStep):
"""Publish CBA file step."""
- def __init__(self, cleanup=False) -> None:
+ def __init__(self) -> None:
"""Initialize CBA publish step."""
- super().__init__(cleanup=cleanup)
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
"""Let's skip enrichment if enriched CBA is already present"""
if Path.is_file(settings.CDS_CBA_UNENRICHED):
- self.add_step(CbaEnrichStep(cleanup=cleanup))
+ self.add_step(CbaEnrichStep())
elif settings.EXPOSE_SERVICES_NODE_PORTS:
- self.add_step(ExposeCDSBlueprintprocessorNodePortStep(cleanup=cleanup))
+ self.add_step(ExposeCDSBlueprintprocessorNodePortStep())
@property
def description(self) -> str:
@@ -247,10 +247,10 @@ class CbaPublishStep(CDSBaseStep):
class CbaProcessStep(CDSBaseStep):
"""Process CBA step."""
- def __init__(self, cleanup=False) -> None:
+ def __init__(self) -> None:
"""Initialize CBA process step."""
- super().__init__(cleanup=cleanup)
- self.add_step(CbaPublishStep(cleanup=cleanup))
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
+ self.add_step(CbaPublishStep())
@property
def description(self) -> str:
diff --git a/src/onaptests/steps/onboard/clamp.py b/src/onaptests/steps/onboard/clamp.py
index c8984ba..7cb20ff 100644
--- a/src/onaptests/steps/onboard/clamp.py
+++ b/src/onaptests/steps/onboard/clamp.py
@@ -7,18 +7,18 @@ from onapsdk.sdc.vf import Vf
from onapsdk.configuration import settings
-from ..base import YamlTemplateBaseStep
+from ..base import BaseStep, YamlTemplateBaseStep
from .service import YamlTemplateVfOnboardStep
class OnboardClampStep(YamlTemplateBaseStep):
"""Onboard class to create CLAMP templates."""
- def __init__(self, cleanup=False):
+ def __init__(self):
"""Initialize Clamp Onboard object."""
- super().__init__(cleanup=cleanup)
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
self._yaml_template: dict = None
- self.add_step(YamlTemplateVfOnboardStep(cleanup=cleanup))
+ self.add_step(YamlTemplateVfOnboardStep())
# if "service_name" in kwargs:
# self.service_name = kwargs['service_name']
# else:
diff --git a/src/onaptests/steps/onboard/cps.py b/src/onaptests/steps/onboard/cps.py
index e582489..55598bf 100644
--- a/src/onaptests/steps/onboard/cps.py
+++ b/src/onaptests/steps/onboard/cps.py
@@ -20,6 +20,10 @@ class CpsBaseStep(BaseStep, ABC):
class CreateCpsDataspaceStep(CpsBaseStep):
"""Step to create a dataspace."""
+ def __init__(self) -> None:
+ """Initialize step."""
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
+
@property
def description(self) -> str:
"""Step description."""
@@ -47,14 +51,14 @@ class CreateCpsDataspaceStep(CpsBaseStep):
class CreateCpsSchemaSetStep(CpsBaseStep):
"""Step to check schema-set creation."""
- def __init__(self, cleanup: bool = False) -> None:
+ def __init__(self) -> None:
"""Initialize step.
Substeps:
- CreateCpsDataspaceStep.
"""
- super().__init__(cleanup)
- self.add_step(CreateCpsDataspaceStep(cleanup))
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
+ self.add_step(CreateCpsDataspaceStep())
@property
def description(self) -> str:
@@ -87,14 +91,14 @@ class CreateCpsSchemaSetStep(CpsBaseStep):
class CreateCpsAnchorStep(CpsBaseStep):
"""Step to create an anchor."""
- def __init__(self, cleanup: bool = False) -> None:
+ def __init__(self) -> None:
"""Initialize step.
Substeps:
- CreateCpsSchemaSetStep.
"""
- super().__init__(cleanup)
- self.add_step(CreateCpsSchemaSetStep(cleanup))
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
+ self.add_step(CreateCpsSchemaSetStep())
@property
def description(self) -> str:
@@ -130,14 +134,14 @@ class CreateCpsAnchorStep(CpsBaseStep):
class CreateCpsAnchorNodeStep(CpsBaseStep):
"""Step to check node on anchor creation."""
- def __init__(self, cleanup: bool = False) -> None:
+ def __init__(self) -> None:
"""Initialize step.
Substeps:
- CreateCpsAnchorStep.
"""
- super().__init__(cleanup)
- self.add_step(CreateCpsAnchorStep(cleanup))
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
+ self.add_step(CreateCpsAnchorStep())
@property
def description(self) -> str:
diff --git a/src/onaptests/steps/onboard/msb_k8s.py b/src/onaptests/steps/onboard/msb_k8s.py
index 666de33..db8d934 100644
--- a/src/onaptests/steps/onboard/msb_k8s.py
+++ b/src/onaptests/steps/onboard/msb_k8s.py
@@ -10,16 +10,16 @@ from onaptests.steps.cloud.k8s_connectivity_info_create import K8SConnectivityIn
class CreateDefinitionStep(BaseStep):
"""Create definition step initialization."""
- def __init__(self, cleanup: bool = False) -> None:
+ def __init__(self) -> None:
"""Initialize step.
Substeps:
- CloudRegionCreateStep,
- K8SConnectivityInfoStep.
"""
- super().__init__(cleanup=cleanup)
- self.add_step(CloudRegionCreateStep(cleanup=cleanup))
- self.add_step(K8SConnectivityInfoStep(cleanup=cleanup))
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
+ self.add_step(CloudRegionCreateStep())
+ self.add_step(K8SConnectivityInfoStep())
self.definition: Definition = None
@property
@@ -45,14 +45,14 @@ class CreateDefinitionStep(BaseStep):
class CreateProfileStep(BaseStep):
"""Create profile step."""
- def __init__(self, cleanup: bool = False) -> None:
+ def __init__(self) -> None:
"""Initialize step.
Substeps:
- CreateDefinitionStep.
"""
- super().__init__(cleanup=cleanup)
- self.add_step(CreateDefinitionStep(cleanup=cleanup))
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
+ self.add_step(CreateDefinitionStep())
self.profile: Profile = None
@property
diff --git a/src/onaptests/steps/onboard/pnf.py b/src/onaptests/steps/onboard/pnf.py
index 1c76202..8e0cd12 100644
--- a/src/onaptests/steps/onboard/pnf.py
+++ b/src/onaptests/steps/onboard/pnf.py
@@ -11,7 +11,7 @@ from .vsp import VspOnboardStep, YamlTemplateVspOnboardStep
class PnfOnboardStep(BaseStep):
"""PNF onboard step."""
- def __init__(self, cleanup: bool = False) -> None:
+ def __init__(self) -> None:
"""Step initialization.
Substeps:
@@ -21,8 +21,8 @@ class PnfOnboardStep(BaseStep):
cleanup(bool, optional): Determines if cleanup action should be called.
"""
- super().__init__(cleanup=cleanup)
- self.add_step(VspOnboardStep(cleanup=cleanup))
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
+ self.add_step(VspOnboardStep())
@property
def description(self) -> str:
@@ -34,6 +34,13 @@ class PnfOnboardStep(BaseStep):
"""Component name."""
return "SDC"
+ def check_preconditions(self, cleanup=False) -> bool:
+ if not super().check_preconditions(cleanup):
+ return False
+ if cleanup:
+ return settings.SDC_CLEANUP
+ return True
+
@BaseStep.store_state
def execute(self) -> None:
"""Onboard PNF in SDC.
@@ -72,7 +79,7 @@ class PnfOnboardStep(BaseStep):
class YamlTemplatePnfOnboardStep(YamlTemplateBaseStep):
"""PNF onboard using YAML template step."""
- def __init__(self, cleanup: bool = False) -> None:
+ def __init__(self) -> None:
"""Step initialization.
Substeps:
@@ -82,8 +89,8 @@ class YamlTemplatePnfOnboardStep(YamlTemplateBaseStep):
cleanup(bool, optional): Determines if cleanup action should be called.
"""
- super().__init__(cleanup=cleanup)
- self.add_step(YamlTemplateVspOnboardStep(cleanup=cleanup))
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
+ self.add_step(YamlTemplateVspOnboardStep())
@property
def description(self) -> str:
@@ -95,6 +102,13 @@ class YamlTemplatePnfOnboardStep(YamlTemplateBaseStep):
"""Component name."""
return "SDC"
+ def check_preconditions(self, cleanup=False) -> bool:
+ if not super().check_preconditions(cleanup):
+ return False
+ if cleanup:
+ return settings.SDC_CLEANUP
+ return True
+
@property
def yaml_template(self) -> dict:
"""YAML template.
diff --git a/src/onaptests/steps/onboard/service.py b/src/onaptests/steps/onboard/service.py
index c0bec0d..be0f6fd 100644
--- a/src/onaptests/steps/onboard/service.py
+++ b/src/onaptests/steps/onboard/service.py
@@ -20,17 +20,17 @@ from .vf import VfOnboardStep, YamlTemplateVfOnboardStep
class ServiceOnboardStep(BaseStep):
"""Service onboard step."""
- def __init__(self, cleanup=False):
+ def __init__(self):
"""Initialize step.
Substeps:
- VfOnboardStep.
"""
- super().__init__(cleanup=cleanup)
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
if settings.VF_NAME != "":
- self.add_step(VfOnboardStep(cleanup=cleanup))
+ self.add_step(VfOnboardStep())
if settings.PNF_NAME != "":
- self.add_step(PnfOnboardStep(cleanup=cleanup))
+ self.add_step(PnfOnboardStep())
@property
def description(self) -> str:
@@ -42,6 +42,13 @@ class ServiceOnboardStep(BaseStep):
"""Component name."""
return "SDC"
+ def check_preconditions(self, cleanup=False) -> bool:
+ if not super().check_preconditions(cleanup):
+ return False
+ if cleanup:
+ return settings.SDC_CLEANUP
+ return True
+
@BaseStep.store_state
def execute(self):
"""Onboard service.
@@ -97,19 +104,19 @@ class ServiceOnboardStep(BaseStep):
class YamlTemplateServiceOnboardStep(YamlTemplateBaseStep):
"""Service onboard using YAML template step."""
- def __init__(self, cleanup=False):
+ def __init__(self):
"""Initialize step.
Substeps:
- YamlTemplateVfOnboardStep.
"""
- super().__init__(cleanup=cleanup)
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
self._yaml_template: dict = None
self._model_yaml_template: dict = None
if "vnfs" in self.yaml_template[self.service_name]:
- self.add_step(YamlTemplateVfOnboardStep(cleanup=cleanup))
+ self.add_step(YamlTemplateVfOnboardStep())
if "pnfs" in self.yaml_template[self.service_name]:
- self.add_step(YamlTemplatePnfOnboardStep(cleanup=cleanup))
+ self.add_step(YamlTemplatePnfOnboardStep())
@property
def description(self) -> str:
@@ -121,6 +128,13 @@ class YamlTemplateServiceOnboardStep(YamlTemplateBaseStep):
"""Component name."""
return "SDC"
+ def check_preconditions(self, cleanup=False) -> bool:
+ if not super().check_preconditions(cleanup):
+ return False
+ if cleanup:
+ return settings.SDC_CLEANUP
+ return True
+
@property
def yaml_template(self) -> dict:
"""Step YAML template.
@@ -153,7 +167,7 @@ class YamlTemplateServiceOnboardStep(YamlTemplateBaseStep):
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)
+ self._model_yaml_template: dict = load(model_yaml_template, SafeLoader)
return self._model_yaml_template
return self.parent.model_yaml_template
@@ -269,9 +283,8 @@ class YamlTemplateServiceOnboardStep(YamlTemplateBaseStep):
@YamlTemplateBaseStep.store_state(cleanup=True)
def cleanup(self) -> None:
"""Cleanup service onboard step."""
- if settings.SDC_CLEANUP:
- service: Service = Service(name=self.service_name)
- if service.exists():
- service.archive()
- service.delete()
- super().cleanup()
+ service: Service = Service(name=self.service_name)
+ if service.exists():
+ service.archive()
+ service.delete()
+ super().cleanup()
diff --git a/src/onaptests/steps/onboard/vendor.py b/src/onaptests/steps/onboard/vendor.py
index b3761d2..ae93738 100644
--- a/src/onaptests/steps/onboard/vendor.py
+++ b/src/onaptests/steps/onboard/vendor.py
@@ -7,6 +7,10 @@ from ..base import BaseStep
class VendorOnboardStep(BaseStep):
"""Vendor onboard step."""
+ def __init__(self):
+ """Initialize step."""
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
+
@property
def description(self) -> str:
"""Step description."""
@@ -17,6 +21,13 @@ class VendorOnboardStep(BaseStep):
"""Component name."""
return "SDC"
+ def check_preconditions(self, cleanup=False) -> bool:
+ if not super().check_preconditions(cleanup):
+ return False
+ if cleanup:
+ return settings.SDC_CLEANUP
+ return True
+
@BaseStep.store_state
def execute(self):
"""Onboard vendor.
diff --git a/src/onaptests/steps/onboard/vf.py b/src/onaptests/steps/onboard/vf.py
index b614fd5..3fc7443 100644
--- a/src/onaptests/steps/onboard/vf.py
+++ b/src/onaptests/steps/onboard/vf.py
@@ -13,14 +13,14 @@ from .vsp import VspOnboardStep, YamlTemplateVspOnboardStep
class VfOnboardStep(BaseStep):
"""Vf onboard step."""
- def __init__(self, cleanup=False):
+ def __init__(self):
"""Initialize step.
Substeps:
- VspOnboardStep.
"""
- super().__init__(cleanup=cleanup)
- self.add_step(VspOnboardStep(cleanup=cleanup))
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
+ self.add_step(VspOnboardStep())
@property
def description(self) -> str:
@@ -32,6 +32,13 @@ class VfOnboardStep(BaseStep):
"""Component name."""
return "SDC"
+ def check_preconditions(self, cleanup=False) -> bool:
+ if not super().check_preconditions(cleanup):
+ return False
+ if cleanup:
+ return settings.SDC_CLEANUP
+ return True
+
@BaseStep.store_state
def execute(self):
"""Onboard Vf.
@@ -59,14 +66,14 @@ class VfOnboardStep(BaseStep):
class YamlTemplateVfOnboardStep(YamlTemplateBaseStep):
"""Vf onboard using YAML template step."""
- def __init__(self, cleanup=False) -> None:
+ def __init__(self) -> None:
"""Initialize step.
Substeps:
- YamlTemplateVspOnboardStep.
"""
- super().__init__(cleanup=cleanup)
- self.add_step(YamlTemplateVspOnboardStep(cleanup=cleanup))
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
+ self.add_step(YamlTemplateVspOnboardStep())
@property
def description(self) -> str:
@@ -78,6 +85,13 @@ class YamlTemplateVfOnboardStep(YamlTemplateBaseStep):
"""Component name."""
return "SDC"
+ def check_preconditions(self, cleanup=False) -> bool:
+ if not super().check_preconditions(cleanup):
+ return False
+ if cleanup:
+ return settings.SDC_CLEANUP
+ return True
+
@property
def yaml_template(self) -> dict:
"""YAML template.
diff --git a/src/onaptests/steps/onboard/vsp.py b/src/onaptests/steps/onboard/vsp.py
index 577b1cf..06e0fa2 100644
--- a/src/onaptests/steps/onboard/vsp.py
+++ b/src/onaptests/steps/onboard/vsp.py
@@ -10,14 +10,14 @@ from .vendor import VendorOnboardStep
class VspOnboardStep(BaseStep):
"""Vsp onboard step."""
- def __init__(self, cleanup=False):
+ def __init__(self):
"""Initialize step.
Substeps:
- VendorOnboardStep.
"""
- super().__init__(cleanup=cleanup)
- self.add_step(VendorOnboardStep(cleanup=cleanup))
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
+ self.add_step(VendorOnboardStep())
@property
def description(self) -> str:
@@ -29,6 +29,13 @@ class VspOnboardStep(BaseStep):
"""Component name."""
return "SDC"
+ def check_preconditions(self, cleanup=False) -> bool:
+ if not super().check_preconditions(cleanup):
+ return False
+ if cleanup:
+ return settings.SDC_CLEANUP
+ return True
+
@BaseStep.store_state
def execute(self):
"""Onboard Vsp.
@@ -58,14 +65,14 @@ class VspOnboardStep(BaseStep):
class YamlTemplateVspOnboardStep(YamlTemplateBaseStep):
"""Vsp onboard using YAML template step."""
- def __init__(self, cleanup=False):
+ def __init__(self):
"""Initialize step.
Substeps:
- VendorOnboardStep.
"""
- super().__init__(cleanup=cleanup)
- self.add_step(VendorOnboardStep(cleanup=cleanup))
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
+ self.add_step(VendorOnboardStep())
@property
def description(self) -> str:
@@ -77,6 +84,13 @@ class YamlTemplateVspOnboardStep(YamlTemplateBaseStep):
"""Component name."""
return "SDC"
+ def check_preconditions(self, cleanup=False) -> bool:
+ if not super().check_preconditions(cleanup):
+ return False
+ if cleanup:
+ return settings.SDC_CLEANUP
+ return True
+
@property
def yaml_template(self) -> dict:
"""YAML template.