diff options
author | 2016-10-12 05:17:29 -0400 | |
---|---|---|
committer | 2016-10-12 05:18:22 -0400 | |
commit | 690d329a91af99777a0d48cdd2ea84ac7e803c0e (patch) | |
tree | 856546379df2af45a6a1deccad122db4b89ae96d /scripts/container.py | |
parent | 47bd76a388cb6a5b3e023fc6239584b59e19b336 (diff) |
preparation for setup.py
JIRA: DOVETAIL-26
1)change the directory scripts to dovetail, to make it unified in OPNFV and for setup.py
2)change the paths accordingly
3)this should be first merged, since docker is changed, then to add setup.py and run the local test
Change-Id: I65974bde17f310ebbfe3c025532b05dae8752945
Signed-off-by: MatthewLi <matthew.lijun@huawei.com>
Diffstat (limited to 'scripts/container.py')
-rw-r--r-- | scripts/container.py | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/scripts/container.py b/scripts/container.py deleted file mode 100644 index 918edb33..00000000 --- a/scripts/container.py +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env python -# -# grakiss.wanglei@huawei.com -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -# - -import utils.dovetail_logger as dt_logger -import utils.dovetail_utils as dt_utils -from conf.dovetail_config import * - -logger = dt_logger.Logger('container.py').getLogger() - -class Container: - - container_list = {} - has_pull_latest_image = {'yardstick':False, 'functest':False} - - def __init__(cls): - pass - - def __str__(cls): - pass - - @classmethod - def get(cls, type): - return cls.container_list[type] - - @classmethod - def get_docker_image(cls, type): - return '%s:%s' % (dovetail_config[type]['image_name'], dovetail_config[type]['docker_tag']) - - @classmethod - def create(cls, type): - #sshkey="-v /root/.ssh/id_rsa:/root/.ssh/id_rsa " - docker_image = cls.get_docker_image(type) - envs = dovetail_config[type]['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) - dt_utils.exec_cmd(cmd,logger) - ret, container_id=dt_utils.exec_cmd("sudo docker ps | grep "+ docker_image + " | awk '{print $1}' | head -1",logger) - cls.container_list[type] = container_id - return container_id - - @classmethod - def pull_image(cls, type): - docker_image = cls.get_docker_image(type) - 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) - cls.has_pull_latest_image[type] = True - - @classmethod - def clean(cls, container_id): - cmd1 = 'sudo docker stop %s' % (container_id) - dt_utils.exec_cmd(cmd1,logger) - cmd2 = 'sudo docker rm %s' % (container_id) - dt_utils.exec_cmd(cmd2,logger) - - @classmethod - def exec_cmd(cls, container_id, sub_cmd, exit_on_error=False): - cmd = 'sudo docker exec %s /bin/bash -c "%s"' % (container_id, sub_cmd) - dt_utils.exec_cmd(cmd,logger,exit_on_error) |