aboutsummaryrefslogtreecommitdiffstats
path: root/src/onaptests/steps/onboard
diff options
context:
space:
mode:
authorKrzysztof Kuzmicki <krzysztof.kuzmicki@nokia.com>2020-11-06 20:44:28 +0000
committerGerrit Code Review <gerrit@onap.org>2020-11-06 20:44:28 +0000
commit882e2b34db0ea53de3195303267c17d8809fca15 (patch)
treee75baa7f93f042fa43e4ee684adbf336b227b80c /src/onaptests/steps/onboard
parenteeeb7190de7185c9994e460cc0472e8817ab68aa (diff)
parent18642f67fcd7268a914fb6632f0f755336e8ba24 (diff)
Merge "Add CLAMP E2E tests"
Diffstat (limited to 'src/onaptests/steps/onboard')
-rw-r--r--src/onaptests/steps/onboard/clamp.py91
1 files changed, 91 insertions, 0 deletions
diff --git a/src/onaptests/steps/onboard/clamp.py b/src/onaptests/steps/onboard/clamp.py
new file mode 100644
index 0000000..8f6b6bf
--- /dev/null
+++ b/src/onaptests/steps/onboard/clamp.py
@@ -0,0 +1,91 @@
+#!/usr/bin/python
+# http://www.apache.org/licenses/LICENSE-2.0
+"""Clamp Onboard service class."""
+from yaml import load
+from onapsdk.sdc.service import Service
+from onapsdk.sdc.vf import Vf
+
+from onapsdk.configuration import settings
+
+from ..base import YamlTemplateBaseStep
+from .service import YamlTemplateVfOnboardStep
+
+class OnboardClampStep(YamlTemplateBaseStep):
+ """Onboard class to create CLAMP templates."""
+
+ def __init__(self, cleanup=False):
+ """Initialize Clamp Onboard object."""
+ super().__init__(cleanup=cleanup)
+ self._yaml_template: dict = None
+ self.add_step(YamlTemplateVfOnboardStep(cleanup=cleanup))
+ # if "service_name" in kwargs:
+ # self.service_name = kwargs['service_name']
+ # else:
+ # raise ValueError("Service Name to define")
+ # self.vf_list = []
+ # self.vsp_list = []
+ # self.set_logger()
+
+ @property
+ def yaml_template(self) -> dict:
+ """Step 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._yaml_template:
+ with open(settings.SERVICE_YAML_TEMPLATE, "r") as yaml_template:
+ self._yaml_template: dict = load(yaml_template)
+ return self._yaml_template
+ return self.parent.yaml_template
+
+ @property
+ def service_name(self) -> str:
+ """Service name.
+
+ Get from YAML template if it's a root step, get from parent otherwise.
+
+ Returns:
+ str: Service name
+
+ """
+ if self.is_root:
+ return next(iter(self.yaml_template.keys()))
+ else:
+ return self.parent.service_name
+
+ @YamlTemplateBaseStep.store_state
+ def execute(self):
+ """Onboard service."""
+ super().execute()
+ # retrieve the Vf
+ vf = None
+ for sdc_vf in Vf.get_all():
+ if sdc_vf.name == settings.VF_NAME:
+ vf = sdc_vf
+ self._logger.debug("Vf retrieved %s", vf)
+
+ service: Service = Service(name=self.service_name,
+ resources=[vf])
+ service.create()
+ self._logger.info(" Service %s created", service)
+
+ service.add_resource(vf)
+
+ # we add the artifact to the first VNF
+ self._logger.info("Try to add blueprint to %s", vf.name)
+ payload_file = open(settings.CONFIGURATION_PATH + 'clampnode.yaml', 'rb')
+ data = payload_file.read()
+ self._logger.info("DCAE INVENTORY BLUEPRINT file retrieved")
+ service.add_artifact_to_vf(vnf_name=vf.name,
+ artifact_type="DCAE_INVENTORY_BLUEPRINT",
+ artifact_name="clampnode.yaml",
+ artifact=data)
+ payload_file.close()
+ service.checkin()
+ service.onboard()
+ self._logger.info("DCAE INVENTORY BLUEPRINT ADDED")