コード例 #1
0
    def setup(self):
        LOG.debug("config:%s context:%s", self._config, self._context)
        host = self._context.get(self._config['host'], None)

        self.connection = ssh.SSH.from_node(host, defaults={"user": "******"})
        self.connection.wait(timeout=600)
        LOG.debug("ssh host success!")

        self.key = self._config['key']
        self.attack_key = self._config['attack_key']

        if "action_parameter" in self._config:
            actionParameter = self._config['action_parameter']
            str = util.buildshellparams(actionParameter)
            LOG.debug("inject parameter is: %s", actionParameter)
            LOG.debug("inject parameter values are: %s",
                      list(actionParameter.values()))
            l = list(actionParameter.values())
            self.action_param = str.format(*l)

        if "rollback_parameter" in self._config:
            rollbackParameter = self._config['rollback_parameter']
            str = util.buildshellparams(rollbackParameter)
            LOG.debug("recover parameter is: %s", rollbackParameter)
            LOG.debug("recover parameter values are: %s",
                      list(rollbackParameter.values()))
            l = list(rollbackParameter.values())
            self.rollback_param = str.format(*l)

        self.fault_cfg = BaseAttacker.attacker_cfgs.get(self.attack_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'])
コード例 #2
0
    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.operation_key = self._config['operation_key']

        if "action_parameter" in self._config:
            actionParameter = self._config['action_parameter']
            str = buildshellparams(actionParameter)
            l = list(item for item in actionParameter.values())
            self.action_param = str.format(*l)

        if "rollback_parameter" in self._config:
            rollbackParameter = self._config['rollback_parameter']
            str = buildshellparams(rollbackParameter)
            l = list(item for item in rollbackParameter.values())
            self.rollback_param = str.format(*l)

        self.operation_cfgs = BaseOperation.operation_cfgs.get(
            self.operation_key)
        self.action_script = self.get_script_fullpath(
            self.operation_cfgs['action_script'])
        self.rollback_script = self.get_script_fullpath(
            self.operation_cfgs['rollback_script'])
コード例 #3
0
    def setup(self):
        LOG.debug("config:%s context:%s", self._config, self._context)
        host = self._context.get(self._config.get('host', None), None)

        self.connection = None
        if host:
            self.connection = ssh.SSH.from_node(host,
                                                defaults={"user": "******"})
            self.connection.wait(timeout=600)
            LOG.debug("ssh host success!")

        self.key = self._config['key']
        self.operation_key = self._config['operation_key']

        if "action_parameter" in self._config:
            actionParameter = self._config['action_parameter']
            str = buildshellparams(actionParameter,
                                   True if self.connection else False)
            l = list(item for item in actionParameter.values())
            self.action_param = str.format(*l)

        if "rollback_parameter" in self._config:
            rollbackParameter = self._config['rollback_parameter']
            str = buildshellparams(rollbackParameter,
                                   True if self.connection else False)
            l = list(item for item in rollbackParameter.values())
            self.rollback_param = str.format(*l)

        self.operation_cfgs = BaseOperation.operation_cfgs.get(
            self.operation_key)
        self.action_script = self.get_script_fullpath(
            self.operation_cfgs['action_script'])
        self.rollback_script = self.get_script_fullpath(
            self.operation_cfgs['rollback_script'])
コード例 #4
0
ファイル: operation_general.py プロジェクト: kkltcjk/1026
    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.operation_key = self._config['operation_key']

        if "action_parameter" in self._config:
            actionParameter = self._config['action_parameter']
            str = buildshellparams(actionParameter)
            l = list(item for item in actionParameter.values())
            self.action_param = str.format(*l)

        if "rollback_parameter" in self._config:
            rollbackParameter = self._config['rollback_parameter']
            str = buildshellparams(rollbackParameter)
            l = list(item for item in rollbackParameter.values())
            self.rollback_param = str.format(*l)

        self.operation_cfgs = BaseOperation.operation_cfgs.get(
            self.operation_key)
        self.action_script = self.get_script_fullpath(
            self.operation_cfgs['action_script'])
        self.rollback_script = self.get_script_fullpath(
            self.operation_cfgs['rollback_script'])
コード例 #5
0
    def setup(self):
        LOG.debug("config:%s context:%s", self._config, self._context)
        host = self._context.get(self._config.get('host', None), None)

        self.connection = None
        if host:
            self.connection = ssh.SSH.from_node(host,
                                                defaults={"user": "******"})
            self.connection.wait(timeout=600)
            LOG.debug("ssh host success!")

        self.key = self._config['key']
        self.resultchecker_key = self._config['checker_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,
                                   True if self.connection else False)
            l = list(item for item in parameter.values())
            self.shell_cmd = str.format(*l)

        self.resultchecker_cfgs = BaseResultChecker.resultchecker_cfgs.get(
            self.resultchecker_key)
        self.verify_script = self.get_script_fullpath(
            self.resultchecker_cfgs['verify_script'])
コード例 #6
0
    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")
        ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
        key_filename = host.get("key_filename", "~/.ssh/id_rsa")

        self.connection = ssh.SSH(user,
                                  ip,
                                  key_filename=key_filename,
                                  port=ssh_port)
        self.connection.wait(timeout=600)
        LOG.debug("ssh host success!")

        self.key = self._config['key']
        self.resultchecker_key = self._config['checker_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)

        self.resultchecker_cfgs = BaseResultChecker.resultchecker_cfgs.get(
            self.resultchecker_key)
        self.verify_script = self.get_script_fullpath(
            self.resultchecker_cfgs['verify_script'])
コード例 #7
0
    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.resultchecker_key = self._config['checker_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)

        self.resultchecker_cfgs = BaseResultChecker.resultchecker_cfgs.get(
            self.resultchecker_key)
        self.verify_script = self.get_script_fullpath(
            self.resultchecker_cfgs['verify_script'])
コード例 #8
0
    def setup(self):
        host = self._context[self._config["host"]]
        ip = host.get("ip", None)
        user = host.get("user", "root")
        ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
        key_filename = host.get("key_filename", "~/.ssh/id_rsa")
        self.key = self._config["key"]
        self.monitor_key = self._config["monitor_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.monitor_key)
        self.monitor_script = self.get_script_fullpath(
            self.monitor_cfg['monitor_script'])
        self.connection = ssh.SSH(user,
                                  ip,
                                  key_filename=key_filename,
                                  port=ssh_port)
        self.connection.wait(timeout=600)
        LOG.debug("ssh host success!")
コード例 #9
0
ファイル: attacker_general.py プロジェクト: kkltcjk/kklt
    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")
        ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
        key_filename = host.get("key_filename", "~/.ssh/id_rsa")

        self.connection = ssh.SSH(user, ip, key_filename=key_filename,
                                  port=ssh_port)
        self.connection.wait(timeout=600)
        LOG.debug("ssh host success!")

        self.key = self._config['key']
        self.attack_key = self._config['attack_key']

        if "action_parameter" in self._config:
            actionParameter = self._config['action_parameter']
            str = util.buildshellparams(actionParameter)
            LOG.debug("inject parameter is: {0}".format(actionParameter))
            LOG.debug("inject parameter values are: {0}"
                      .format(list(actionParameter.values())))
            l = list(item for item in actionParameter.values())
            self.action_param = str.format(*l)

        if "rollback_parameter" in self._config:
            rollbackParameter = self._config['rollback_parameter']
            str = util.buildshellparams(rollbackParameter)
            LOG.debug("recover parameter is: {0}".format(rollbackParameter))
            LOG.debug("recover parameter values are: {0}".
                      format(list(rollbackParameter.values())))
            l = list(item for item in rollbackParameter.values())
            self.rollback_param = str.format(*l)

        self.fault_cfg = BaseAttacker.attacker_cfgs.get(self.attack_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'])
コード例 #10
0
    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.attack_key = self._config['attack_key']

        if "action_parameter" in self._config:
            actionParameter = self._config['action_parameter']
            str = util.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 "rollback_parameter" in self._config:
            rollbackParameter = self._config['rollback_parameter']
            str = util.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.attack_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'])
コード例 #11
0
    def setup(self):
        host = self._context[self._config["host"]]
        self.key = self._config["key"]
        self.monitor_key = self._config["monitor_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.monitor_key)
        self.monitor_script = self.get_script_fullpath(
            self.monitor_cfg['monitor_script'])
        self.connection = ssh.SSH.from_node(host, defaults={"user": "******"})
        self.connection.wait(timeout=600)
        LOG.debug("ssh host success!")
コード例 #12
0
    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_key = self._config["monitor_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.monitor_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!")
コード例 #13
0
ファイル: test_util.py プロジェクト: rossella/yardstick
 def test_buildshellparams(self, mock_subprocess):
     result = util.buildshellparams(self.cmd_config, True)
     self.assertEquals('/bin/bash -s {0} {1}', result)
コード例 #14
0
ファイル: test_util.py プロジェクト: yc18/yardstick
 def test_buildshellparams(self):
     result = util.buildshellparams(self.cmd_config, True)
     self.assertEqual('/bin/bash -s {0} {1}', result)