# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
# bulk data test and req/rsp test are supported
-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
self.setup_done = False
def setup(self):
- '''scenario setup'''
+ """scenario setup"""
self.target_script = pkg_resources.resource_filename(
'yardstick.benchmark.scenarios.networking',
Netperf.TARGET_SCRIPT)
host = self.context_cfg['host']
- host_user = host.get('user', 'ubuntu')
- host_ip = host.get('ip', None)
- host_key_filename = host.get('key_filename', '~/.ssh/id_rsa')
target = self.context_cfg['target']
- target_user = target.get('user', 'ubuntu')
- target_ip = target.get('ip', None)
- target_key_filename = target.get('key_filename', '~/.ssh/id_rsa')
# netserver start automatically during the vm boot
- LOG.info("user:%s, target:%s", target_user, target_ip)
- self.server = ssh.SSH(target_user, target_ip,
- key_filename=target_key_filename)
+ LOG.info("user:%s, target:%s", target['user'], target['ip'])
+ self.server = ssh.SSH.from_node(target, defaults={"user": "ubuntu"})
self.server.wait(timeout=600)
- LOG.info("user:%s, host:%s", host_user, host_ip)
- self.client = ssh.SSH(host_user, host_ip,
- key_filename=host_key_filename)
+ LOG.info("user:%s, host:%s", host['user'], host['ip'])
+ self.client = ssh.SSH.from_node(host, defaults={"user": "ubuntu"})
self.client.wait(timeout=600)
# copy script to host
- self.client.run("cat > ~/netperf.sh",
- stdin=open(self.target_script, "rb"))
+ self.client._put_file_shell(self.target_script, '~/netperf.sh')
self.setup_done = True
if status:
raise RuntimeError(stderr)
- result.update(json.loads(stdout))
+ result.update(jsonutils.loads(stdout))
if result['mean_latency'] == '':
raise RuntimeError(stdout)
def _test():
- '''internal test function'''
+ """internal test function"""
key_filename = pkg_resources.resource_filename("yardstick.resources",
"files/yardstick_key")
ctx = {
netperf = Netperf(args, ctx)
netperf.run(result)
- print result
+ print(result)
+
if __name__ == '__main__':
_test()