From 4def3379f3513aa92b6df2f23551082ba7aa6ad4 Mon Sep 17 00:00:00 2001 From: xudan Date: Fri, 21 Oct 2016 08:03:43 +0000 Subject: dovetail tool: Add cli mechanism for changing envs at run-time JIRA: DOVETAIL-23 1. Add file cmd_config.yml for defining arguments and options. 2. Using python click module to add and parse cmds in cmd_config.yml 3. Using envs options to update envs in yardstick/functest config file Change-Id: Ie513c0f0a1ed76f29408419a4bcbbcf21334bb3f Signed-off-by: xudan --- dovetail/container.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'dovetail/container.py') diff --git a/dovetail/container.py b/dovetail/container.py index 6ff3980d..6d7ac94d 100644 --- a/dovetail/container.py +++ b/dovetail/container.py @@ -7,7 +7,7 @@ # http://www.apache.org/licenses/LICENSE-2.0 # -import os + import utils.dovetail_logger as dt_logger import utils.dovetail_utils as dt_utils from conf.dovetail_config import dovetail_config @@ -39,18 +39,12 @@ class Container: # sshkey="-v /root/.ssh/id_rsa:/root/.ssh/id_rsa " docker_image = cls.get_docker_image(type) envs = dovetail_config[type]['envs'] - import re - for i in ['INSTALLER_TYPE', 'DEPLOY_SCENARIO', - 'DEPLOY_TYPE', 'CI_DEBUG']: - envs = re.sub("%s=(\w+)" % i, '%s=%s' % (i, os.getenv(i)), envs) - envs = re.sub("INSTALLER_IP=\d+\.?\d+\.?\d+\.?\d+", - 'INSTALLER_IP=' + os.getenv('INSTALLER_IP'), envs) opts = dovetail_config[type]['opts'] sshkey = '' result_volume = ' -v %s:%s ' % (dovetail_config['result_dir'], dovetail_config[type]['result']['dir']) cmd = 'sudo docker run %s %s %s %s %s /bin/bash' % \ - (opts, envs, sshkey, result_volume, docker_image) + (opts, envs, sshkey, result_volume, docker_image) dt_utils.exec_cmd(cmd, logger) ret, container_id = \ dt_utils.exec_cmd("sudo docker ps | grep " + docker_image + -- cgit 1.2.3-korg