aboutsummaryrefslogtreecommitdiffstats
path: root/src/onaptests/steps/onboard/vf.py
diff options
context:
space:
mode:
authorMichal Jagiello <michal.jagiello@t-mobile.pl>2020-07-16 19:16:42 +0200
committerMichal Jagiello <michal.jagiello@t-mobile.pl>2020-08-24 17:39:38 +0000
commitf9b0c349a5c83f9278f6b115d334598201d9d7e6 (patch)
tree474e0928dda4a7fd8340f27ab72bb5bee7683fce /src/onaptests/steps/onboard/vf.py
parent9d674116f24285d68a80597202d393b74ac544ce (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/onboard/vf.py')
-rw-r--r--src/onaptests/steps/onboard/vf.py65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/onaptests/steps/onboard/vf.py b/src/onaptests/steps/onboard/vf.py
new file mode 100644
index 0000000..6d19b9a
--- /dev/null
+++ b/src/onaptests/steps/onboard/vf.py
@@ -0,0 +1,65 @@
+from onapsdk.configuration import settings
+from onapsdk.sdc.vf import Vf
+from onapsdk.sdc.vsp import Vsp
+
+from ..base import BaseStep, YamlTemplateBaseStep
+from .vsp import VspOnboardStep, YamlTemplateVspOnboardStep
+
+
+class VfOnboardStep(BaseStep):
+ """Vf onboard step."""
+
+ def __init__(self, cleanup=False):
+ """Initialize step.
+
+ Substeps:
+ - VspOnboardStep.
+ """
+ super().__init__(cleanup=cleanup)
+ self.add_step(VspOnboardStep(cleanup=cleanup))
+
+ def execute(self):
+ """Onboard Vf.
+
+ Use settings values:
+ - VSP_NAME,
+ - VF_NAME.
+
+ """
+ super().execute()
+ vsp: Vsp = Vsp(name=settings.VSP_NAME)
+ vf: Vf = Vf(name=settings.VF_NAME, vsp=vsp)
+ vf.onboard()
+
+
+class YamlTemplateVfOnboardStep(YamlTemplateBaseStep):
+ """Vf onboard using YAML template step."""
+
+ def __init__(self, cleanup=False) -> None:
+ """Initialize step.
+
+ Substeps:
+ - YamlTemplateVspOnboardStep.
+ """
+ super().__init__(cleanup=cleanup)
+ self.add_step(YamlTemplateVspOnboardStep(cleanup=cleanup))
+
+ @property
+ def yaml_template(self) -> dict:
+ """YAML template.
+
+ Get YAML template from parent using it's name.
+
+ Returns:
+ dict: YAML template
+
+ """
+ return self.parent.yaml_template[self.parent.name]
+
+ def execute(self):
+ """Onboard Vfs from YAML template."""
+ super().execute()
+ 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)
+ vf.onboard()