diff options
author | 2017-05-04 15:58:55 +0800 | |
---|---|---|
committer | 2017-05-04 19:56:48 +0800 | |
commit | 2fb95fbb9380ea7ce92dcb32cd2f0789b9f91bdc (patch) | |
tree | 19403bb47d29758c8e01f7efa19f67ba563164ec /yardstick/benchmark/scenarios/availability/util.py | |
parent | ea12d172d6ce24e8a21f0509e8fb286bc9fcbf14 (diff) |
Bugfix: Local Openstack Operation in HA test frameworks
JIRA: YARDSTICK-635
Change-Id: Ic27517714db9325e7a3b1ef623c49af61c36b2b5
Signed-off-by: tjuyinkanglin <14_ykl@tongji.edu.cn>
Diffstat (limited to 'yardstick/benchmark/scenarios/availability/util.py')
-rw-r--r-- | yardstick/benchmark/scenarios/availability/util.py | 25 |
1 files changed, 23 insertions, 2 deletions
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 |