def recover(self): jump_host_name = self._config.get("jump_host", None) self.jump_connection = None if jump_host_name is not None: host = self._context.get(jump_host_name, None) ip = host.get("ip", None) user = host.get("user", "root") pwd = host.get("pwd", None) LOG.debug("jump_host ip:%s user:%s" % (ip, user)) self.jump_connection = ssh.SSH(user, ip, password=pwd) self.jump_connection.wait(timeout=600) LOG.debug("ssh jump host success!") if self.jump_connection is not None: exit_status, stdout, stderr = self.jump_connection.execute( "/bin/bash -s {0} {1} {2} {3}".format(self.ipmi_ip, self.ipmi_user, self.ipmi_pwd, "on"), stdin=open(self.recovery_script, "r")) else: exit_status, stdout = _execute_shell_command( "/bin/bash -s {0} {1} {2} {3}".format(self.ipmi_ip, self.ipmi_user, self.ipmi_pwd, "on"), stdin=open(self.recovery_script, "r"))
def setup(self): LOG.debug("config:%s context:%s" % (self._config, self._context)) host = self._context.get(self._config['host'], None) ip = host.get("ip", None) user = host.get("user", "root") key_filename = host.get("key_filename", "~/.ssh/id_rsa") self.connection = ssh.SSH(user, ip, key_filename=key_filename) self.connection.wait(timeout=600) LOG.debug("ssh host success!") self.key = self._config['key'] self.type = self._config['checker_type'] self.condition = self._config['condition'] self.expectedResult = self._config['expectedValue'] self.actualResult = object() self.key = self._config['key'] if "parameter" in self._config: parameter = self._config['parameter'] str = buildshellparams(parameter) l = list(item for item in parameter.values()) self.shell_cmd = str.format(*l) if self.__result_checker__type__ == "general-result-checker": self.resultchecker_cfgs = BaseResultChecker.resultchecker_cfgs.get( self.key) self.verify_script = self.get_script_fullpath( self.resultchecker_cfgs['verify_script']) self.setup_done = True self.value_list = {} self.value_prefix = "@_@"
def connect_to_node(self): LOG.debug("config:%s context:%s" % (self._config, self._context)) host = self._context.get(self._config['host'], None) ip = host.get("ip", None) user = host.get("user", "root") key_filename = host.get("key_filename", "~/.ssh/id_rsa") self.connection = ssh.SSH(user, ip, key_filename=key_filename) self.connection.wait(timeout=600) LOG.debug("ssh host success!")
def setup(self): host = self._context[self._config["host"]] ip = host.get("ip", None) user = host.get("user", "root") key_filename = host.get("key_filename", "~/.ssh/id_rsa") self.connection = ssh.SSH(user, ip, key_filename=key_filename) self.connection.wait(timeout=600) LOG.debug("ssh host success!") self.check_script = self.get_script_fullpath( "ha_tools/check_process_python.bash") self.process_name = self._config["process_name"]
def setup(self): self.connection = None node_name = self._config.get("host", None) if node_name: host = self._context[node_name] ip = host.get("ip", None) user = host.get("user", "root") key_filename = host.get("key_filename", "~/.ssh/id_rsa") self.connection = ssh.SSH(user, ip, key_filename=key_filename) self.connection.wait(timeout=600) LOG.debug("ssh host success!") self.check_script = self.get_script_fullpath(self._config["command_name"])
def setup(self): LOG.debug("config:%s context:%s" % (self._config, self._context)) host = self._context.get(self._config['host'], None) ip = host.get("ip", None) user = host.get("user", "root") key_filename = host.get("key_filename", "~/.ssh/id_rsa") self.connection = ssh.SSH(user, ip, key_filename=key_filename) self.connection.wait(timeout=600) LOG.debug("ssh host success!") self.key = self._config['key'] self.type = self._config['operation_type'] if "actionParameter" in self._config: actionParameter = self._config['actionParameter'] str = buildshellparams(actionParameter) LOG.debug("inject parameter is: {0}".format(actionParameter)) LOG.debug("inject parameter values are: {0}".format( actionParameter.values())) l = list(item for item in actionParameter.values()) self.action_param = str.format(*l) if "rollbackParameter" in self._config: rollbackParameter = self._config['rollbackParameter'] str = buildshellparams(rollbackParameter) LOG.debug("recover parameter is: {0}".format(rollbackParameter)) LOG.debug("recover parameter values are: {0}".format( rollbackParameter.values())) l = list(item for item in rollbackParameter.values()) self.rollback_param = str.format(*l) if (self.__operation__type__ == "general-operation"): self.operation_cfgs = BaseOperation.operation_cfgs.get(self.key) else: self.operation_cfgs = BaseOperation.operation_cfgs.get(self.type) self.action_script = self.get_script_fullpath( self.operation_cfgs['action_script']) self.rollback_script = self.get_script_fullpath( self.operation_cfgs['rollback_script']) self.setup_done = True self.value_list = {} self.value_prefix = "@_@"
def setup(self): host = self._context[self._config["host"]] ip = host.get("ip", None) user = host.get("user", "root") key_filename = host.get("key_filename", "~/.ssh/id_rsa") self.key = self._config["key"] self.monitor_type = self._config["monitor_type"] if "parameter" in self._config: parameter = self._config['parameter'] str = buildshellparams(parameter) l = list(item for item in parameter.values()) self.cmd_param = str.format(*l) self.monitor_cfg = basemonitor.BaseMonitor.monitor_cfgs.get(self.key) self.monitor_script = self.get_script_fullpath(self.monitor_cfg['monitor_script']) self.connection = ssh.SSH(user, ip, key_filename=key_filename) self.connection.wait(timeout=600) LOG.debug("ssh host success!")
def setup(self): LOG.debug("config:%s context:%s" % (self._config, self._context)) host = self._context.get(self._config['host'], None) ip = host.get("ip", None) user = host.get("user", "root") key_filename = host.get("key_filename", "~/.ssh/id_rsa") self.connection = ssh.SSH(user, ip, key_filename=key_filename) self.connection.wait(timeout=600) LOG.debug("ssh host success!") self.fault_cfg = BaseAttacker.attacker_cfgs.get(self.__attacker_type__) self.check_script = self.get_script_fullpath( self.fault_cfg['check_script']) self.inject_script = self.get_script_fullpath( self.fault_cfg['inject_script']) self.recovery_script = self.get_script_fullpath( self.fault_cfg['recovery_script']) if self.check(): self.setup_done = True
def setup(self): LOG.debug("config:%s context:%s" % (self._config, self._context)) host = self._context.get(self._config['host'], None) ip = host.get("ip", None) user = host.get("user", "root") key_filename = host.get("key_filename", "~/.ssh/id_rsa") self.connection = ssh.SSH(user, ip, key_filename=key_filename) self.connection.wait(timeout=600) LOG.debug("ssh host success!") self.key = self._config['key'] if "actionParameter" in self._config: actionParameter = self._config['actionParameter'] str = buildshellparams(actionParameter) LOG.debug("inject parameter is: {0}".format(actionParameter)) LOG.debug("inject parameter values are: {0}".format( actionParameter.values())) l = list(item for item in actionParameter.values()) self.action_param = str.format(*l) if "rollbackParameter" in self._config: rollbackParameter = self._config['rollbackParameter'] str = buildshellparams(rollbackParameter) LOG.debug("recover parameter is: {0}".format(rollbackParameter)) LOG.debug("recover parameter values are: {0}".format( rollbackParameter.values())) l = list(item for item in rollbackParameter.values()) self.rollback_param = str.format(*l) self.fault_cfg = BaseAttacker.attacker_cfgs.get(self.key) self.inject_script = self.get_script_fullpath( self.fault_cfg['inject_script']) self.recovery_script = self.get_script_fullpath( self.fault_cfg['recovery_script']) self.value_list = {} self.value_prefix = "@_@"
def setup(self): LOG.debug("config:%s context:%s" % (self._config, self._context)) host = self._context.get(self._config['host'], None) ip = host.get("ip", None) user = host.get("user", "root") key_filename = host.get("key_filename", "~/.ssh/id_rsa") self.connection = ssh.SSH(user, ip, key_filename=key_filename) self.connection.wait(timeout=600) LOG.debug("ssh host success!") self.key = self._config['key'] self.type = self._config['checker_type'] self.condition = self._config['condition'] self.expectedResult = self._config['expectedValue'] self.actualResult = object() self.key = self._config['key'] self.resultchecker_cfgs = BaseResultChecker.resultchecker_cfgs.get( self.type) self.verify_script = self.get_script_fullpath( self.resultchecker_cfgs['verify_script']) self.setup_done = True