X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=yardstick%2Fbenchmark%2Fscenarios%2Fnetworking%2Fpktgen.py;h=b61337a70fad1154e61fc5d54862021c26ba4336;hb=5ecd7b446156775b8adb9cd15fe7decea5d305d9;hp=3e105767aec45fa255371b330c2e1bf99e2b3129;hpb=eec370bc52caee7fe1633ae9f3ec8ac85ac50119;p=yardstick.git diff --git a/yardstick/benchmark/scenarios/networking/pktgen.py b/yardstick/benchmark/scenarios/networking/pktgen.py index 3e105767a..b61337a70 100644 --- a/yardstick/benchmark/scenarios/networking/pktgen.py +++ b/yardstick/benchmark/scenarios/networking/pktgen.py @@ -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__':