summaryrefslogtreecommitdiffstats
path: root/vnftest/common
diff options
context:
space:
mode:
Diffstat (limited to 'vnftest/common')
-rw-r--r--vnftest/common/constants.py35
-rw-r--r--vnftest/common/html_template.py1
-rw-r--r--vnftest/common/import_utils.py38
-rw-r--r--vnftest/common/openstack_utils.py55
-rw-r--r--vnftest/common/utils.py50
5 files changed, 82 insertions, 97 deletions
diff --git a/vnftest/common/constants.py b/vnftest/common/constants.py
index 46db92c..acf14ea 100644
--- a/vnftest/common/constants.py
+++ b/vnftest/common/constants.py
@@ -83,48 +83,23 @@ if not SERVER_IP:
# dir
CONF_DIR = get_param('dir.conf', join(VNFTEST_ROOT_PATH, 'etc/vnftest'))
+IMAGE_DIR = get_param('dir.images', join(VNFTEST_ROOT_PATH, 'home/onap/images/'))
+PACKAGE_DIR = get_param('dir.packages', join(VNFTEST_ROOT_PATH, 'home/onap/packages/'))
CONF_FILE = join(CONF_DIR, 'vnftest.conf')
REPOS_DIR = get_param('dir.repos', join(VNFTEST_ROOT_PATH, 'home/onap/repos/vnftest'))
-LOG_DIR = get_param('dir.log', join(VNFTEST_ROOT_PATH, 'tmp/vnftest/'))
+LOG_DIR = get_param('dir.log', join(VNFTEST_ROOT_PATH, 'var/log/vnftest/'))
TASK_LOG_DIR = get_param('dir.tasklog', join(VNFTEST_ROOT_PATH, 'var/log/vnftest/'))
CONF_SAMPLE_DIR = join(REPOS_DIR, 'etc/vnftest/')
SAMPLE_CASE_DIR = join(REPOS_DIR, 'samples')
-TESTCASE_DIR = join(VNFTEST_ROOT_PATH, 'vnftest/test_config/onap/test_cases/')
-TESTSUITE_DIR = join(VNFTEST_ROOT_PATH, 'vnftest/test_config/onap/test_suites/')
+TESTCASE_DIR = join(REPOS_DIR, 'vnftest/test_config/onap/test_cases/')
+TESTSUITE_DIR = join(REPOS_DIR, 'vnftest/test_config/onap/test_suites/')
# file
DEFAULT_OUTPUT_FILE = get_param('file.output_file', join(VNFTEST_ROOT_PATH, 'tmp/vnftest.out'))
DEFAULT_HTML_FILE = get_param('file.html_file', join(VNFTEST_ROOT_PATH, 'tmp/vnftest.htm'))
REPORTING_FILE = get_param('file.reporting_file', join(VNFTEST_ROOT_PATH, 'tmp/report.html'))
-# components
-AAI_IP = get_param('component.aai_ip')
-AAI_PORT = get_param('component.aai_port')
-AAI_SSL_PORT = get_param('component.aai_ssl_port')
-MSO_IP = get_param('component.mso_ip')
-SDC_IP = get_param('component.sdc_ip')
-SDC_PORT = get_param('component.sdc_port')
-SDC_CATALOG_PORT = get_param('component.sdc_catalog_port')
-SDC_DESIGNER_USER = get_param('component.sdc_designer_user')
-SDC_TESTER_USER = get_param('component.sdc_tester_user')
-SDC_GOVERNANCE_USER = get_param('component.sdc_governance_user')
-SDC_OPERATIONS_USER = get_param('component.sdc_operations_user')
-
-component_constants = {}
-component_constants['aai_ip'] = AAI_IP
-component_constants['aai_port'] = AAI_PORT
-component_constants['aai_ssl_port'] = AAI_SSL_PORT
-component_constants['mso_ip'] = MSO_IP
-component_constants['sdc_ip'] = SDC_IP
-component_constants['sdc_port'] = SDC_PORT
-component_constants['sdc_catalog_port'] = SDC_CATALOG_PORT
-component_constants['sdc_designer_user'] = SDC_DESIGNER_USER
-component_constants['sdc_tester_user'] = SDC_TESTER_USER
-component_constants['sdc_governance_user'] = SDC_GOVERNANCE_USER
-component_constants['sdc_operations_user'] = SDC_OPERATIONS_USER
-
-
# api
API_PORT = 5000
DOCKER_URL = 'unix://var/run/docker.sock'
diff --git a/vnftest/common/html_template.py b/vnftest/common/html_template.py
index 572d47f..7a91781 100644
--- a/vnftest/common/html_template.py
+++ b/vnftest/common/html_template.py
@@ -184,6 +184,7 @@ report_template = """
<td>{{ loop.index }}</td>
<td>{{key}}</td>
<td>{{value.criteria}}</td>
+ <td>{{value.output}}</td>
</tr>
{% endfor %}
</tbody>
diff --git a/vnftest/common/import_utils.py b/vnftest/common/import_utils.py
new file mode 100644
index 0000000..1cff864
--- /dev/null
+++ b/vnftest/common/import_utils.py
@@ -0,0 +1,38 @@
+##############################################################################
+# Copyright 2018 EuropeanSoftwareMarketingLtd.
+# ===================================================================
+# Licensed under the ApacheLicense, Version2.0 (the"License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# software distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and limitations under
+# the License
+##############################################################################
+import importlib
+
+import os
+import sys
+import vnftest
+
+
+def import_modules_from_package(package):
+ """Import modules given a package name
+ :param: package - Full package name. For example: rally.deploy.engines
+ """
+ vnftest_root = os.path.dirname(os.path.dirname(vnftest.__file__))
+ path = os.path.join(vnftest_root, *package.split('.'))
+ for root, _, files in os.walk(path):
+ matches = (filename for filename in files if filename.endswith('.py')
+ and not filename.startswith('__'))
+ new_package = os.path.relpath(root, vnftest_root).replace(os.sep,
+ '.')
+ module_names = set(
+ '{}.{}'.format(new_package, filename.rsplit('.py', 1)[0])
+ for filename in matches)
+ # Find modules which haven't already been imported
+ missing_modules = module_names.difference(sys.modules)
+ for module_name in missing_modules:
+ importlib.import_module(module_name)
diff --git a/vnftest/common/openstack_utils.py b/vnftest/common/openstack_utils.py
index 829b916..c8842d8 100644
--- a/vnftest/common/openstack_utils.py
+++ b/vnftest/common/openstack_utils.py
@@ -40,35 +40,34 @@ creds = {}
# *********************************************
# CREDENTIALS
# *********************************************
+def initialize(openstack_env_config):
+ keystone_api_version = openstack_env_config.get('OS_IDENTITY_API_VERSION', None)
+
+ if keystone_api_version is None or keystone_api_version == '2':
+ keystone_v3 = False
+ creds['tenant_name'] = openstack_env_config['OS_TENANT_NAME']
+ else:
+ keystone_v3 = True
+ creds['tenant_name'] = openstack_env_config['OS_PROJECT_NAME']
+ creds['project_name'] = openstack_env_config['OS_PROJECT_NAME']
+
+ creds["username"] = openstack_env_config["OS_USERNAME"]
+ creds["password"] = openstack_env_config["OS_PASSWORD"]
+ creds["auth_url"] = openstack_env_config["OS_AUTH_URL"]
+ creds["tenant_id"] = openstack_env_config["OS_TENANT_ID"]
+
+ if keystone_v3:
+ if 'OS_USER_DOMAIN_NAME' in openstack_env_config:
+ creds.update({
+ "user_domain_name": openstack_env_config['OS_USER_DOMAIN_NAME']
+ })
+ if 'OS_PROJECT_DOMAIN_NAME' in openstack_env_config:
+ creds.update({
+ "project_domain_name": openstack_env_config['OS_PROJECT_DOMAIN_NAME']
+ })
+
+
def get_credentials():
- """Returns a creds dictionary filled with parsed from env"""
- if len(creds) == 0:
- # The most common way to pass these info to the script is to do it
- # through environment variables.
- keystone_api_version = os.getenv('OS_IDENTITY_API_VERSION')
-
- if keystone_api_version is None or keystone_api_version == '2':
- keystone_v3 = False
- creds['tenant_name'] = os.environ.get('OS_TENANT_NAME')
- else:
- keystone_v3 = True
- creds['tenant_name'] = os.environ.get('OS_PROJECT_NAME')
- creds['project_name'] = os.environ.get('OS_PROJECT_NAME')
-
- creds["username"] = os.environ.get("OS_USERNAME")
- creds["password"] = os.environ.get("OS_PASSWORD")
- creds["auth_url"] = os.environ.get("OS_AUTH_URL")
- creds["tenant_id"] = os.environ.get("OS_TENANT_ID")
-
- if keystone_v3:
- if os.getenv('OS_USER_DOMAIN_NAME') is not None:
- creds.update({
- "user_domain_name": os.getenv('OS_USER_DOMAIN_NAME')
- })
- if os.getenv('OS_PROJECT_DOMAIN_NAME') is not None:
- creds.update({
- "project_domain_name": os.getenv('OS_PROJECT_DOMAIN_NAME')
- })
return creds
diff --git a/vnftest/common/utils.py b/vnftest/common/utils.py
index 10edc05..9e2496e 100644
--- a/vnftest/common/utils.py
+++ b/vnftest/common/utils.py
@@ -15,11 +15,9 @@
# yardstick/common/utils.py
import collections
-import formatter
from contextlib import closing
import datetime
import errno
-import importlib
from string import Formatter
import ipaddress
@@ -28,7 +26,6 @@ import os
import random
import socket
import subprocess
-import sys
import pkg_resources
import six
@@ -36,7 +33,6 @@ from flask import jsonify
from six.moves import configparser
from oslo_serialization import jsonutils
import xml.etree.ElementTree
-import vnftest
from vnftest.common.exceptions import ResourceNotFound
@@ -74,31 +70,6 @@ def findsubclasses(cls):
return class_implementations[cls.__name__]
-def import_modules_from_package(package):
- """Import modules given a package name
-
- :param: package - Full package name. For example: rally.deploy.engines
- """
- vnftest_root = os.path.dirname(os.path.dirname(vnftest.__file__))
- path = os.path.join(vnftest_root, *package.split('.'))
- for root, _, files in os.walk(path):
- matches = (filename for filename in files if filename.endswith('.py')
- and not filename.startswith('__'))
- new_package = os.path.relpath(root, vnftest_root).replace(os.sep,
- '.')
- module_names = set(
- '{}.{}'.format(new_package, filename.rsplit('.py', 1)[0])
- for filename in matches)
- # Find modules which haven't already been imported
- missing_modules = module_names.difference(sys.modules)
- logger.debug('Importing modules: %s', missing_modules)
- for module_name in missing_modules:
- try:
- importlib.import_module(module_name)
- except (ImportError, SyntaxError):
- logger.exception('Unable to import module %s', module_name)
-
-
def makedirs(d):
try:
os.makedirs(d)
@@ -496,19 +467,20 @@ def element_tree_to_dict(element_tree):
def resource_as_string(path):
- split_path = os.path.split(path)
- package = split_path[0].replace("/", ".")
- if not pkg_resources.resource_exists(package, split_path[1]):
- raise ResourceNotFound(resource=path)
- return pkg_resources.resource_string(package, split_path[1])
+ resource = load_resource(path)
+ return resource.read()
def load_resource(path):
- split_path = os.path.split(path)
- package = split_path[0].replace("/", ".")
- if not pkg_resources.resource_exists(package, split_path[1]):
- raise ResourceNotFound(resource=path)
- return pkg_resources.resource_stream(package, split_path[1])
+ try:
+ return open(path)
+ except Exception:
+ logger.info("path not loaded as file, trying load as package")
+ split_path = os.path.split(path)
+ package = split_path[0].replace("/", ".")
+ if not pkg_resources.resource_exists(package, split_path[1]):
+ raise ResourceNotFound(resource=path)
+ return pkg_resources.resource_stream(package, split_path[1])
def format(st, params):