Merge "Bux: task_id parameter from API can not pass to yardstick core"
[yardstick.git] / yardstick / benchmark / scenarios / networking / pktgen.py
index 3e10576..b61337a 100644 (file)
@@ -6,9 +6,13 @@
 # which accompanies this distribution, and is available at
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
-import pkg_resources
+from __future__ import absolute_import
+from __future__ import print_function
+
 import logging
-import json
+
+import pkg_resources
+from oslo_serialization import jsonutils
 
 import yardstick.ssh as ssh
 from yardstick.benchmark.scenarios import base
@@ -43,7 +47,7 @@ class Pktgen(base.Scenario):
         self.setup_done = False
 
     def setup(self):
-        '''scenario setup'''
+        """scenario setup"""
         self.target_script = pkg_resources.resource_filename(
             'yardstick.benchmark.scenarios.networking',
             Pktgen.TARGET_SCRIPT)
@@ -71,8 +75,7 @@ class Pktgen(base.Scenario):
         self.client.wait(timeout=600)
 
         # copy script to host
-        self.client.run("cat > ~/pktgen.sh",
-                        stdin=open(self.target_script, "rb"))
+        self.client._put_file_shell(self.target_script, '~/pktgen.sh')
 
         self.setup_done = True
 
@@ -131,7 +134,7 @@ class Pktgen(base.Scenario):
         if status:
             raise RuntimeError(stderr)
 
-        result.update(json.loads(stdout))
+        result.update(jsonutils.loads(stdout))
 
         result['packets_received'] = self._iptables_get_result()
 
@@ -145,7 +148,7 @@ class Pktgen(base.Scenario):
 
 
 def _test():
-    '''internal test function'''
+    """internal test function"""
     key_filename = pkg_resources.resource_filename('yardstick.resources',
                                                    'files/yardstick_key')
     ctx = {
@@ -171,7 +174,7 @@ def _test():
 
     p = Pktgen(args, ctx)
     p.run(result)
-    print result
+    print(result)
 
 
 if __name__ == '__main__':