Merge "fix the ssh bug when run tc043 in CI"
authorliang gao <jean.gaoliang@huawei.com>
Thu, 7 Jul 2016 03:25:57 +0000 (03:25 +0000)
committerGerrit Code Review <gerrit@172.30.200.206>
Thu, 7 Jul 2016 03:25:57 +0000 (03:25 +0000)
yardstick/benchmark/scenarios/networking/ping.py

index 3af3548..08755a0 100644 (file)
@@ -41,11 +41,17 @@ class Ping(base.Scenario):
         user = host.get('user', 'ubuntu')
         ip = host.get('ip', None)
         key_filename = host.get('key_filename', '/root/.ssh/id_rsa')
-        password = host.get('password', 'root')
+        password = host.get('password', None)
+
+        if password is not None:
+            LOG.info("Log in via pw, user:%s, host:%s, pw:%s",
+                     user, ip, password)
+            self.connection = ssh.SSH(user, ip, password=password)
+        else:
+            LOG.info("Log in via key, user:%s, host:%s, key_filename:%s",
+                     user, ip, key_filename)
+            self.connection = ssh.SSH(user, ip, key_filename=key_filename)
 
-        LOG.info("user:%s, host:%s, key_filename:%s", user, ip, key_filename)
-        self.connection = ssh.SSH(user, ip, key_filename=key_filename,
-                                  password=password)
         self.connection.wait()
 
     def run(self, result):