From 1b267df54356da0cba66a33edaf68ee50ecee53d Mon Sep 17 00:00:00 2001 From: tjuyinkanglin <14_ykl@tongji.edu.cn> Date: Thu, 4 May 2017 15:58:55 +0800 Subject: Bugfix: Local Openstack Operation in HA test frameworks JIRA: YARDSTICK-635 Change-Id: Ic27517714db9325e7a3b1ef623c49af61c36b2b5 Signed-off-by: tjuyinkanglin <14_ykl@tongji.edu.cn> (cherry picked from commit 2fb95fbb9380ea7ce92dcb32cd2f0789b9f91bdc) --- yardstick/benchmark/scenarios/availability/util.py | 25 ++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'yardstick/benchmark/scenarios/availability/util.py') diff --git a/yardstick/benchmark/scenarios/availability/util.py b/yardstick/benchmark/scenarios/availability/util.py index 2addef8ef..eadbfa53b 100644 --- a/yardstick/benchmark/scenarios/availability/util.py +++ b/yardstick/benchmark/scenarios/availability/util.py @@ -6,14 +6,35 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +import logging +import subprocess +import traceback +LOG = logging.getLogger(__name__) -def buildshellparams(param): + +def buildshellparams(param, remote=True): i = 0 values = [] - result = '/bin/bash -s' + result = '/bin/bash -s' if remote else '' for key in param.keys(): values.append(param[key]) result += " {%d}" % i i = i + 1 return result + + +def execute_shell_command(command): + """execute shell script with error handling""" + exitcode = 0 + output = [] + try: + LOG.debug("the command is: %s", command) + output = subprocess.check_output(command, shell=True) + except Exception: + exitcode = -1 + output = traceback.format_exc() + LOG.error("exec command '%s' error:\n ", command) + LOG.error(traceback.format_exc()) + + return exitcode, output -- cgit 1.2.3-korg