Merge "Yardstick TC083: Move sample test case netperf"
[yardstick.git] / yardstick / benchmark / scenarios / networking / networkcapacity.py
index 250f7ea..6363406 100644 (file)
@@ -6,9 +6,12 @@
 # which accompanies this distribution, and is available at
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
-import pkg_resources
+from __future__ import absolute_import
+
 import logging
-import json
+
+import pkg_resources
+from oslo_serialization import jsonutils
 
 import yardstick.ssh as ssh
 from yardstick.benchmark.scenarios import base
@@ -39,14 +42,8 @@ class NetworkCapacity(base.Scenario):
         host = self.context_cfg['host']
         if host is None:
             raise RuntimeError('No right node.please check the configuration')
-        host_user = host.get('user', 'ubuntu')
-        ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
-        host_ip = host.get('ip', None)
-        host_pwd = host.get('password', None)
-
-        LOG.debug("user:%s, host:%s", host_user, host_ip)
-        self.client = ssh.SSH(host_user, host_ip, password=host_pwd,
-                              port=ssh_port)
+
+        self.client = ssh.SSH.from_node(host, defaults={"user": "ubuntu"})
         self.client.wait(timeout=600)
 
         # copy script to host
@@ -67,4 +64,4 @@ class NetworkCapacity(base.Scenario):
         if status:
             raise RuntimeError(stderr)
 
-        result.update(json.loads(stdout))
+        result.update(jsonutils.loads(stdout))