Merge "Remove references to "dpdk_nic_bind" utility"
[yardstick.git] / yardstick / benchmark / scenarios / compute / ramspeed.py
index 819ef76..ca64935 100644 (file)
@@ -6,11 +6,15 @@
 # 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.common import utils
 from yardstick.benchmark.scenarios import base
 
 LOG = logging.getLogger(__name__)
@@ -86,19 +90,15 @@ class Ramspeed(base.Scenario):
             Ramspeed.RAMSPEED_MEM_SCRIPT)
 
         host = self.context_cfg["host"]
-        user = host.get("user", "ubuntu")
-        ip = host.get("ip", None)
-        key_filename = host.get('key_filename', "~/.ssh/id_rsa")
 
-        LOG.info("user:%s, host:%s", user, ip)
-        self.client = ssh.SSH(user, ip, key_filename=key_filename)
+        self.client = ssh.SSH.from_node(host, defaults={"user": "ubuntu"})
         self.client.wait(timeout=600)
 
         # copy scripts to host
-        self.client.run("cat > ~/ramspeed_mark_benchmark.sh",
-                        stdin=open(self.mark_target_script, 'rb'))
-        self.client.run("cat > ~/ramspeed_mem_benchmark.sh",
-                        stdin=open(self.mem_target_script, 'rb'))
+        self.client._put_file_shell(
+            self.mark_target_script, '~/ramspeed_mark_benchmark.sh')
+        self.client._put_file_shell(
+            self.mem_target_script, '~/ramspeed_mem_benchmark.sh')
         self.setup_done = True
 
     def run(self, result):
@@ -129,12 +129,13 @@ class Ramspeed(base.Scenario):
         if status:
             raise RuntimeError(stderr)
 
-        result.update(json.loads(stdout))
+        ramspeed_result = jsonutils.loads(stdout)
+        result.update(utils.flatten_dict_key(ramspeed_result))
 
         if "sla" in self.scenario_cfg:
             sla_error = ""
             sla_min_bw = int(self.scenario_cfg['sla']['min_bandwidth'])
-            for i in result["Result"]:
+            for i in ramspeed_result["Result"]:
                 bw = i["Bandwidth(MBps)"]
                 if bw < sla_min_bw:
                     sla_error += "Bandwidth %f < " \