- self.ha_conf_file = pkg_resources.resource_filename(
- "yardstick.benchmark.scenarios.availability",
- ServiceHA.HA_CONF)
- ha_cfg = []
- with open(self.ha_conf_file) as stream:
- ha_cfg = yaml.load(stream)
- LOG.debug("ha_cfg content:%s" % ha_cfg)
-
- # check the ha_conf contains the service defined in test cases yaml
- service_cfg = ha_cfg.get(self.service_name, None)
- if not service_cfg:
- LOG.error(
- "The component %s can not be supported!" % self.service_name)
- return
-
- for fault in service_cfg:
- if fault["type"] == self.fault_type:
- self.fault_cfg = fault
- break
- if not self.fault_cfg:
- LOG.error(
- "The fualt_type %s can not be supproted!" % self.fault_type)
- return
- LOG.debug("the fault_cfg :%s" % self.fault_cfg)
-
- self.fault_script = pkg_resources.resource_filename(
- "yardstick.benchmark.scenarios.availability",
- self.fault_cfg["inject_script"])
- self.recovery_script = pkg_resources.resource_filename(
- "yardstick.benchmark.scenarios.availability",
- self.fault_cfg["recovery_script"])
- self.check_script = pkg_resources.resource_filename(
- "yardstick.benchmark.scenarios.availability",
- self.fault_cfg["check_script"])
-
- host = self.context_cfg.get("host", None)
- ip = host.get("ip", None)
- user = host.get("user", "root")
- key_filename = host.get("key_filename", "~/.ssh/id_rsa")
- LOG.info("The host: %s the service: %s" % (ip, self.service_name))
- LOG.debug("The params, host:%s fault_cfg:%s" % (host, self.fault_cfg))
-
- LOG.debug(
- "ssh connection ip:%s, user:%s, key_file:%s",
- ip, user, key_filename)
- self.connection = ssh.SSH(user, ip, key_filename=key_filename)
- self.connection.wait(timeout=600)
- LOG.debug("ssh host success!")
-
- # check the host envrioment
- exit_status, stdout, stderr = self.connection.execute(
- "/bin/sh -s {0}".format(self.service_name),
- stdin=open(self.check_script, "r"))
- LOG.info(
- "the exit_status:%s stdout:%s stderr:%s" %
- (exit_status, stdout, stderr))
- if exit_status:
- raise RuntimeError(stderr)
-
- if stdout and "running" in stdout:
- LOG.info("check the envrioment success!")
- else:
- LOG.error(
- "the host envrioment is error, stdout:%s, stderr:%s" %
- (stdout, stderr))