diff options
author | 2017-09-15 03:17:50 +0000 | |
---|---|---|
committer | 2017-09-30 01:23:07 -0700 | |
commit | f87516f78e4ca82b881ceaa8d8a38e53d8021241 (patch) | |
tree | 9f09ebfd6d2104ca6c3eed33e31ebb1bacb1dae6 /api/resources/v1 | |
parent | e96d94fa70ddefd2f6b8709b14413b7a340e543b (diff) |
Read user & password from yardstick.conf in Grafana configuration
JIRA: YARDSTICK-812
Currently grafana data source configuration is hardcoding .
It is a risk.
so I read it from yardstick.conf.
Change-Id: I8a9c8afbce6c4534fc43a0bfb5c56d67a8b59db0
Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
Diffstat (limited to 'api/resources/v1')
-rw-r--r-- | api/resources/v1/env.py | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/api/resources/v1/env.py b/api/resources/v1/env.py index 04cc659c7..7c831fd74 100644 --- a/api/resources/v1/env.py +++ b/api/resources/v1/env.py @@ -101,21 +101,15 @@ class V1Env(ApiResource): def _create_data_source(self, ip): url = 'http://admin:admin@{}:{}/api/datasources'.format(ip, consts.GRAFANA_PORT) - influx_conf = utils.parse_ini_file(consts.CONF_FILE) - - try: - influx_url = influx_conf['dispatcher_influxdb']['target'] - except KeyError: - LOG.exception('influxdb url not set in yardstick.conf') - raise + influx_conf = utils.parse_ini_file(consts.CONF_FILE).get('dispatcher_influxdb', {}) data = { "name": "yardstick", "type": "influxdb", "access": "proxy", - "url": influx_url, - "password": "root", - "user": "root", + "url": influx_conf.get('target', ''), + "password": influx_conf.get('password', ''), + "user": influx_conf.get('username', ''), "database": "yardstick", "basicAuth": True, "basicAuthUser": "admin", |