diff options
author | Rex Lee <limingjiang@huawei.com> | 2017-09-26 08:22:36 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-09-26 08:22:36 +0000 |
commit | cb63cb9ed232dc40ce118e1b8c001841552ff808 (patch) | |
tree | 4f252dc7dd6d95a739b9086c1329243344026f1c /api/resources | |
parent | 8eedebec3bca3dc6e588c06073b3ad367dfd36b1 (diff) | |
parent | d49de4ede216ff24085c4e58dfc1ea970390cb6f (diff) |
Merge "Read user & password from yardstick.conf in Grafana configuration"
Diffstat (limited to 'api/resources')
-rw-r--r-- | api/resources/v1/env.py | 14 | ||||
-rw-r--r-- | api/resources/v2/containers.py | 14 |
2 files changed, 8 insertions, 20 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", diff --git a/api/resources/v2/containers.py b/api/resources/v2/containers.py index 66dc94120..ee1903901 100644 --- a/api/resources/v2/containers.py +++ b/api/resources/v2/containers.py @@ -272,21 +272,15 @@ class V2Containers(ApiResource): def _create_data_source(self, ip): url = 'http://admin:admin@{}:{}/api/datasources'.format(ip, 3000) - - 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", |