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) --- .../result_checker/result_checker_general.py | 47 +++++++++++++++------- 1 file changed, 32 insertions(+), 15 deletions(-) (limited to 'yardstick/benchmark/scenarios/availability/result_checker') diff --git a/yardstick/benchmark/scenarios/availability/result_checker/result_checker_general.py b/yardstick/benchmark/scenarios/availability/result_checker/result_checker_general.py index ff6017b88..0f2e382ae 100644 --- a/yardstick/benchmark/scenarios/availability/result_checker/result_checker_general.py +++ b/yardstick/benchmark/scenarios/availability/result_checker/result_checker_general.py @@ -9,13 +9,13 @@ from __future__ import absolute_import import logging - from yardstick.benchmark.scenarios.availability.result_checker \ .baseresultchecker import \ BaseResultChecker from yardstick.benchmark.scenarios.availability import Condition import yardstick.ssh as ssh -from yardstick.benchmark.scenarios.availability.util import buildshellparams +from yardstick.benchmark.scenarios.availability.util \ + import buildshellparams, execute_shell_command LOG = logging.getLogger(__name__) @@ -25,11 +25,14 @@ class GeneralResultChecker(BaseResultChecker): def setup(self): LOG.debug("config:%s context:%s", self._config, self._context) - host = self._context.get(self._config['host'], None) + host = self._context.get(self._config.get('host', None), None) - self.connection = ssh.SSH.from_node(host, defaults={"user": "root"}) - self.connection.wait(timeout=600) - LOG.debug("ssh host success!") + self.connection = None + if host: + self.connection = ssh.SSH.from_node( + host, defaults={"user": "root"}) + self.connection.wait(timeout=600) + LOG.debug("ssh host success!") self.key = self._config['key'] self.resultchecker_key = self._config['checker_key'] @@ -41,7 +44,8 @@ class GeneralResultChecker(BaseResultChecker): self.key = self._config['key'] if "parameter" in self._config: parameter = self._config['parameter'] - str = buildshellparams(parameter) + str = buildshellparams( + parameter, True if self.connection else False) l = list(item for item in parameter.values()) self.shell_cmd = str.format(*l) @@ -52,19 +56,32 @@ class GeneralResultChecker(BaseResultChecker): def verify(self): if "parameter" in self._config: - with open(self.verify_script, "r") as stdin_file: - exit_status, stdout, stderr = self.connection.execute( - self.shell_cmd, - stdin=stdin_file) + if self.connection: + with open(self.verify_script, "r") as stdin_file: + exit_status, stdout, stderr = self.connection.execute( + self.shell_cmd, + stdin=stdin_file) + else: + exit_status, stdout = \ + execute_shell_command( + "/bin/bash {0} {1}".format( + self.verify_script, + self.rollback_param)) + LOG.debug("action script of the operation is: %s", self.verify_script) LOG.debug("action parameter the of operation is: %s", self.shell_cmd) else: - with open(self.verify_script, "r") as stdin_file: - exit_status, stdout, stderr = self.connection.execute( - "/bin/bash -s ", - stdin=stdin_file) + if self.connection: + with open(self.verify_script, "r") as stdin_file: + exit_status, stdout, stderr = self.connection.execute( + "/bin/bash -s ", + stdin=stdin_file) + else: + exit_status, stdout = execute_shell_command( + "/bin/bash {0}".format(self.verify_script)) + LOG.debug("action script of the operation is: %s", self.verify_script) -- cgit 1.2.3-korg