aboutsummaryrefslogtreecommitdiffstats
path: root/src/onaptests/configuration
diff options
context:
space:
mode:
Diffstat (limited to 'src/onaptests/configuration')
-rw-r--r--src/onaptests/configuration/basic_clamp_settings.py53
-rw-r--r--src/onaptests/configuration/basic_cnf_macro_settings.py3
-rw-r--r--src/onaptests/configuration/basic_onboard_settings.py38
-rw-r--r--src/onaptests/configuration/basic_vm_macro_settings.py26
-rw-r--r--src/onaptests/configuration/basic_vm_settings.py3
-rw-r--r--src/onaptests/configuration/multi_vnf_ubuntu_settings.py28
-rw-r--r--src/onaptests/configuration/pnf_macro_settings.py3
-rw-r--r--src/onaptests/configuration/settings.py44
8 files changed, 80 insertions, 118 deletions
diff --git a/src/onaptests/configuration/basic_clamp_settings.py b/src/onaptests/configuration/basic_clamp_settings.py
deleted file mode 100644
index 1277f5f..0000000
--- a/src/onaptests/configuration/basic_clamp_settings.py
+++ /dev/null
@@ -1,53 +0,0 @@
-from yaml import SafeLoader, load
-
-from onaptests.utils.resources import get_resource_location
-
-from .settings import * # noqa
-
-CLEANUP_FLAG = False
-CLAMP_DISTRIBUTION_TIMER = 10
-
-# The ONAP part
-SERVICE_DETAILS = ("Onboarding, enriching a model with TCA." +
- "Design a loop with Clamp and deploy it in Policy and DCAE")
-
-VENDOR_NAME = "basiclamp_vendor"
-
-VSP_NAME = "basiclamp_vsp"
-
-OPERATIONAL_POLICIES = [
- {
- "name": "MinMax",
- "policy_type": "onap.policies.controlloop.guard.common.MinMax",
- "policy_version": "1.0.0",
- "config_function": "add_minmax_config", # func
- "configuration": {
- "min": 1,
- "max": 10
- }
- },
- {
- "name": "FrequencyLimiter",
- "policy_type": "onap.policies.controlloop.guard.common.FrequencyLimiter",
- "policy_version": "1.0.0",
- "config_function": "add_frequency_limiter", # func
- "configuration": {}
- }
-]
-
-# if a yaml file is define, retrieve info from this yaml files
-# if not declare the parameters in the settings
-SERVICE_YAML_TEMPLATE = get_resource_location("templates/vnf-services/basic_clamp-service.yaml")
-CONFIGURATION_PATH = get_resource_location("configuration/")
-
-try:
- # Try to retrieve the SERVICE NAME from the yaml file
- with open(SERVICE_YAML_TEMPLATE, "r", encoding="utf-8") as yaml_template:
- yaml_config_file = load(yaml_template, SafeLoader)
- SERVICE_NAME = next(iter(yaml_config_file.keys()))
- VF_NAME = SERVICE_NAME
-except ValueError:
- SERVICE_NAME = "" # Fill me
- VF_NAME = "" # Fill me
-
-MODEL_YAML_TEMPLATE = None
diff --git a/src/onaptests/configuration/basic_cnf_macro_settings.py b/src/onaptests/configuration/basic_cnf_macro_settings.py
index a55267c..d52f8bb 100644
--- a/src/onaptests/configuration/basic_cnf_macro_settings.py
+++ b/src/onaptests/configuration/basic_cnf_macro_settings.py
@@ -66,6 +66,9 @@ TENANT_NAME = 'dummy_test'
SERVICE_YAML_TEMPLATE = Path(get_resource_location(
"templates/vnf-services/basic_cnf_macro-service.yaml"))
+generate_service_config_yaml_file(service_name="basic_cnf_macro", # noqa
+ service_template="basic_cnf_macro-service.yaml.j2",
+ service_config=SERVICE_YAML_TEMPLATE)
try:
# Try to retrieve the SERVICE NAME from the yaml file
diff --git a/src/onaptests/configuration/basic_onboard_settings.py b/src/onaptests/configuration/basic_onboard_settings.py
index e16bf31..73bc0e4 100644
--- a/src/onaptests/configuration/basic_onboard_settings.py
+++ b/src/onaptests/configuration/basic_onboard_settings.py
@@ -1,8 +1,5 @@
-import random
-import string
-from jinja2 import Environment, PackageLoader
from yaml import SafeLoader, load
import onaptests.utils.exceptions as onap_test_exceptions
@@ -11,29 +8,6 @@ from onaptests.utils.resources import get_resource_location
from .settings import * # noqa
-# 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)
-
- with open(SERVICE_YAML_TEMPLATE, 'w+', encoding="utf-8") as file_to_write:
- file_to_write.write(rendered_template)
-
-
# The ONAP part
SERVICE_DETAILS = "Basic onboard service to only onboard a service in SDC"
@@ -45,8 +19,15 @@ SERVICE_DETAILS = "Basic onboard service to only onboard a service in SDC"
# if a yaml file is define, retrieve info from this yaml files
# if not declare the parameters in the settings
+MODEL_YAML_TEMPLATE = None
+CLEANUP_FLAG = True
+SDC_CLEANUP = True
+
SERVICE_YAML_TEMPLATE = get_resource_location("templates/vnf-services/basic-onboard-service.yaml")
-generate_service_config_yaml_file()
+generate_service_config_yaml_file(service_name="basic_onboard", # noqa
+ service_template="basic_onboard-service.yaml.j2",
+ service_config=SERVICE_YAML_TEMPLATE,
+ generate_random_names=SDC_CLEANUP)
try:
# Try to retrieve the SERVICE NAME from the yaml file
@@ -59,6 +40,3 @@ except (FileNotFoundError, ValueError) as exc:
# CLEANUP_FLAG = True
# CLEANUP_ACTIVITY_TIMER = 10 # nb of seconds before cleanup in case cleanup option is set
VENDOR_NAME = "basic_onboard_vendor"
-
-MODEL_YAML_TEMPLATE = None
-CLEANUP_FLAG = True
diff --git a/src/onaptests/configuration/basic_vm_macro_settings.py b/src/onaptests/configuration/basic_vm_macro_settings.py
index ce1a607..8c1b927 100644
--- a/src/onaptests/configuration/basic_vm_macro_settings.py
+++ b/src/onaptests/configuration/basic_vm_macro_settings.py
@@ -1,15 +1,12 @@
-import os
from pathlib import Path
from uuid import uuid4
-import openstack
from yaml import SafeLoader, load
import onaptests.utils.exceptions as onap_test_exceptions
from onaptests.utils.resources import get_resource_location
from .settings import * # noqa
-from .settings import IF_VALIDATION
SERVICE_DETAILS = "Onboarding, distribution and instanitation of an Ubuntu VM using macro"
@@ -36,16 +33,16 @@ COMPLEX_DATA_CENTER_CODE = "1234-5"
GLOBAL_CUSTOMER_ID = "basicvm-customer"
-if not IF_VALIDATION:
- TEST_CLOUD = os.getenv('OS_TEST_CLOUD')
- cloud = openstack.connect(cloud=TEST_CLOUD)
- VIM_USERNAME = cloud.config.auth.get('username', 'Fill me')
- VIM_PASSWORD = cloud.config.auth.get('password', 'Fill me')
- VIM_SERVICE_URL = cloud.config.auth.get('auth_url', 'Fill me')
- TENANT_ID = cloud.config.auth.get('project_id', 'Fill me')
- TENANT_NAME = cloud.config.auth.get('project_name', 'Fill me')
- CLOUD_REGION_ID = cloud.config.auth.get('region_name', 'RegionOne')
- CLOUD_DOMAIN = cloud.config.auth.get('project_domain_name', 'Default')
+# if not IF_VALIDATION:
+# TEST_CLOUD = os.getenv('OS_TEST_CLOUD')
+# cloud = openstack.connect(cloud=TEST_CLOUD)
+# VIM_USERNAME = cloud.config.auth.get('username', 'Fill me')
+# VIM_PASSWORD = cloud.config.auth.get('password', 'Fill me')
+# VIM_SERVICE_URL = cloud.config.auth.get('auth_url', 'Fill me')
+# TENANT_ID = cloud.config.auth.get('project_id', 'Fill me')
+# TENANT_NAME = cloud.config.auth.get('project_name', 'Fill me')
+# CLOUD_REGION_ID = cloud.config.auth.get('region_name', 'RegionOne')
+# CLOUD_DOMAIN = cloud.config.auth.get('project_domain_name', 'Default')
OWNING_ENTITY = "basicvm-oe"
PROJECT = "basicvm-project"
@@ -54,6 +51,9 @@ PLATFORM = "basicvm-platform"
CLOUD_DOMAIN = "Default"
SERVICE_YAML_TEMPLATE = Path(get_resource_location(
"templates/vnf-services/basic_vm_macro-service.yaml"))
+generate_service_config_yaml_file(service_name="basic_vm_macro", # noqa
+ service_template="basic_vm_macro-service.yaml.j2",
+ service_config=SERVICE_YAML_TEMPLATE)
try:
# Try to retrieve the SERVICE NAME from the yaml file
diff --git a/src/onaptests/configuration/basic_vm_settings.py b/src/onaptests/configuration/basic_vm_settings.py
index 41a1dc4..00c03af 100644
--- a/src/onaptests/configuration/basic_vm_settings.py
+++ b/src/onaptests/configuration/basic_vm_settings.py
@@ -20,6 +20,9 @@ ONLY_INSTANTIATE = False
# if a yaml file is define, retrieve info from this yaml files
# if not declare the parameters in the settings
SERVICE_YAML_TEMPLATE = get_resource_location("templates/vnf-services/basic_vm-service.yaml")
+generate_service_config_yaml_file(service_name="basic_vm", # noqa
+ service_template="basic_vm-service.yaml.j2",
+ service_config=SERVICE_YAML_TEMPLATE)
try:
# Try to retrieve the SERVICE NAME from the yaml file
diff --git a/src/onaptests/configuration/multi_vnf_ubuntu_settings.py b/src/onaptests/configuration/multi_vnf_ubuntu_settings.py
index bdf6576..78b6a1b 100644
--- a/src/onaptests/configuration/multi_vnf_ubuntu_settings.py
+++ b/src/onaptests/configuration/multi_vnf_ubuntu_settings.py
@@ -3,7 +3,6 @@ import uuid
from pathlib import Path
import openstack
-from jinja2 import Environment, PackageLoader
from onaptests.utils.resources import get_resource_location
@@ -15,25 +14,6 @@ SERVICE_NAME = f"multivnfubuntu{str(uuid.uuid4().hex)[:6]}"
SERVICE_DETAILS = "Onboarding, distribution and instanitation of an Mutli VM service using macro"
-# 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(filename):
- """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(f"{filename}.yaml.j2")
-
- rendered_template = template.render(service_name=SERVICE_NAME)
-
- file_name = get_resource_location(f"templates/vnf-services/{filename}.yaml")
-
- with open(file_name, 'w+', encoding="utf-8") as file_to_write:
- file_to_write.write(rendered_template)
-
-
CLEANUP_FLAG = True
CDS_DD_FILE = Path(get_resource_location("templates/artifacts/dd_nso_ubuntu.json"))
@@ -81,7 +61,11 @@ MODEL_YAML_TEMPLATE = Path(get_resource_location("templates/vnf-services/" +
f"{VNF_FILENAME_PREFIX}-model.yaml"))
-generate_service_config_yaml_file(f"{VNF_FILENAME_PREFIX}-service")
-generate_service_config_yaml_file(f"{VNF_FILENAME_PREFIX}-model")
+generate_service_config_yaml_file(f"{VNF_FILENAME_PREFIX}-service", # noqa
+ f"{VNF_FILENAME_PREFIX}-service.yaml.j2",
+ str(SERVICE_YAML_TEMPLATE))
+generate_service_config_yaml_file(f"{VNF_FILENAME_PREFIX}-model", # noqa
+ f"{VNF_FILENAME_PREFIX}-model.yaml.j2",
+ str(MODEL_YAML_TEMPLATE))
SERVICE_INSTANCE_NAME = f"{SERVICE_NAME}_svc"
diff --git a/src/onaptests/configuration/pnf_macro_settings.py b/src/onaptests/configuration/pnf_macro_settings.py
index 877b569..e568ec3 100644
--- a/src/onaptests/configuration/pnf_macro_settings.py
+++ b/src/onaptests/configuration/pnf_macro_settings.py
@@ -14,6 +14,9 @@ SERVICE_NAME = "test_pnf_macro"
SERVICE_DETAILS = "Onboarding, distribution and registration of PNF using macro"
SERVICE_INSTANCE_NAME = "TestPNFMacroInstantiation"
SERVICE_YAML_TEMPLATE = Path(get_resource_location("templates/vnf-services/pnf-service.yaml"))
+generate_service_config_yaml_file(service_name="pnf_macro", # noqa
+ service_template="pnf-service.yaml.j2",
+ service_config=SERVICE_YAML_TEMPLATE)
CDS_DD_FILE = Path(get_resource_location("templates/artifacts/dd.json"))
CDS_CBA_UNENRICHED = Path(get_resource_location("templates/artifacts/PNF_DEMO.zip"))
diff --git a/src/onaptests/configuration/settings.py b/src/onaptests/configuration/settings.py
index 399f3f7..5feffac 100644
--- a/src/onaptests/configuration/settings.py
+++ b/src/onaptests/configuration/settings.py
@@ -6,6 +6,9 @@
# #
######################
+import random
+import string
+from jinja2 import Environment, PackageLoader
# Variables to set logger information
# Possible values for logging levels in onapsdk: INFO, DEBUG , WARNING, ERROR
@@ -60,3 +63,44 @@ CDS_NODE_PORT = 30449
IN_CLUSTER = False
VES_BASIC_AUTH = {'username': 'sample1', 'password': 'sample1'}
IF_VALIDATION = False
+
+
+# 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(service_name: str,
+ service_template: str,
+ service_config: str,
+ generate_random_names: bool = False):
+ """Generate service config YAML file.
+
+ Service configurations (both models and instances) are stored in YAML files
+ mostly generated by filling Jinja templates with service names. For most
+ cases we are generate the same configuration for all runs
+ (so generate_random_names is set to False, as default) but it is possible to
+ create all resources on each test execution.
+
+ Args:
+ service_name (str): Name of the service
+ service_template (str): Template which would be used to generate configuration
+ service_config (str): Configuration output file path
+ generate_random_names (bool, optional): Flag indicating whether service name
+ should have a random suffix or not. Defaults to False.
+
+ """
+
+ env = Environment(
+ loader=PackageLoader('onaptests', 'templates/vnf-services'),
+ )
+ template = env.get_template(service_template)
+
+ if generate_random_names:
+ # 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 = f"{service_name}_{result_str}"
+
+ rendered_template = template.render(service_name=service_name)
+
+ with open(service_config, 'w+', encoding="utf-8") as file_to_write:
+ file_to_write.write(rendered_template)