From 76be7f7c6b2921aad6a68504a2020fb032eb5fde Mon Sep 17 00:00:00 2001 From: Leo Wang Date: Wed, 21 Dec 2016 02:34:44 -0500 Subject: [dovetail tool]check and get results for each cmd JIRA: DOVETAIL-166 Check the results of each cmds executed in test case 1. the results of pre_condition, post_condition, cmds need to be checked, so it can get a quick fail, dont need to go through the next step 2. it's more accurate to show where error occurred as early as possible 3. get results from shell scripts Change-Id: I5c1e59839c55b92de0e83e7e1eb552aa364b3f80 Signed-off-by: Leo Wang --- dovetail/container.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'dovetail/container.py') diff --git a/dovetail/container.py b/dovetail/container.py index 59fc0d8a..b3450fa3 100644 --- a/dovetail/container.py +++ b/dovetail/container.py @@ -67,8 +67,10 @@ class Container: (docker_image)) else: cmd = 'sudo docker pull %s' % (docker_image) - dt_utils.exec_cmd(cmd, cls.logger) - cls.has_pull_latest_image[type] = True + ret, msg = dt_utils.exec_cmd(cmd, cls.logger) + if ret == 0: + cls.logger.debug('docker pull %s success!', docker_image) + cls.has_pull_latest_image[type] = True @classmethod def clean(cls, container_id): @@ -80,6 +82,6 @@ class Container: @classmethod def exec_cmd(cls, container_id, sub_cmd, exit_on_error=False): if sub_cmd == "": - return + return (1, 'sub_cmd is empty') cmd = 'sudo docker exec %s /bin/bash -c "%s"' % (container_id, sub_cmd) - dt_utils.exec_cmd(cmd, cls.logger, exit_on_error) + return dt_utils.exec_cmd(cmd, cls.logger, exit_on_error) -- cgit 1.2.3-korg