aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--run_basic_onboard.py20
-rw-r--r--setup.cfg1
-rw-r--r--src/onaptests/configuration/basic_onboard_settings.py68
-rw-r--r--src/onaptests/configuration/settings.py2
-rw-r--r--src/onaptests/scenario/basic_onboard.py43
-rw-r--r--src/onaptests/templates/vnf-services/basic_onboard-service.yaml.j239
6 files changed, 172 insertions, 1 deletions
diff --git a/run_basic_onboard.py b/run_basic_onboard.py
new file mode 100644
index 0000000..835c661
--- /dev/null
+++ b/run_basic_onboard.py
@@ -0,0 +1,20 @@
+import logging.config
+import onaptests.utils.exceptions as onap_test_exceptions
+from onapsdk.configuration import settings
+from onaptests.steps.onboard.service import YamlTemplateServiceOnboardStep
+
+
+
+if __name__ == "__main__":
+ # logging configuration for onapsdk, it is not requested for onaptests
+ # Correction requested in onapsdk to avoid having this duplicate code
+ logging.config.dictConfig(settings.LOG_CONFIG)
+ logger = logging.getLogger("Basic Onboard")
+
+ basic_vm_onboard = YamlTemplateServiceOnboardStep(
+ cleanup=settings.CLEANUP_FLAG)
+ try:
+ basic_vm_onboard.execute()
+ except onap_test_exceptions.TestConfigurationException:
+ logger.error("Basic Onboard configuration error")
+ basic_vm_onboard.reports_collection.generate_report()
diff --git a/setup.cfg b/setup.cfg
index 8ac68c4..1b4a751 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -49,3 +49,4 @@ xtesting.testcase =
basic_cnf = onaptests.scenario.basic_cnf:BasicCnf
basic_cds = onaptests.scenario.cds_blueprint_enrichment:CDSBlueprintEnrichment
clearwater_ims = onaptests.scenario.clearwater_ims:ClearwaterIms
+ basic_onboard = onaptests.scenario.basic_onboard:BasicOnboard \ No newline at end of file
diff --git a/src/onaptests/configuration/basic_onboard_settings.py b/src/onaptests/configuration/basic_onboard_settings.py
new file mode 100644
index 0000000..db7680d
--- /dev/null
+++ b/src/onaptests/configuration/basic_onboard_settings.py
@@ -0,0 +1,68 @@
+
+import sys
+import random
+import string
+from yaml import load
+from jinja2 import Environment, PackageLoader
+import onaptests.utils.exceptions as onap_test_exceptions
+from .settings import * # pylint: disable=W0614
+
+""" Creation of service to onboard"""
+
+# We need to create a service file with a random service name,
+# to be sure that we force onboarding
+def generate_service_config_yaml_file():
+ """ generate the service file with a random service name
+ from a jinja template"""
+
+ env = Environment(
+ loader=PackageLoader('onaptests', 'templates/vnf-services'),
+ )
+ template = env.get_template('basic_onboard-service.yaml.j2')
+
+ # get a random string to randomize the vnf name
+ # Random string with the combination of lower and upper case
+ letters = string.ascii_letters
+ result_str = ''.join(random.choice(letters) for i in range(6))
+ service_name = 'basic_onboard_' + result_str
+
+ rendered_template = template.render(service_name=service_name)
+
+ file_name = (sys.path[-1] + "/onaptests/templates/vnf-services/" +
+ "basic-onboard-service.yaml")
+
+ with open(file_name, 'w+') as file_to_write:
+ file_to_write.write(rendered_template)
+
+"""Basic onboard service to only onboard a service in SDC"""
+
+# pylint: disable=bad-whitespace
+# The ONAP part
+SERVICE_DETAILS="Onboarding of an Ubuntu VM"
+SERVICE_COMPONENTS="SDC"
+
+#USE_MULTICLOUD = False
+# Set ONLY_INSTANTIATE to true to run an instantiation without repeating
+# onboarding and related AAI configuration (Cloud config)
+#ONLY_INSTANTIATE= False
+
+# if a yaml file is define, retrieve info from this yaml files
+# if not declare the parameters in the settings
+generate_service_config_yaml_file()
+SERVICE_YAML_TEMPLATE = (sys.path[-1] + "/onaptests/templates/vnf-services/" +
+ "basic-onboard-service.yaml")
+
+try:
+ # Try to retrieve the SERVICE NAME from the yaml file
+ with open(SERVICE_YAML_TEMPLATE, "r") as yaml_template:
+ yaml_config_file = load(yaml_template)
+ SERVICE_NAME = next(iter(yaml_config_file.keys()))
+except (FileNotFoundError, ValueError):
+ raise onap_test_exceptions.TestConfigurationException
+
+#CLEANUP_FLAG = True
+#CLEANUP_ACTIVITY_TIMER = 10 # nb of seconds before cleanup in case cleanup option is set
+VENDOR_NAME = "basic_onboard_vendor"
+
+VF_NAME = "basic_onboard_vf"
+VSP_NAME = "basic_onboard_vsp"
diff --git a/src/onaptests/configuration/settings.py b/src/onaptests/configuration/settings.py
index a2a4b4a..ba4e163 100644
--- a/src/onaptests/configuration/settings.py
+++ b/src/onaptests/configuration/settings.py
@@ -43,4 +43,4 @@ REPORTING_FILE_PATH = "/tmp/reporting.html"
K8S_REGION_TYPE = "k8s"
K8S_CONFIG = None # None means it will use default config (~/.kube/config)
K8S_NAMESPACE = "onap" # Kubernetes namespace
-# SOCK_HTTP = "socks5h://127.0.0.1:8083"
+#SOCK_HTTP = "socks5h://127.0.0.1:8091"
diff --git a/src/onaptests/scenario/basic_onboard.py b/src/onaptests/scenario/basic_onboard.py
new file mode 100644
index 0000000..3695975
--- /dev/null
+++ b/src/onaptests/scenario/basic_onboard.py
@@ -0,0 +1,43 @@
+
+#!/usr/bin/env python
+"""Basic Onboard test case."""
+import logging
+import time
+from xtesting.core import testcase
+#from onapsdk.configuration import settings
+import onaptests.utils.exceptions as onap_test_exceptions
+#from onaptests.steps.onboard.service import YamlTemplateServiceOnboardStep
+
+class BasicOnboard(testcase.TestCase):
+ """Onboard a simple VM with ONAP."""
+
+ __logger = logging.getLogger(__name__)
+
+ def __init__(self, **kwargs):
+ """Init BasicOnboard."""
+ # import basic_onboard_settings needed
+ if "case_name" not in kwargs:
+ kwargs["case_name"] = 'basic_onboard'
+ super(BasicOnboard, self).__init__(**kwargs)
+ self.__logger.debug("BasicOnboard init started")
+ self.start_time = None
+ self.stop_time = None
+ self.result = 0
+
+ def run(self):
+ """Run basic_onboard and onboard a simple service"""
+ self.start_time = time.time()
+ self.__logger.debug("start time")
+ try:
+ self.test.execute()
+ self.__logger.info("VNF basic_vm successfully onboarded")
+ except onap_test_exceptions.OnapTestException as exc:
+ self.result = 0
+ self.__logger.error(exc.error_message)
+ finally:
+ self.stop_time = time.time()
+
+ def clean(self):
+ """Clean Additional resources if needed."""
+ self.__logger.info("Generate Test report")
+ self.test.reports_collection.generate_report()
diff --git a/src/onaptests/templates/vnf-services/basic_onboard-service.yaml.j2 b/src/onaptests/templates/vnf-services/basic_onboard-service.yaml.j2
new file mode 100644
index 0000000..c45745e
--- /dev/null
+++ b/src/onaptests/templates/vnf-services/basic_onboard-service.yaml.j2
@@ -0,0 +1,39 @@
+---
+{{ service_name }}:
+ vnfs:
+ - vnf_name: {{ service_name }}
+ heat_files_to_upload: onaptests/templates/heat-files/ubuntu18/ubuntu18agent.zip
+ vnf_parameters: [
+ {"name": "ubuntu18_image_name",
+ "value": "ubuntu-agent"
+ },
+ {"name": "ubuntu18_key_name",
+ "value": "cleouverte"
+ },
+ {"name": "ubuntu18_pub_key",
+ "value": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAA\
+BAQDY15cdBmIs2XOpe4EiFCsaY6bmUmK/GysMoLl4UG51JCfJwvwoWCoA+6mDIbymZxhxq9IGx\
+ilp/yTA6WQ9s/5pBag1cUMJmFuda9PjOkXl04jgqh5tR6I+GZ97AvCg93KAECis5ubSqw1xOCj4\
+utfEUtPoF1OuzqM/lE5mY4N6VKXn+fT7pCD6cifBEs6JHhVNvs5OLLp/tO8Pa3kKYQOdyS0xc3r\
+h+t2lrzvKUSWGZbX+dLiFiEpjsUL3tDqzkEMNUn4pdv69OJuzWHCxRWPfdrY9Wg0j3mJesP29EBh\
+t+w+EC9/kBKq+1VKdmsXUXAcjEvjovVL8l1BrX3BY0R8D imported-openssh-key"
+ },
+ {"name": "ubuntu18_flavor_name",
+ "value": "onap.small"
+ },
+ {"name": "VM_name",
+ "value": "ubuntu18agent-VM-01"
+ },
+ {"name": "vnf_id",
+ "value": "ubuntu18agent-VNF-instance"
+ },
+ {"name": "vf_module_id",
+ "value": "ubuntu18agent-vfmodule-instance"
+ },
+ {"name": "vnf_name",
+ "value": "ubuntu18agent-VNF"
+ },
+ {"name": "admin_plane_net_name",
+ "value": "admin"
+ }
+ ]