Add support for Python 3
[yardstick.git] / yardstick / benchmark / scenarios / compute / cyclictest.py
index a6c4d95..76bafff 100644 (file)
@@ -6,12 +6,16 @@
 # 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 os
 import re
 import time
-import os
+
+import pkg_resources
+from oslo_serialization import jsonutils
 
 import yardstick.ssh as ssh
 from yardstick.benchmark.scenarios import base
@@ -154,8 +158,8 @@ class Cyclictest(base.Scenario):
         self.target_script = pkg_resources.resource_filename(
             "yardstick.benchmark.scenarios.compute",
             Cyclictest.TARGET_SCRIPT)
-        self.guest.run("cat > ~/cyclictest_benchmark.sh",
-                       stdin=open(self.target_script, "rb"))
+        self.guest._put_file_shell(
+            self.target_script, '~/cyclictest_benchmark.sh')
 
         self.setup_done = True
 
@@ -183,7 +187,7 @@ class Cyclictest(base.Scenario):
         if status:
             raise RuntimeError(stderr)
 
-        result.update(json.loads(stdout))
+        result.update(jsonutils.loads(stdout))
 
         if "sla" in self.scenario_cfg:
             sla_error = ""
@@ -236,7 +240,8 @@ def _test():    # pragma: no cover
 
     cyclictest = Cyclictest(args, ctx)
     cyclictest.run(result)
-    print result
+    print(result)
+
 
 if __name__ == '__main__':    # pragma: no cover
     _test()