summaryrefslogtreecommitdiffstats
path: root/api/resources/env_action.py
diff options
context:
space:
mode:
Diffstat (limited to 'api/resources/env_action.py')
-rw-r--r--api/resources/env_action.py32
1 files changed, 22 insertions, 10 deletions
diff --git a/api/resources/env_action.py b/api/resources/env_action.py
index 917681c37..9d1686a1d 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
@@ -26,6 +27,7 @@ from api.utils.common import result_handler
from docker import Client
from yardstick.common import constants as config
from yardstick.common import utils as yardstick_utils
+from yardstick.common import openstack_utils
from yardstick.common.httpClient import HttpClient
logger = logging.getLogger(__name__)
@@ -67,9 +69,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():
@@ -189,6 +195,13 @@ def prepareYardstickEnv(args):
return result_handler('success', {'task_id': task_id})
+def _already_source_openrc():
+ """Check if openrc is sourced already"""
+ return all(os.environ.get(k) for k in ['OS_AUTH_URL', 'OS_USERNAME',
+ 'OS_PASSWORD', 'OS_TENANT_NAME',
+ 'EXTERNAL_NETWORK'])
+
+
def _prepare_env_daemon(task_id):
_create_task(task_id)
@@ -202,11 +215,10 @@ def _prepare_env_daemon(task_id):
rc_file = config.OPENSTACK_RC_FILE
- _get_remote_rc_file(rc_file, installer_ip, installer_type)
-
- _source_file(rc_file)
-
- _append_external_network(rc_file)
+ if not _already_source_openrc():
+ _get_remote_rc_file(rc_file, installer_ip, installer_type)
+ _source_file(rc_file)
+ _append_external_network(rc_file)
# update the external_network
_source_file(rc_file)
@@ -258,7 +270,7 @@ def _get_remote_rc_file(rc_file, installer_ip, installer_type):
def _append_external_network(rc_file):
- neutron_client = yardstick_utils.get_neutron_client()
+ neutron_client = openstack_utils.get_neutron_client()
networks = neutron_client.list_networks()['networks']
try:
ext_network = next(n['name'] for n in networks if n['router:external'])