X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=yardstick%2Fbenchmark%2Fscenarios%2Fcompute%2Flmbench.py;h=c99fc988d528d72f104bdf8eb1a56c485aa13493;hb=0cca44508c3a171cb5e94347a3b555462ec31cd3;hp=518840c09cd820ecc133ff88f83729b68476d7c0;hpb=0576844bb2cdae6b479504ec1532a5dc56c0b633;p=yardstick.git diff --git a/yardstick/benchmark/scenarios/compute/lmbench.py b/yardstick/benchmark/scenarios/compute/lmbench.py index 518840c09..c99fc988d 100644 --- a/yardstick/benchmark/scenarios/compute/lmbench.py +++ b/yardstick/benchmark/scenarios/compute/lmbench.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 @@ -76,14 +80,8 @@ class Lmbench(base.Scenario): "yardstick.benchmark.scenarios.compute", Lmbench.LATENCY_CACHE_SCRIPT) host = self.context_cfg["host"] - user = host.get("user", "ubuntu") - ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT) - 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, - port=ssh_port) + + self.client = ssh.SSH.from_node(host, defaults={"user": "ubuntu"}) self.client.wait(timeout=600) # copy scripts to host @@ -130,9 +128,10 @@ class Lmbench(base.Scenario): raise RuntimeError(stderr) if test_type == 'latency': - result.update({"latencies": json.loads(stdout)}) + result.update( + {"latencies": jsonutils.loads(stdout)}) else: - result.update(json.loads(stdout)) + result.update(jsonutils.loads(stdout)) if "sla" in self.scenario_cfg: sla_error = "" @@ -185,7 +184,8 @@ def _test(): p = Lmbench(args, ctx) p.run(result) - print result + print(result) + if __name__ == '__main__': _test()