1 ##############################################################################
2 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9 from __future__ import absolute_import
13 from functools import reduce
17 # this module must only import other modules that do
18 # not require loggers to be created, so this cannot
19 # include yardstick.common.utils
20 from yardstick.common.yaml_loader import yaml_load
22 dirname = os.path.dirname
23 abspath = os.path.abspath
30 def get_param(key, default=''):
32 # we have to defer this to runtime so that we can mock os.environ.get in unittests
33 conf_file = os.environ.get('CONF_FILE', '/etc/yardstick/yardstick.yaml')
35 # don't re-parse yaml for each lookup
37 # do not use yardstick.common.utils.parse_yaml
38 # since yardstick.common.utils creates a logger
39 # and so it cannot be imported before this code
41 with open(conf_file) as f:
43 except (IOError, OSError) as e:
44 if e.errno != errno.ENOENT:
49 return reduce(lambda a, b: a[b], key.split('.'), CONF)
57 SERVER_IP = get_param('api.server_ip')
60 from pyroute2 import IPDB
62 SERVER_IP = '172.17.0.1'
66 SERVER_IP = ip.routes['default'].gateway
68 # during unittests ip.routes['default'] can be invalid
69 SERVER_IP = '127.0.0.1'
72 SERVER_IP = '127.0.0.1'
76 CONF_DIR = get_param('dir.conf', '/etc/yardstick')
77 IMAGE_DIR = get_param('dir.images', '/home/opnfv/images/')
78 REPOS_DIR = get_param('dir.repos', '/home/opnfv/repos/yardstick')
79 RELENG_DIR = get_param('dir.releng', '/home/opnfv/repos/releng')
80 LOG_DIR = get_param('dir.log', '/tmp/yardstick/')
81 YARDSTICK_ROOT_PATH = dirname(
82 dirname(abspath(pkg_resources.resource_filename(__name__, "")))) + sep
83 TASK_LOG_DIR = get_param('dir.tasklog', '/var/log/yardstick/')
84 CONF_SAMPLE_DIR = join(REPOS_DIR, 'etc/yardstick/')
85 ANSIBLE_DIR = join(REPOS_DIR, 'ansible')
86 ANSIBLE_ROLES_PATH = join(REPOS_DIR, 'ansible/roles/')
87 SAMPLE_CASE_DIR = join(REPOS_DIR, 'samples')
88 TESTCASE_DIR = join(YARDSTICK_ROOT_PATH, 'tests/opnfv/test_cases/')
89 TESTSUITE_DIR = join(YARDSTICK_ROOT_PATH, 'tests/opnfv/test_suites/')
90 DOCS_DIR = join(REPOS_DIR, 'docs/testing/user/userguide/')
91 OPENSTACK_CONF_DIR = '/etc/openstack'
94 OPENRC = get_param('file.openrc', '/etc/yardstick/openstack.creds')
95 ETC_HOSTS = get_param('file.etc_hosts', '/etc/hosts')
96 CONF_FILE = join(CONF_DIR, 'yardstick.conf')
97 POD_FILE = join(CONF_DIR, 'pod.yaml')
98 CLOUDS_CONF = join(OPENSTACK_CONF_DIR, 'clouds.yml')
99 K8S_CONF_FILE = join(CONF_DIR, 'admin.conf')
100 CONF_SAMPLE_FILE = join(CONF_SAMPLE_DIR, 'yardstick.conf.sample')
101 FETCH_SCRIPT = get_param('file.fetch_script', 'utils/fetch_os_creds.sh')
102 FETCH_SCRIPT = join(RELENG_DIR, FETCH_SCRIPT)
103 CLEAN_IMAGES_SCRIPT = get_param('file.clean_image_script',
104 'tests/ci/clean_images.sh')
105 CLEAN_IMAGES_SCRIPT = join(REPOS_DIR, CLEAN_IMAGES_SCRIPT)
106 LOAD_IMAGES_SCRIPT = get_param('file.load_image_script',
107 'tests/ci/load_images.sh')
108 LOAD_IMAGES_SCRIPT = join(REPOS_DIR, LOAD_IMAGES_SCRIPT)
109 DEFAULT_OUTPUT_FILE = get_param('file.output_file', '/tmp/yardstick.out')
110 DEFAULT_HTML_FILE = get_param('file.html_file', '/tmp/yardstick.htm')
111 REPORTING_FILE = get_param('file.reporting_file', '/tmp/report.html')
114 INFLUXDB_IP = get_param('influxdb.ip', SERVER_IP)
115 INFLUXDB_PORT = get_param('influxdb.port', 8086)
116 INFLUXDB_USER = get_param('influxdb.username', 'root')
117 INFLUXDB_PASS = get_param('influxdb.password', 'root')
118 INFLUXDB_DB_NAME = get_param('influxdb.db_name', 'yardstick')
119 INFLUXDB_IMAGE = get_param('influxdb.image', 'tutum/influxdb')
120 INFLUXDB_TAG = get_param('influxdb.tag', '0.13')
121 INFLUXDB_DASHBOARD_PORT = 8083
124 GRAFANA_IP = get_param('grafana.ip', SERVER_IP)
125 GRAFANA_PORT = get_param('grafana.port', 3000)
126 GRAFANA_USER = get_param('grafana.username', 'admin')
127 GRAFANA_PASS = get_param('grafana.password', 'admin')
128 GRAFANA_IMAGE = get_param('grafana.image', 'grafana/grafana')
129 GRAFANA_TAG = get_param('grafana.tag', '4.4.3')
130 GRAFANA_MAPPING_PORT = 1948
134 DOCKER_URL = 'unix://var/run/docker.sock'
135 INSTALLERS = ['apex', 'compass', 'fuel', 'joid']
136 SQLITE = 'sqlite:////tmp/yardstick.db'
144 BASE_URL = 'http://localhost:5000'
145 ENV_ACTION_API = BASE_URL + '/yardstick/env/action'
146 ASYNC_TASK_API = BASE_URL + '/yardstick/asynctask'
149 IS_EXISTING = 'is_existing'
150 IS_PUBLIC = 'is_public'
153 TESTCASE_PRE = 'opnfv_yardstick_'
154 TESTSUITE_PRE = 'opnfv_'