Merge "Generate pod.yaml from current context"
[yardstick.git] / yardstick / benchmark / scenarios / availability / monitor / monitor_process.py
index 10b398e..b0f6f8e 100644 (file)
@@ -22,13 +22,8 @@ class MonitorProcess(basemonitor.BaseMonitor):
 
     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.connection = ssh.SSH(user, ip, key_filename=key_filename,
-                                  port=ssh_port)
+        self.connection = ssh.SSH.from_node(host, defaults={"user": "root"})
         self.connection.wait(timeout=600)
         LOG.debug("ssh host success!")
         self.check_script = self.get_script_fullpath(
@@ -38,12 +33,15 @@ class MonitorProcess(basemonitor.BaseMonitor):
     def monitor_func(self):
         with open(self.check_script, "r") as stdin_file:
             exit_status, stdout, stderr = self.connection.execute(
-                "/bin/sh -s {0}".format(self.process_name),
+                "sudo /bin/sh -s {0}".format(self.process_name),
                 stdin=stdin_file)
-        if not stdout or int(stdout) <= 0:
-            LOG.info("the process (%s) is not running!", self.process_name)
+
+        if not stdout or int(stdout) < self.monitor_data[self.process_name]:
+            LOG.info("the (%s) processes are in recovery!", self.process_name)
             return False
 
+        LOG.info("the (%s) processes have been fully recovered!",
+                 self.process_name)
         return True
 
     def verify_SLA(self):
@@ -54,6 +52,7 @@ class MonitorProcess(basemonitor.BaseMonitor):
             LOG.error("SLA failure: %f > %f", outage_time, max_outage_time)
             return False
         else:
+            LOG.info("the sla is passed")
             return True