From 3e390f1d45785bca5beb1f5c2fa57ef59f6736e9 Mon Sep 17 00:00:00 2001 From: mrichomme Date: Tue, 29 Sep 2020 16:08:46 +0200 Subject: Update path management In case a yaml file is defined the zip was referenced in 2 places consider only the yaml param if the yaml file is defined Add the python path to simplify the integration in CI a,d avoid overwritting any configuration only the 2 ENV parameters + the openstack cloud + the hosts are needed to run any pythonsdk-test Issue-ID: TEST-240 Signed-off-by: mrichomme Change-Id: I57bf303b497e4d2b1dd740286f07beb3783222b1 Signed-off-by: mrichomme --- README.md | 4 ++-- .../clearwater_ims_nomulticloud_settings.py | 13 ++++++++----- .../ubuntu16_multicloud_yaml_settings.py | 3 ++- .../ubuntu16_nomulticloud_settings.py | 22 +++++++++++++--------- src/onaptests/steps/onboard/vsp.py | 8 ++++++-- .../vnf-services/clearwater-ims-service.yaml | 11 +++-------- .../vnf-services/ubuntu16test-service.yaml | 2 +- 7 files changed, 35 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 4515944..097967d 100644 --- a/README.md +++ b/README.md @@ -43,14 +43,14 @@ See ubuntu16test as example If you got the clouds.yaml, you need to reference your cloud with the env variable OS_TEST_CLOUD ```shell - export OS_TEST_CLOUD="cloud-name-referenced-in-the-cloud-configuration" + export OS_TEST_CLOUD=cloud-name-referenced-in-the-cloud-configuration ``` If you do not have access to the cloud config, you must precise all the parameters manually - Export the setting file in a environment variable ```shell - export ONAP_PYTHON_SDK_SETTINGS="onaptests.configuration.ubuntu16_multicloud_yaml_settings" + export ONAP_PYTHON_SDK_SETTINGS=onaptests.configuration.ubuntu16_multicloud_yaml_settings ``` Note each "use case" may have its own settings corresponding to the test diff --git a/src/onaptests/configuration/clearwater_ims_nomulticloud_settings.py b/src/onaptests/configuration/clearwater_ims_nomulticloud_settings.py index d640894..6130474 100644 --- a/src/onaptests/configuration/clearwater_ims_nomulticloud_settings.py +++ b/src/onaptests/configuration/clearwater_ims_nomulticloud_settings.py @@ -1,4 +1,5 @@ import os +import sys import openstack from yaml import load @@ -9,13 +10,17 @@ from .settings import * # pylint: disable=W0614 # pylint: disable=bad-whitespace # The ONAP part USE_MULTICLOUD = False -SERVICE_YAML_TEMPLATE = "templates/vnf-services/clearwater-ims-service.yaml" CLEANUP_FLAG = True CLEANUP_ACTIVITY_TIMER = 60 # nb of seconds before cleanup in case cleanup option is set VENDOR_NAME = "clearwater-ims_vendor" VF_NAME = "clearwater-ims_ubuntu_vf" VSP_NAME = "clearwater-ims_ubuntu_vsp" +# if a yaml file is define, retrieve info from this yaml files +# if not declare the parameters in the settings +SERVICE_YAML_TEMPLATE = (sys.path[-1] + "/onaptests/templates/vnf-services/" + + "clearwater-ims-service.yaml") + try: # Try to retrieve the SERVICE NAME from the yaml file with open(SERVICE_YAML_TEMPLATE, "r") as yaml_template: @@ -23,6 +28,7 @@ try: SERVICE_NAME = next(iter(yaml_config_file.keys())) except ValueError: SERVICE_NAME = "" # Fill me + VSP_FILE_PATH = "" # Fill me CLOUD_REGION_CLOUD_OWNER = "clearwater-ims-cloud-owner" CLOUD_REGION_TYPE = "openstack" @@ -40,10 +46,7 @@ PROJECT = "clearwater-ims-project" LINE_OF_BUSINESS = "clearwater-ims-lob" PLATFORM = "clearwater-ims-platform" -SERVICE_INSTANCE_NAME = "clearwater-ims_service_instance_7" - -VSP_FILE_PATH = "templates/heat_files/clearwater_ims/clearwater_ims.zip" - +SERVICE_INSTANCE_NAME = "clearwater-ims_service_instance" # The cloud Part # Assuming a cloud.yaml is available, use the openstack client diff --git a/src/onaptests/configuration/ubuntu16_multicloud_yaml_settings.py b/src/onaptests/configuration/ubuntu16_multicloud_yaml_settings.py index 6f19fc1..341dc16 100644 --- a/src/onaptests/configuration/ubuntu16_multicloud_yaml_settings.py +++ b/src/onaptests/configuration/ubuntu16_multicloud_yaml_settings.py @@ -1,3 +1,4 @@ +import sys from .settings import * # pylint: disable=W0614 """ Specific ubuntu16 with multicloud and yaml config scenario.""" @@ -35,4 +36,4 @@ PLATFORM = "sdktests_platform" SERVICE_INSTANCE_NAME = "sdktests_service_instance_name" -SERVICE_YAML_TEMPLATE = "templates/vnf-services/ubuntu16test-service.yaml" +SERVICE_YAML_TEMPLATE = sys.path[-1] + "/onaptests/templates/vnf-services/ubuntu16test-service.yaml" diff --git a/src/onaptests/configuration/ubuntu16_nomulticloud_settings.py b/src/onaptests/configuration/ubuntu16_nomulticloud_settings.py index e9f1bf6..c6c9e66 100644 --- a/src/onaptests/configuration/ubuntu16_nomulticloud_settings.py +++ b/src/onaptests/configuration/ubuntu16_nomulticloud_settings.py @@ -1,5 +1,6 @@ import os import openstack +import sys from yaml import load from .settings import * # pylint: disable=W0614 @@ -12,13 +13,12 @@ USE_MULTICLOUD = False # Set ONLY_INSTANTIATE to true to run an instantiation without repeating # onboarding and related AAI configuration (Cloud config) ONLY_INSTANTIATE= False -SERVICE_YAML_TEMPLATE = "src/onaptests/templates/vnf-services/ubuntu16test-service.yaml" -CLEANUP_FLAG = True -CLEANUP_ACTIVITY_TIMER = 10 # nb of seconds before cleanup in case cleanup option is set -VENDOR_NAME = "basicvm_vendor" -VF_NAME = "basicvm_ubuntu_vf" -VSP_NAME = "basicvm_ubuntu_vsp" +# if a yaml file is define, retrieve info from this yaml files +# if not declare the parameters in the settings +SERVICE_YAML_TEMPLATE = (sys.path[-1] + "/onaptests/templates/vnf-services/" + + "ubuntu16test-service.yaml") + try: # Try to retrieve the SERVICE NAME from the yaml file with open(SERVICE_YAML_TEMPLATE, "r") as yaml_template: @@ -27,6 +27,13 @@ try: except ValueError: SERVICE_NAME = "" # Fill me +CLEANUP_FLAG = True +CLEANUP_ACTIVITY_TIMER = 10 # nb of seconds before cleanup in case cleanup option is set +VENDOR_NAME = "basicvm_vendor" + +VF_NAME = "basicvm_ubuntu_vf" +VSP_NAME = "basicvm_ubuntu_vsp" + CLOUD_REGION_CLOUD_OWNER = "basicvm-cloud-owner" CLOUD_REGION_TYPE = "openstack" CLOUD_REGION_VERSION = "openstack" @@ -45,9 +52,6 @@ PLATFORM = "basicvm-platform" SERVICE_INSTANCE_NAME = "basicvm_ubuntu16_service_instance" -VSP_FILE_PATH = "src/onaptests/templates/templates/heat-files/ubuntu16/ubuntu16.zip" - - # The cloud Part # Assuming a cloud.yaml is available, use the openstack client # to retrieve cloud info and avoid data duplication diff --git a/src/onaptests/steps/onboard/vsp.py b/src/onaptests/steps/onboard/vsp.py index 50f1dfc..8ac47b5 100644 --- a/src/onaptests/steps/onboard/vsp.py +++ b/src/onaptests/steps/onboard/vsp.py @@ -1,3 +1,4 @@ +import sys from onapsdk.configuration import settings from onapsdk.sdc.vendor import Vendor from onapsdk.sdc.vsp import Vsp @@ -66,6 +67,9 @@ class YamlTemplateVspOnboardStep(YamlTemplateBaseStep): super().execute() vendor: Vendor = Vendor(name=settings.VENDOR_NAME) for vnf in self.yaml_template["vnfs"]: - with open(vnf["heat_files_to_upload"], "rb") as package: - vsp: Vsp = Vsp(name=f"{vnf['vnf_name']}_VSP", vendor=vendor, package=package) + with open( + sys.path[-1] + "/" + vnf["heat_files_to_upload"], "rb") as package: + vsp: Vsp = Vsp(name=f"{vnf['vnf_name']}_VSP", + vendor=vendor, + package=package) vsp.onboard() diff --git a/src/onaptests/templates/vnf-services/clearwater-ims-service.yaml b/src/onaptests/templates/vnf-services/clearwater-ims-service.yaml index 51543da..78bd4f3 100644 --- a/src/onaptests/templates/vnf-services/clearwater-ims-service.yaml +++ b/src/onaptests/templates/vnf-services/clearwater-ims-service.yaml @@ -2,10 +2,10 @@ clearwater_ims: vnfs: - vnf_name: clearwater_ims_vnf - heat_files_to_upload: templates/heat_files/clearwater_ims/clearwater_ims.zip + heat_files_to_upload: onaptests/templates/heat_files/clearwater_ims/clearwater_ims.zip vnf_parameters: [ {"name": "public_net_id", - "value": "8b0fb448-0daf-4344-a958-74852c5a0530"}, + "value": "FILL ME"}, {"name": "bono_image_name", "value": "ubuntu-16.04-daily"}, {"name": "dime_image_name", @@ -25,12 +25,7 @@ clearwater_ims: {"name": "dns_ip", "value": "8.8.8.8"}, {"name": "clearwater_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" + "value": "FILL ME" }, {"name": "clearwater_key_name", "value": "cleouverte"}] diff --git a/src/onaptests/templates/vnf-services/ubuntu16test-service.yaml b/src/onaptests/templates/vnf-services/ubuntu16test-service.yaml index a7e55e3..708991a 100644 --- a/src/onaptests/templates/vnf-services/ubuntu16test-service.yaml +++ b/src/onaptests/templates/vnf-services/ubuntu16test-service.yaml @@ -4,7 +4,7 @@ ubuntu16test: version: "1.0" vnfs: - vnf_name: ubuntu16test - heat_files_to_upload: src/onaptests/templates/heat-files/ubuntu16/ubuntu16.zip + heat_files_to_upload: onaptests/templates/heat-files/ubuntu16/ubuntu16.zip vnf_parameters: [ {"name": "ubuntu16_image_name", "value": "ubuntu-16.04-daily" -- cgit 1.2.3-korg