From 6de223dad312a4fac4a410fc4a4a21f457c06f27 Mon Sep 17 00:00:00 2001 From: SerenaFeng Date: Fri, 9 Mar 2018 18:46:27 +0800 Subject: substitute image copy with docker volume Change-Id: Ie470d03bd168c909fd02c316523049c67a6bb095 Signed-off-by: SerenaFeng --- dovetail/container.py | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) (limited to 'dovetail/container.py') diff --git a/dovetail/container.py b/dovetail/container.py index 63ce2db8..9a90a48b 100644 --- a/dovetail/container.py +++ b/dovetail/container.py @@ -202,34 +202,23 @@ class Container(object): "insecure mode...") return None + images_volume = '' + if dovetail_config[type]['config'].get('images', None): + images_volume = '-v {}:{}'.format( + dovetail_config['images_dir'], + dovetail_config[type]['config']['images']) + result_volume = ' -v %s:%s ' % (dovetail_config['result_dir'], dovetail_config[type]['result']['dir']) - cmd = 'sudo docker run %s %s %s %s %s %s %s %s %s /bin/bash' % \ - (opts, envs, config, hosts_config, openrc, cacert_volume, - config_volume, result_volume, docker_image) + cmd = 'sudo docker run {opts} {envs} {config} {hosts_config} ' \ + '{openrc} {cacert_volume} {config_volume} {result_volume} ' \ + '{images_volume} {docker_image} /bin/bash'.format(**locals()) dt_utils.exec_cmd(cmd, cls.logger) ret, container_id = \ dt_utils.exec_cmd("sudo docker ps | grep " + docker_image + " | awk '{print $1}' | head -1", cls.logger) cls.container_list[type] = container_id - if 'sdnvpn' in str(testcase_name): - prefix_path = dt_cfg.dovetail_config[type]['config']['dir'] - file_name = dt_cfg.dovetail_config['sdnvpn_image'] - src_path = os.path.join(prefix_path, 'pre_config', file_name) - dest_path = '/home/opnfv/functest/images' - Container.pre_copy(container_id, src_path, dest_path) - - if type.lower() == 'functest': - prefix_path = dt_cfg.dovetail_config[type]['config']['dir'] - images = ['cirros_image', 'ubuntu14_image', 'cloudify_image', - 'trusty_image'] - for image in images: - file_name = dt_cfg.dovetail_config[image] - src_path = os.path.join(prefix_path, 'pre_config', file_name) - dest_path = '/home/opnfv/functest/images' - Container.pre_copy(container_id, src_path, dest_path) - if type.lower() == 'yardstick': cls.set_yardstick_conf_file(container_id) -- cgit 1.2.3-korg