1 """Specific settings module."""
11 from jinja2 import Environment, PackageLoader
13 # Variables to set logger information
14 # Possible values for logging levels in onapsdk: INFO, DEBUG , WARNING, ERROR
17 "disable_existing_loggers": False,
20 "class": "logging.Formatter",
21 "format": "%(asctime)s %(levelname)s %(lineno)d:%(filename)s(%(process)d) - %(message)s"
27 "class": "logging.StreamHandler",
28 "formatter": "default"
32 "class": "logging.FileHandler",
33 "formatter": "default",
34 "filename": "/tmp/pythonsdk.debug.log",
40 "handlers": ["console", "file"]
44 CLEANUP_ACTIVITY_TIMER = 5
47 REPORTING_FILE_DIRECTORY = "/tmp/"
48 HTML_REPORTING_FILE_NAME = "reporting.html"
49 JSON_REPORTING_FILE_NAME = "reporting.json"
50 K8S_REGION_TYPE = "k8s"
51 TILLER_HOST = "localhost"
52 K8S_CONFIG = None # None means it will use default config (~/.kube/config)
53 K8S_ONAP_NAMESPACE = "onap" # ONAP Kubernetes namespace
54 K8S_ADDITIONAL_RESOURCES_NAMESPACE = K8S_ONAP_NAMESPACE # Resources created on tests namespace
55 MSB_K8S_OVERRIDE_VALUES = None
56 # SOCK_HTTP = "socks5h://127.0.0.1:8091"
58 ORCHESTRATION_REQUEST_TIMEOUT = 60.0 * 15 # 15 minutes in seconds
59 SERVICE_DISTRIBUTION_NUMBER_OF_TRIES = 30
60 SERVICE_DISTRIBUTION_SLEEP_TIME = 60
61 EXPOSE_SERVICES_NODE_PORTS = True
64 VES_BASIC_AUTH = {'username': 'sample1', 'password': 'sample1'}
66 SDNC_SECRET_NAME = "onap-sdnc-db-secret"
67 SDNC_DB_PRIMARY_HOST = "sdnc-db.onap.svc.cluster.local"
71 # We need to create a service file with a random service name,
72 # to be sure that we force onboarding
73 def generate_service_config_yaml_file(service_name: str,
74 service_template: str,
76 generate_random_names: bool = False):
77 """Generate service config YAML file.
79 Service configurations (both models and instances) are stored in YAML files
80 mostly generated by filling Jinja templates with service names. For most
81 cases we are generate the same configuration for all runs
82 (so generate_random_names is set to False, as default) but it is possible to
83 create all resources on each test execution.
86 service_name (str): Name of the service
87 service_template (str): Template which would be used to generate configuration
88 service_config (str): Configuration output file path
89 generate_random_names (bool, optional): Flag indicating whether service name
90 should have a random suffix or not. Defaults to False.
95 loader=PackageLoader('onaptests', 'templates/vnf-services'),
97 template = env.get_template(service_template)
99 if generate_random_names:
100 # get a random string to randomize the vnf name
101 # Random string with the combination of lower and upper case
102 letters = string.ascii_letters
103 result_str = ''.join(random.choice(letters) for i in range(6))
104 service_name = f"{service_name}_{result_str}"
106 rendered_template = template.render(service_name=service_name)
108 with open(service_config, 'w+', encoding="utf-8") as file_to_write:
109 file_to_write.write(rendered_template)