diff options
author | chenjiankun <chenjiankun1@huawei.com> | 2017-02-21 07:26:51 +0000 |
---|---|---|
committer | chenjiankun <chenjiankun1@huawei.com> | 2017-02-22 01:32:33 +0000 |
commit | eaabfd1623008b2a16fcf1c2ade1e120e2fe3a0f (patch) | |
tree | 56ed2833b0842e6fe0e96d95dfc594ab6d68dc5f /api/resources | |
parent | a207ca9c170ce6cfd1c1cb198170ac7c93307d64 (diff) |
Create Grafana dashboards according config file under root_path/dashboard
JIRA: YARDSTICK-570
Currently we only create ping Grafana dashboard when create Grafana
docker container.
Actually we need to create some default dashboards.
Change-Id: Icee975ad8c1c960b27625274c775f1716edfa03e
Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
Diffstat (limited to 'api/resources')
-rw-r--r-- | api/resources/env_action.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/api/resources/env_action.py b/api/resources/env_action.py index 917681c37..2d3496cbc 100644 --- a/api/resources/env_action.py +++ b/api/resources/env_action.py @@ -9,15 +9,16 @@ from __future__ import absolute_import import errno -import json import logging import os import subprocess import threading import time import uuid +import glob from six.moves import configparser +from oslo_serialization import jsonutils from api import conf as api_conf from api.database.handler import AsyncTaskHandler @@ -67,9 +68,13 @@ def _create_grafana(task_id): def _create_dashboard(): url = 'http://admin:admin@%s:3000/api/dashboards/db' % api_conf.GATEWAY_IP - with open('../dashboard/ping_dashboard.json') as dashboard_json: - data = json.load(dashboard_json) - HttpClient().post(url, data) + path = os.path.join(config.YARDSTICK_REPOS_DIR, 'dashboard', + '*dashboard.json') + + for i in sorted(glob.iglob(path)): + with open(i) as f: + data = jsonutils.load(f) + HttpClient().post(url, data) def _create_data_source(): |