From ed7f8ee3697be3751dc6cfb243cc55092ddd1dd5 Mon Sep 17 00:00:00 2001 From: xudan Date: Thu, 25 May 2017 04:35:18 -0400 Subject: Change the directories of results and some files to DOVETAIL_HOME JIRA: DOVETAIL-438 1. Need an env variable DOVETAIL_HOME in env_config.sh 2. env_config.sh, pod.yaml and id_rsa should be put in path DOVETAIL_HOME/pre_config 3. the results will also be put in this path 4. no need to give the path of openstack credential file while running a testsuite 5. if running with the code, source the env_config.sh file before running source $DOVETAIL_HOME/env_config.sh dovetail run --testsuite 6. if running with Dovetail docker image docker run -it --privileged=true -e DOVETAIL_HOME= -v : -v /var/run/docker.sock:/var/run/docker.sock opnfv/dovetail:latest /bin/bash Change-Id: Ia23078f27a34e293d0075e49c673930f41069cb6 Signed-off-by: xudan --- dovetail/run.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'dovetail/run.py') diff --git a/dovetail/run.py b/dovetail/run.py index 5b4dca8e..521379d7 100755 --- a/dovetail/run.py +++ b/dovetail/run.py @@ -181,23 +181,36 @@ def clean_results_dir(): def get_result_path(): - dovetail_home = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + try: + dovetail_home = os.environ["DOVETAIL_HOME"] + except Exception: + print("ERROR: mandatory env variable 'DOVETAIL_HOME' is not found, " + "please set in env_config.sh and source this file before " + "running.") + return None result_path = os.path.join(dovetail_home, 'results') dt_cfg.dovetail_config['result_dir'] = result_path + pre_config_path = os.path.join(dovetail_home, 'pre_config') + dt_cfg.dovetail_config['config_dir'] = pre_config_path + return dovetail_home -def get_userconfig_path(): +def copy_userconfig_files(logger): dovetail_home = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) userconfig_path = os.path.join(dovetail_home, 'userconfig') - dt_cfg.dovetail_config['userconfig_dir'] = userconfig_path + pre_config_path = dt_cfg.dovetail_config['config_dir'] + if not os.path.isdir(pre_config_path): + os.makedirs(pre_config_path) + cmd = 'sudo cp -r %s/* %s' % (userconfig_path, pre_config_path) + dt_utils.exec_cmd(cmd, logger, exit_on_error=False) def main(*args, **kwargs): """Dovetail compliance test entry!""" build_tag = "daily-master-%s" % str(uuid.uuid4()) dt_cfg.dovetail_config['build_tag'] = build_tag - get_result_path() - get_userconfig_path() + if not get_result_path(): + return clean_results_dir() if kwargs['debug']: os.environ['DEBUG'] = 'true' @@ -207,6 +220,7 @@ def main(*args, **kwargs): logger.info('Dovetail compliance: %s!', (kwargs['testsuite'])) logger.info('================================================') logger.info('Build tag: %s', dt_cfg.dovetail_config['build_tag']) + copy_userconfig_files(logger) dt_utils.check_docker_version(logger) validate_input(kwargs, dt_cfg.dovetail_config['validate_input'], logger) configs = filter_config(kwargs, logger) -- cgit 1.2.3-korg