diff options
Diffstat (limited to 'api/resources')
-rw-r--r-- | api/resources/env_action.py | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/api/resources/env_action.py b/api/resources/env_action.py index fa0f95d90..59a1692a1 100644 --- a/api/resources/env_action.py +++ b/api/resources/env_action.py @@ -13,6 +13,7 @@ import time import json import os import errno +import ConfigParser from docker import Client @@ -104,7 +105,7 @@ def _create_influxdb(): client = Client(base_url=config.DOCKER_URL) try: - _config_output_file() + _change_output_to_influxdb() if not _check_image_exist(client, '%s:%s' % (config.INFLUXDB_IMAGE, config.INFLUXDB_TAG)): @@ -144,29 +145,18 @@ def _config_influxdb(): logger.debug('Failed to config influxDB: %s', e) -def _config_output_file(): +def _change_output_to_influxdb(): yardstick_utils.makedirs(config.YARDSTICK_CONFIG_DIR) - with open(config.YARDSTICK_CONFIG_FILE, 'w') as f: - f.write("""\ -[DEFAULT] -debug = False -dispatcher = influxdb -[dispatcher_file] -file_path = /tmp/yardstick.out + parser = ConfigParser.ConfigParser() + parser.read(config.YARDSTICK_CONFIG_SAMPLE_FILE) -[dispatcher_http] -timeout = 5 -# target = http://127.0.0.1:8000/results + parser.set('DEFAULT', 'dispatcher', 'influxdb') + parser.set('dispatcher_influxdb', 'target', + 'http://%s:8086' % api_conf.GATEWAY_IP) -[dispatcher_influxdb] -timeout = 5 -target = http://%s:8086 -db_name = yardstick -username = root -password = root -""" - % api_conf.GATEWAY_IP) + with open(config.YARDSTICK_CONFIG_FILE, 'w') as f: + parser.write(f) def prepareYardstickEnv(args): @@ -195,6 +185,8 @@ def _prepare_env_daemon(): # update the external_network _source_file(rc_file) + _clean_images() + _load_images() @@ -251,6 +243,14 @@ def _append_external_network(rc_file): raise +def _clean_images(): + cmd = [config.CLEAN_IMAGES_SCRIPT] + p = subprocess.Popen(cmd, stdout=subprocess.PIPE, + cwd=config.YARDSTICK_REPOS_DIR) + output = p.communicate()[0] + logger.debug('The result is: %s', output) + + def _load_images(): cmd = [config.LOAD_IMAGES_SCRIPT] p = subprocess.Popen(cmd, stdout=subprocess.PIPE, |