BugFix: fix Storperf CI bug
[yardstick.git] / yardstick / cmd / commands / plugin.py
index 52ecf20..9936942 100644 (file)
@@ -9,6 +9,7 @@
 
 """ Handler for yardstick command 'plugin' """
 
+import os
 import sys
 import yaml
 import time
@@ -40,8 +41,10 @@ class PluginCommands(object):
         plugin_name = plugins.get("name")
         print("Installing plugin: %s" % plugin_name)
 
+        LOG.info("Executing _install_setup()")
         self._install_setup(plugin_name, deployment)
 
+        LOG.info("Executing _run()")
         self._run(plugin_name)
 
         total_end_time = time.time()
@@ -60,10 +63,12 @@ class PluginCommands(object):
 
         plugins, deployment = parser.parse_plugin()
         plugin_name = plugins.get("name")
-        print("Remove plugin: %s" % plugin_name)
+        print("Removing plugin: %s" % plugin_name)
 
+        LOG.info("Executing _remove_setup()")
         self._remove_setup(plugin_name, deployment)
 
+        LOG.info("Executing _run()")
         self._run(plugin_name)
 
         total_end_time = time.time()
@@ -76,45 +81,65 @@ class PluginCommands(object):
         '''Deployment environment setup'''
         target_script = plugin_name + ".bash"
         self.script = pkg_resources.resource_filename(
-            'yardstick.resources', 'script/install/' + target_script)
+            'yardstick.resources', 'scripts/install/' + target_script)
 
         deployment_user = deployment.get("user")
         deployment_ip = deployment.get("ip")
-
         deployment_password = deployment.get("password")
-        LOG.debug("user:%s, host:%s", deployment_user, deployment_ip)
-        self.client = ssh.SSH(deployment_user, deployment_ip,
-                              password=deployment_password)
-        self.client.wait(timeout=600)
+
+        if deployment_ip == "local":
+            installer_ip = os.environ.get("INSTALLER_IP", None)
+
+            LOG.info("user:%s, host:%s", deployment_user, installer_ip)
+            self.client = ssh.SSH(deployment_user, installer_ip,
+                                  password=deployment_password)
+            self.client.wait(timeout=600)
+        else:
+            LOG.info("user:%s, host:%s", deployment_user, deployment_ip)
+            self.client = ssh.SSH(deployment_user, deployment_ip,
+                                  password=deployment_password)
+            self.client.wait(timeout=600)
 
         # copy script to host
         cmd = "cat > ~/%s.sh" % plugin_name
+
+        LOG.info("copying script to host: %s", cmd)
         self.client.run(cmd, stdin=open(self.script, 'rb'))
 
     def _remove_setup(self, plugin_name, deployment):
         '''Deployment environment setup'''
         target_script = plugin_name + ".bash"
         self.script = pkg_resources.resource_filename(
-            'yardstick.resources', 'script/remove/' + target_script)
+            'yardstick.resources', 'scripts/remove/' + target_script)
 
         deployment_user = deployment.get("user")
         deployment_ip = deployment.get("ip")
-
         deployment_password = deployment.get("password")
-        LOG.debug("user:%s, host:%s", deployment_user, deployment_ip)
-        self.client = ssh.SSH(deployment_user, deployment_ip,
-                              password=deployment_password)
-        self.client.wait(timeout=600)
+
+        if deployment_ip == "local":
+            installer_ip = os.environ.get("INSTALLER_IP", None)
+
+            LOG.info("user:%s, host:%s", deployment_user, installer_ip)
+            self.client = ssh.SSH(deployment_user, installer_ip,
+                                  password=deployment_password)
+            self.client.wait(timeout=600)
+        else:
+            LOG.info("user:%s, host:%s", deployment_user, deployment_ip)
+            self.client = ssh.SSH(deployment_user, deployment_ip,
+                                  password=deployment_password)
+            self.client.wait(timeout=600)
 
         # copy script to host
         cmd = "cat > ~/%s.sh" % plugin_name
+
+        LOG.info("copying script to host: %s", cmd)
         self.client.run(cmd, stdin=open(self.script, 'rb'))
 
     def _run(self, plugin_name):
         '''Run installation script '''
         cmd = "sudo bash %s" % plugin_name + ".sh"
 
-        LOG.debug("Executing command: %s", cmd)
+        LOG.info("Executing command: %s", cmd)
         status, stdout, stderr = self.client.execute(cmd)