X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=yardstick%2Fcommon%2Fconstants.py;h=f6e4ab7e983cfca6d0d9b45fbce3093b4ed81f84;hb=c8a3679b57eafd2c7855dc82bd028308fa92f4e2;hp=822d3b4faa76fce3fe42e7a7cb32f8c783cf8193;hpb=89fe59588ec6bf7da5df53cbab61731e476912c3;p=yardstick.git diff --git a/yardstick/common/constants.py b/yardstick/common/constants.py index 822d3b4fa..f6e4ab7e9 100644 --- a/yardstick/common/constants.py +++ b/yardstick/common/constants.py @@ -7,12 +7,17 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## from __future__ import absolute_import + +import errno import os from functools import reduce import pkg_resources -from yardstick.common.utils import parse_yaml +# this module must only import other modules that do +# not require loggers to be created, so this cannot +# include yardstick.common.utils +from yardstick.common.yaml_loader import yaml_load dirname = os.path.dirname abspath = os.path.abspath @@ -29,7 +34,17 @@ def get_param(key, default=''): # don't re-parse yaml for each lookup if not CONF: - CONF.update(parse_yaml(conf_file)) + # do not use yardstick.common.utils.parse_yaml + # since yardstick.common.utils creates a logger + # and so it cannot be imported before this code + try: + with open(conf_file) as f: + value = yaml_load(f) + except (IOError, OSError) as e: + if e.errno != errno.ENOENT: + raise + else: + CONF.update(value) try: return reduce(lambda a, b: a[b], key.split('.'), CONF) except KeyError: @@ -59,13 +74,16 @@ if not SERVER_IP: # dir CONF_DIR = get_param('dir.conf', '/etc/yardstick') +IMAGE_DIR = get_param('dir.images', '/home/opnfv/images/') REPOS_DIR = get_param('dir.repos', '/home/opnfv/repos/yardstick') RELENG_DIR = get_param('dir.releng', '/home/opnfv/repos/releng') LOG_DIR = get_param('dir.log', '/tmp/yardstick/') YARDSTICK_ROOT_PATH = dirname( dirname(abspath(pkg_resources.resource_filename(__name__, "")))) + sep +TASK_LOG_DIR = get_param('dir.tasklog', '/var/log/yardstick/') CONF_SAMPLE_DIR = join(REPOS_DIR, 'etc/yardstick/') ANSIBLE_DIR = join(REPOS_DIR, 'ansible') +ANSIBLE_ROLES_PATH = join(REPOS_DIR, 'ansible/roles/') SAMPLE_CASE_DIR = join(REPOS_DIR, 'samples') TESTCASE_DIR = join(YARDSTICK_ROOT_PATH, 'tests/opnfv/test_cases/') TESTSUITE_DIR = join(YARDSTICK_ROOT_PATH, 'tests/opnfv/test_suites/') @@ -90,6 +108,7 @@ LOAD_IMAGES_SCRIPT = get_param('file.load_image_script', LOAD_IMAGES_SCRIPT = join(REPOS_DIR, LOAD_IMAGES_SCRIPT) DEFAULT_OUTPUT_FILE = get_param('file.output_file', '/tmp/yardstick.out') DEFAULT_HTML_FILE = get_param('file.html_file', '/tmp/yardstick.htm') +REPORTING_FILE = get_param('file.reporting_file', '/tmp/report.html') # influxDB INFLUXDB_IP = get_param('influxdb.ip', SERVER_IP) @@ -107,7 +126,7 @@ GRAFANA_PORT = get_param('grafana.port', 3000) GRAFANA_USER = get_param('grafana.username', 'admin') GRAFANA_PASS = get_param('grafana.password', 'admin') GRAFANA_IMAGE = get_param('grafana.image', 'grafana/grafana') -GRAFANA_TAG = get_param('grafana.tag', '3.1.1') +GRAFANA_TAG = get_param('grafana.tag', '4.4.3') GRAFANA_MAPPING_PORT = 1948 # api @@ -126,6 +145,28 @@ BASE_URL = 'http://localhost:5000' ENV_ACTION_API = BASE_URL + '/yardstick/env/action' ASYNC_TASK_API = BASE_URL + '/yardstick/asynctask' +API_ERRORS = { + 'UploadOpenrcError': { + 'message': "Upload openrc ERROR!", + 'status': API_ERROR, + }, + 'UpdateOpenrcError': { + 'message': "Update openrc ERROR!", + 'status': API_ERROR, + }, + 'ApiServerError': { + 'message': "An unkown exception happened to Api Server!", + 'status': API_ERROR, + }, +} + +# flags +IS_EXISTING = 'is_existing' +IS_PUBLIC = 'is_public' + # general TESTCASE_PRE = 'opnfv_yardstick_' TESTSUITE_PRE = 'opnfv_' + +# OpenStack cloud default config parameters +OS_CLOUD_DEFAULT_CONFIG = {'verify': False}