diff options
author | xudan2189 <xudanstudy@gmail.com> | 2016-09-21 04:40:44 -0400 |
---|---|---|
committer | xudan <xudan16@huawei.com> | 2016-09-23 03:25:07 -0400 |
commit | c554b6951f8ee8298d3f8ae8f53ba468dbf4c164 (patch) | |
tree | 1c00e69f31fcd3b04d88073700eddf1f1d620b06 /scripts/container.py | |
parent | d8ee3fd2cb9e221466e49703a25e9b7e1343be62 (diff) |
Move copyfile to container and remove hard-code
JIRA: DOVETAIL-17
Change-Id: Id4ad126169cf83c6c72a7b599f3309f0f930e461
Signed-off-by: xudan <xudan16@huawei.com>
Diffstat (limited to 'scripts/container.py')
-rw-r--r-- | scripts/container.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/scripts/container.py b/scripts/container.py index 4bbc5e5b..678a0929 100644 --- a/scripts/container.py +++ b/scripts/container.py @@ -16,6 +16,8 @@ logger = dt_logger.Logger('container.py').getLogger() class Container: container_list = {} + has_pull_latest_image = {'yardstick':False, 'functest':False} + has_build_images = {'yardstick':False, 'functest':False} def __init__(cls): pass @@ -48,12 +50,12 @@ class Container: @classmethod def pull_image(cls, type): docker_image = cls.get_docker_image(type) - if container_config[type]['has_pull'] == True: + if cls.has_pull_latest_image[type] == True: logger.debug('%s is already the newest version.' % (docker_image)) else: cmd = 'sudo docker pull %s' % (docker_image) dt_utils.exec_cmd(cmd,logger) - container_config[type]['has_pull'] = True + cls.has_pull_latest_image[type] = True @classmethod def clean(cls, container_id): @@ -67,4 +69,9 @@ class Container: cmd = 'sudo docker exec %s %s' % (container_id, sub_cmd) dt_utils.exec_cmd(cmd,logger,exit_on_error) - + @classmethod + def copy_file(cls, file_dir, container_id, container_dir): + for root, dirs, files in os.walk(file_dir): + for file_name in files: + cmd = 'sudo docker cp %s %s:%s' % (os.path.join(file_dir,file_name), container_id, container_dir) + dt_utils.exec_cmd(cmd, logger, exit_on_error = False) |