Merge "vnfdgen: replace yaml.load with yaml.safe_load"
[yardstick.git] / yardstick / common / constants.py
1 ##############################################################################
2 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
3 #
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
10 import os
11
12 from yardstick.common.utils import get_param
13
14
15 dirname = os.path.dirname
16 abspath = os.path.abspath
17 join = os.path.join
18 sep = os.path.sep
19
20 try:
21     SERVER_IP = get_param('api.server_ip')
22 except KeyError:
23     try:
24         from pyroute2 import IPDB
25     except ImportError:
26         SERVER_IP = '172.17.0.1'
27     else:
28         with IPDB() as ip:
29             try:
30                 SERVER_IP = ip.routes['default'].gateway
31             except KeyError:
32                 # during unittests ip.routes['default'] can be invalid
33                 SERVER_IP = '127.0.0.1'
34
35 if not SERVER_IP:
36     SERVER_IP = '127.0.0.1'
37
38
39 # dir
40 CONF_DIR = get_param('dir.conf', '/etc/yardstick')
41 REPOS_DIR = get_param('dir.repos', '/home/opnfv/repos/yardstick')
42 RELENG_DIR = get_param('dir.releng', '/home/opnfv/repos/releng')
43 LOG_DIR = get_param('dir.log', '/tmp/yardstick/')
44 YARDSTICK_ROOT_PATH = dirname(dirname(dirname(abspath(__file__)))) + sep
45 CONF_SAMPLE_DIR = join(REPOS_DIR, 'etc/yardstick/')
46 ANSIBLE_DIR = join(REPOS_DIR, 'ansible')
47 SAMPLE_CASE_DIR = join(REPOS_DIR, 'samples')
48 TESTCASE_DIR = join(YARDSTICK_ROOT_PATH, 'tests/opnfv/test_cases/')
49 TESTSUITE_DIR = join(YARDSTICK_ROOT_PATH, 'tests/opnfv/test_suites/')
50 DOCS_DIR = join(REPOS_DIR, 'docs/testing/user/userguide/')
51 OPENSTACK_CONF_DIR = '/etc/openstack'
52
53 # file
54 OPENRC = get_param('file.openrc', '/etc/yardstick/openstack.creds')
55 ETC_HOSTS = get_param('file.etc_hosts', '/etc/hosts')
56 CONF_FILE = join(CONF_DIR, 'yardstick.conf')
57 POD_FILE = join(CONF_DIR, 'pod.yaml')
58 CLOUDS_CONF = join(OPENSTACK_CONF_DIR, 'clouds.yml')
59 K8S_CONF_FILE = join(CONF_DIR, 'admin.conf')
60 CONF_SAMPLE_FILE = join(CONF_SAMPLE_DIR, 'yardstick.conf.sample')
61 FETCH_SCRIPT = get_param('file.fetch_script', 'utils/fetch_os_creds.sh')
62 FETCH_SCRIPT = join(RELENG_DIR, FETCH_SCRIPT)
63 CLEAN_IMAGES_SCRIPT = get_param('file.clean_image_script',
64                                 'tests/ci/clean_images.sh')
65 CLEAN_IMAGES_SCRIPT = join(REPOS_DIR, CLEAN_IMAGES_SCRIPT)
66 LOAD_IMAGES_SCRIPT = get_param('file.load_image_script',
67                                'tests/ci/load_images.sh')
68 LOAD_IMAGES_SCRIPT = join(REPOS_DIR, LOAD_IMAGES_SCRIPT)
69 DEFAULT_OUTPUT_FILE = get_param('file.output_file', '/tmp/yardstick.out')
70 DEFAULT_HTML_FILE = get_param('file.html_file', '/tmp/yardstick.htm')
71
72 # influxDB
73 INFLUXDB_IP = get_param('influxdb.ip', SERVER_IP)
74 INFLUXDB_PORT = get_param('influxdb.port', 8086)
75 INFLUXDB_USER = get_param('influxdb.username', 'root')
76 INFLUXDB_PASS = get_param('influxdb.password', 'root')
77 INFLUXDB_DB_NAME = get_param('influxdb.db_name', 'yardstick')
78 INFLUXDB_IMAGE = get_param('influxdb.image', 'tutum/influxdb')
79 INFLUXDB_TAG = get_param('influxdb.tag', '0.13')
80 INFLUXDB_DASHBOARD_PORT = 8083
81
82 # grafana
83 GRAFANA_IP = get_param('grafana.ip', SERVER_IP)
84 GRAFANA_PORT = get_param('grafana.port', 3000)
85 GRAFANA_USER = get_param('grafana.username', 'admin')
86 GRAFANA_PASS = get_param('grafana.password', 'admin')
87 GRAFANA_IMAGE = get_param('grafana.image', 'grafana/grafana')
88 GRAFANA_TAG = get_param('grafana.tag', '3.1.1')
89 GRAFANA_MAPPING_PORT = 1948
90
91 # api
92 API_PORT = 5000
93 DOCKER_URL = 'unix://var/run/docker.sock'
94 INSTALLERS = ['apex', 'compass', 'fuel', 'joid']
95 SQLITE = 'sqlite:////tmp/yardstick.db'
96
97 API_SUCCESS = 1
98 API_ERROR = 2
99 TASK_NOT_DONE = 0
100 TASK_DONE = 1
101 TASK_FAILED = 2
102
103 BASE_URL = 'http://localhost:5000'
104 ENV_ACTION_API = BASE_URL + '/yardstick/env/action'
105 ASYNC_TASK_API = BASE_URL + '/yardstick/asynctask'
106
107 # general
108 TESTCASE_PRE = 'opnfv_yardstick_'
109 TESTSUITE_PRE = 'opnfv_'