aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick
diff options
context:
space:
mode:
authorRoss Brattain <ross.b.brattain@intel.com>2017-03-01 17:28:46 -0800
committerJing Lu <lvjing5@huawei.com>2017-05-04 12:54:00 +0000
commit150481286dcf3c3c1fedd8213070cff48e5ad61d (patch)
treea8fc477a69e0a747612de328faaed57f55231973 /yardstick
parent478a499e8cb048abf434559c8d47259ec238ed24 (diff)
standardize ssh auth
we need to be following defautl paramiko rules, first use pkey, then key_filenames (autodetecting ~/.ssh/ keys), then password We have too much boilerplate redudant code everywhere, we need to standardize on a factory function that takes a node dict. Using Python3 ChainMap we can layer overrides and defaults. VNF descriptors have to default key_filename, password to Python None. The only way to do this is to omit key values if the variable is not defined, this way the dict will not have the value and it will default to Python None Add python2 chainmap backport Updated unittest mocking to use ssh.SSH.from_node Change-Id: I80b0cb606e593b33e317c9e5e8ed0b74da591514 Signed-off-by: Ross Brattain <ross.b.brattain@intel.com> (cherry picked from commit 99abbb424007da2e01762f3c040a39c0157cbe1f)
Diffstat (limited to 'yardstick')
-rw-r--r--yardstick/benchmark/contexts/node.py16
-rw-r--r--yardstick/benchmark/core/plugin.py72
-rw-r--r--yardstick/benchmark/scenarios/availability/attacker/attacker_baremetal.py28
-rw-r--r--yardstick/benchmark/scenarios/availability/attacker/attacker_general.py7
-rw-r--r--yardstick/benchmark/scenarios/availability/attacker/attacker_process.py7
-rw-r--r--yardstick/benchmark/scenarios/availability/monitor/monitor_command.py8
-rw-r--r--yardstick/benchmark/scenarios/availability/monitor/monitor_general.py7
-rw-r--r--yardstick/benchmark/scenarios/availability/monitor/monitor_process.py7
-rw-r--r--yardstick/benchmark/scenarios/availability/operation/operation_general.py7
-rw-r--r--yardstick/benchmark/scenarios/availability/result_checker/result_checker_general.py7
-rw-r--r--yardstick/benchmark/scenarios/compute/cachestat.py10
-rw-r--r--yardstick/benchmark/scenarios/compute/computecapacity.py10
-rw-r--r--yardstick/benchmark/scenarios/compute/cpuload.py10
-rw-r--r--yardstick/benchmark/scenarios/compute/cyclictest.py19
-rw-r--r--yardstick/benchmark/scenarios/compute/lmbench.py10
-rw-r--r--yardstick/benchmark/scenarios/compute/memload.py10
-rw-r--r--yardstick/benchmark/scenarios/compute/perf.py10
-rw-r--r--yardstick/benchmark/scenarios/compute/plugintest.py11
-rw-r--r--yardstick/benchmark/scenarios/compute/ramspeed.py10
-rw-r--r--yardstick/benchmark/scenarios/compute/unixbench.py10
-rw-r--r--yardstick/benchmark/scenarios/networking/iperf3.py21
-rwxr-xr-xyardstick/benchmark/scenarios/networking/netperf.py20
-rwxr-xr-xyardstick/benchmark/scenarios/networking/netperf_node.py23
-rw-r--r--yardstick/benchmark/scenarios/networking/netutilization.py10
-rw-r--r--yardstick/benchmark/scenarios/networking/networkcapacity.py10
-rw-r--r--yardstick/benchmark/scenarios/networking/nstat.py10
-rw-r--r--yardstick/benchmark/scenarios/networking/ping.py18
-rw-r--r--yardstick/benchmark/scenarios/networking/ping6.py15
-rw-r--r--yardstick/benchmark/scenarios/networking/pktgen.py22
-rw-r--r--yardstick/benchmark/scenarios/networking/pktgen_dpdk.py20
-rw-r--r--yardstick/benchmark/scenarios/networking/sfc.py59
-rw-r--r--yardstick/benchmark/scenarios/networking/vnf_generic.py8
-rw-r--r--yardstick/benchmark/scenarios/networking/vsperf.py10
-rw-r--r--yardstick/benchmark/scenarios/storage/fio.py10
-rw-r--r--yardstick/benchmark/scenarios/storage/storagecapacity.py12
-rw-r--r--yardstick/network_services/nfvi/resource.py12
-rw-r--r--yardstick/network_services/vnf_generic/vnf/tg_ping.py12
-rw-r--r--yardstick/network_services/vnf_generic/vnf/tg_rfc2544_trex.py12
-rw-r--r--yardstick/network_services/vnf_generic/vnf/tg_trex.py15
-rw-r--r--yardstick/network_services/vnf_generic/vnf/vpe_vnf.py16
-rw-r--r--yardstick/network_services/vnf_generic/vnfdgen.py2
-rw-r--r--yardstick/ssh.py26
42 files changed, 179 insertions, 460 deletions
diff --git a/yardstick/benchmark/contexts/node.py b/yardstick/benchmark/contexts/node.py
index a4a2cfc57..baa1cf5d6 100644
--- a/yardstick/benchmark/contexts/node.py
+++ b/yardstick/benchmark/contexts/node.py
@@ -178,21 +178,7 @@ class NodeContext(Context):
if node is None:
raise SystemExit('No such node')
- user = node.get('user', 'ubuntu')
- ssh_port = node.get("ssh_port", ssh.DEFAULT_PORT)
- ip = node.get('ip')
- pwd = node.get('password')
- key_fname = node.get('key_filename', '/root/.ssh/id_rsa')
-
- if pwd is not None:
- LOG.debug("Log in via pw, user:%s, host:%s, password:%s",
- user, ip, pwd)
- self.client = ssh.SSH(user, ip, password=pwd, port=ssh_port)
- else:
- LOG.debug("Log in via key, user:%s, host:%s, key_filename:%s",
- user, ip, key_fname)
- self.client = ssh.SSH(user, ip, key_filename=key_fname,
- port=ssh_port)
+ self.client = ssh.SSH.from_node(node, defaults={'user': 'ubuntu'})
self.client.wait(timeout=600)
diff --git a/yardstick/benchmark/core/plugin.py b/yardstick/benchmark/core/plugin.py
index 3080f5dd9..7f67a04b3 100644
--- a/yardstick/benchmark/core/plugin.py
+++ b/yardstick/benchmark/core/plugin.py
@@ -80,33 +80,17 @@ class Plugin(object):
self.script = pkg_resources.resource_filename(
'yardstick.resources', 'scripts/install/' + target_script)
- deployment_user = deployment.get("user")
- deployment_ssh_port = deployment.get("ssh_port", ssh.DEFAULT_PORT)
deployment_ip = deployment.get("ip", None)
- deployment_password = deployment.get("password", None)
- deployment_key_filename = deployment.get("key_filename",
- "/root/.ssh/id_rsa")
if deployment_ip == "local":
- installer_ip = os.environ.get("INSTALLER_IP", None)
-
- if deployment_password is not None:
- self._login_via_password(deployment_user, installer_ip,
- deployment_password,
- deployment_ssh_port)
- else:
- self._login_via_key(self, deployment_user, installer_ip,
- deployment_key_filename,
- deployment_ssh_port)
+ self.client = ssh.SSH.from_node(deployment, overrides={
+ # host can't be None, fail if no INSTALLER_IP
+ 'ip': os.environ["INSTALLER_IP"],
+ })
else:
- if deployment_password is not None:
- self._login_via_password(deployment_user, deployment_ip,
- deployment_password,
- deployment_ssh_port)
- else:
- self._login_via_key(self, deployment_user, deployment_ip,
- deployment_key_filename,
- deployment_ssh_port)
+ self.client = ssh.SSH.from_node(deployment)
+ self.client.wait(timeout=600)
+
# copy script to host
remotepath = '~/%s.sh' % plugin_name
@@ -119,33 +103,16 @@ class Plugin(object):
self.script = pkg_resources.resource_filename(
'yardstick.resources', 'scripts/remove/' + target_script)
- deployment_user = deployment.get("user")
- deployment_ssh_port = deployment.get("ssh_port", ssh.DEFAULT_PORT)
deployment_ip = deployment.get("ip", None)
- deployment_password = deployment.get("password", None)
- deployment_key_filename = deployment.get("key_filename",
- "/root/.ssh/id_rsa")
if deployment_ip == "local":
- installer_ip = os.environ.get("INSTALLER_IP", None)
-
- if deployment_password is not None:
- self._login_via_password(deployment_user, installer_ip,
- deployment_password,
- deployment_ssh_port)
- else:
- self._login_via_key(self, deployment_user, installer_ip,
- deployment_key_filename,
- deployment_ssh_port)
+ self.client = ssh.SSH.from_node(deployment, overrides={
+ # host can't be None, fail if no INSTALLER_IP
+ 'ip': os.environ["INSTALLER_IP"],
+ })
else:
- if deployment_password is not None:
- self._login_via_password(deployment_user, deployment_ip,
- deployment_password,
- deployment_ssh_port)
- else:
- self._login_via_key(self, deployment_user, deployment_ip,
- deployment_key_filename,
- deployment_ssh_port)
+ self.client = ssh.SSH.from_node(deployment)
+ self.client.wait(timeout=600)
# copy script to host
remotepath = '~/%s.sh' % plugin_name
@@ -153,23 +120,12 @@ class Plugin(object):
LOG.info("copying script to host: %s", remotepath)
self.client._put_file_shell(self.script, remotepath)
- def _login_via_password(self, user, ip, password, ssh_port):
- LOG.info("Log in via pw, user:%s, host:%s", user, ip)
- self.client = ssh.SSH(user, ip, password=password, port=ssh_port)
- self.client.wait(timeout=600)
-
- def _login_via_key(self, user, ip, key_filename, ssh_port):
- LOG.info("Log in via key, user:%s, host:%s", user, ip)
- self.client = ssh.SSH(user, ip, key_filename=key_filename,
- port=ssh_port)
- self.client.wait(timeout=600)
-
def _run(self, plugin_name):
"""Run installation script """
cmd = "sudo bash %s" % plugin_name + ".sh"
LOG.info("Executing command: %s", cmd)
- status, stdout, stderr = self.client.execute(cmd)
+ self.client.execute(cmd)
class PluginParser(object):
diff --git a/yardstick/benchmark/scenarios/availability/attacker/attacker_baremetal.py b/yardstick/benchmark/scenarios/availability/attacker/attacker_baremetal.py
index 1d632799d..f7683fd84 100644
--- a/yardstick/benchmark/scenarios/availability/attacker/attacker_baremetal.py
+++ b/yardstick/benchmark/scenarios/availability/attacker/attacker_baremetal.py
@@ -39,16 +39,11 @@ class BaremetalAttacker(BaseAttacker):
def setup(self):
LOG.debug("config:%s context:%s", self._config, self._context)
host = self._context.get(self._config['host'], None)
- ip = host.get("ip", None)
- user = host.get("user", "root")
- ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
- key_filename = host.get("key_filename", "~/.ssh/id_rsa")
- self.connection = ssh.SSH(user, ip, key_filename=key_filename,
- port=ssh_port)
+ self.connection = ssh.SSH.from_node(host, defaults={"user": "root"})
self.connection.wait(timeout=600)
LOG.debug("ssh host success!")
- self.host_ip = ip
+ self.host_ip = host['ip']
self.ipmi_ip = host.get("ipmi_ip", None)
self.ipmi_user = host.get("ipmi_user", "root")
@@ -90,25 +85,24 @@ class BaremetalAttacker(BaseAttacker):
self.jump_connection = None
if jump_host_name is not None:
host = self._context.get(jump_host_name, None)
- ip = host.get("ip", None)
- user = host.get("user", "root")
- ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
- pwd = host.get("pwd", None)
-
- LOG.debug("jump_host ip:%s user:%s", ip, user)
- self.jump_connection = ssh.SSH(user, ip, password=pwd,
- port=ssh_port)
+
+ LOG.debug("jump_host ip:%s user:%s", host['ip'], host['user'])
+ self.jump_connection = ssh.SSH.from_node(
+ host,
+ # why do we allow pwd for password?
+ defaults={"user": "root", "password": host.get("pwd")}
+ )
self.jump_connection.wait(timeout=600)
LOG.debug("ssh jump host success!")
if self.jump_connection is not None:
with open(self.recovery_script, "r") as stdin_file:
- exit_status, stdout, stderr = self.jump_connection.execute(
+ self.jump_connection.execute(
"/bin/bash -s {0} {1} {2} {3}".format(
self.ipmi_ip, self.ipmi_user, self.ipmi_pwd, "on"),
stdin=stdin_file)
else:
- exit_status, stdout = _execute_shell_command(
+ _execute_shell_command(
"/bin/bash -s {0} {1} {2} {3}".format(
self.ipmi_ip, self.ipmi_user, self.ipmi_pwd, "on"),
stdin=open(self.recovery_script, "r"))
diff --git a/yardstick/benchmark/scenarios/availability/attacker/attacker_general.py b/yardstick/benchmark/scenarios/availability/attacker/attacker_general.py
index ab5e99860..35cbccd6e 100644
--- a/yardstick/benchmark/scenarios/availability/attacker/attacker_general.py
+++ b/yardstick/benchmark/scenarios/availability/attacker/attacker_general.py
@@ -24,13 +24,8 @@ class GeneralAttacker(BaseAttacker):
def setup(self):
LOG.debug("config:%s context:%s", self._config, self._context)
host = self._context.get(self._config['host'], None)
- ip = host.get("ip", None)
- user = host.get("user", "root")
- ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
- key_filename = host.get("key_filename", "~/.ssh/id_rsa")
- self.connection = ssh.SSH(user, ip, key_filename=key_filename,
- port=ssh_port)
+ self.connection = ssh.SSH.from_node(host, defaults={"user": "root"})
self.connection.wait(timeout=600)
LOG.debug("ssh host success!")
diff --git a/yardstick/benchmark/scenarios/availability/attacker/attacker_process.py b/yardstick/benchmark/scenarios/availability/attacker/attacker_process.py
index 66934afeb..93375a6dc 100644
--- a/yardstick/benchmark/scenarios/availability/attacker/attacker_process.py
+++ b/yardstick/benchmark/scenarios/availability/attacker/attacker_process.py
@@ -23,13 +23,8 @@ class ProcessAttacker(BaseAttacker):
def setup(self):
LOG.debug("config:%s context:%s", self._config, self._context)
host = self._context.get(self._config['host'], None)
- ip = host.get("ip", None)
- user = host.get("user", "root")
- ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
- key_filename = host.get("key_filename", "~/.ssh/id_rsa")
- self.connection = ssh.SSH(user, ip, key_filename=key_filename,
- port=ssh_port)
+ self.connection = ssh.SSH.from_node(host, defaults={"user": "root"})
self.connection.wait(timeout=600)
LOG.debug("ssh host success!")
diff --git a/yardstick/benchmark/scenarios/availability/monitor/monitor_command.py b/yardstick/benchmark/scenarios/availability/monitor/monitor_command.py
index 084f80225..033a2d721 100644
--- a/yardstick/benchmark/scenarios/availability/monitor/monitor_command.py
+++ b/yardstick/benchmark/scenarios/availability/monitor/monitor_command.py
@@ -42,13 +42,9 @@ class MonitorOpenstackCmd(basemonitor.BaseMonitor):
node_name = self._config.get("host", None)
if node_name:
host = self._context[node_name]
- ip = host.get("ip", None)
- user = host.get("user", "root")
- ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
- key_filename = host.get("key_filename", "~/.ssh/id_rsa")
- self.connection = ssh.SSH(user, ip, key_filename=key_filename,
- port=ssh_port)
+ self.connection = ssh.SSH.from_node(host,
+ defaults={"user": "root"})
self.connection.wait(timeout=600)
LOG.debug("ssh host success!")
diff --git a/yardstick/benchmark/scenarios/availability/monitor/monitor_general.py b/yardstick/benchmark/scenarios/availability/monitor/monitor_general.py
index 78a603193..c6c5a75a1 100644
--- a/yardstick/benchmark/scenarios/availability/monitor/monitor_general.py
+++ b/yardstick/benchmark/scenarios/availability/monitor/monitor_general.py
@@ -24,10 +24,6 @@ class GeneralMonitor(basemonitor.BaseMonitor):
def setup(self):
host = self._context[self._config["host"]]
- ip = host.get("ip", None)
- user = host.get("user", "root")
- ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
- key_filename = host.get("key_filename", "~/.ssh/id_rsa")
self.key = self._config["key"]
self.monitor_key = self._config["monitor_key"]
self.monitor_type = self._config["monitor_type"]
@@ -42,8 +38,7 @@ class GeneralMonitor(basemonitor.BaseMonitor):
self.monitor_key)
self.monitor_script = self.get_script_fullpath(
self.monitor_cfg['monitor_script'])
- self.connection = ssh.SSH(user, ip, key_filename=key_filename,
- port=ssh_port)
+ self.connection = ssh.SSH.from_node(host, defaults={"user": "root"})
self.connection.wait(timeout=600)
LOG.debug("ssh host success!")
diff --git a/yardstick/benchmark/scenarios/availability/monitor/monitor_process.py b/yardstick/benchmark/scenarios/availability/monitor/monitor_process.py
index 91b6ba31a..ca5cac1ff 100644
--- a/yardstick/benchmark/scenarios/availability/monitor/monitor_process.py
+++ b/yardstick/benchmark/scenarios/availability/monitor/monitor_process.py
@@ -22,13 +22,8 @@ class MonitorProcess(basemonitor.BaseMonitor):
def setup(self):
host = self._context[self._config["host"]]
- ip = host.get("ip", None)
- user = host.get("user", "root")
- ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
- key_filename = host.get("key_filename", "~/.ssh/id_rsa")
- self.connection = ssh.SSH(user, ip, key_filename=key_filename,
- port=ssh_port)
+ self.connection = ssh.SSH.from_node(host, defaults={"user": "root"})
self.connection.wait(timeout=600)
LOG.debug("ssh host success!")
self.check_script = self.get_script_fullpath(
diff --git a/yardstick/benchmark/scenarios/availability/operation/operation_general.py b/yardstick/benchmark/scenarios/availability/operation/operation_general.py
index bfd7d04b0..49c63cc75 100644
--- a/yardstick/benchmark/scenarios/availability/operation/operation_general.py
+++ b/yardstick/benchmark/scenarios/availability/operation/operation_general.py
@@ -26,13 +26,8 @@ class GeneralOperaion(BaseOperation):
def setup(self):
LOG.debug("config:%s context:%s", self._config, self._context)
host = self._context.get(self._config['host'], None)
- ip = host.get("ip", None)
- user = host.get("user", "root")
- ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
- key_filename = host.get("key_filename", "~/.ssh/id_rsa")
- self.connection = ssh.SSH(user, ip, key_filename=key_filename,
- port=ssh_port)
+ self.connection = ssh.SSH.from_node(host, defaults={"user": "root"})
self.connection.wait(timeout=600)
LOG.debug("ssh host success!")
diff --git a/yardstick/benchmark/scenarios/availability/result_checker/result_checker_general.py b/yardstick/benchmark/scenarios/availability/result_checker/result_checker_general.py
index 8f987a647..ff6017b88 100644
--- a/yardstick/benchmark/scenarios/availability/result_checker/result_checker_general.py
+++ b/yardstick/benchmark/scenarios/availability/result_checker/result_checker_general.py
@@ -26,13 +26,8 @@ class GeneralResultChecker(BaseResultChecker):
def setup(self):
LOG.debug("config:%s context:%s", self._config, self._context)
host = self._context.get(self._config['host'], None)
- ip = host.get("ip", None)
- user = host.get("user", "root")
- ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
- key_filename = host.get("key_filename", "~/.ssh/id_rsa")
- self.connection = ssh.SSH(user, ip, key_filename=key_filename,
- port=ssh_port)
+ self.connection = ssh.SSH.from_node(host, defaults={"user": "root"})
self.connection.wait(timeout=600)
LOG.debug("ssh host success!")
diff --git a/yardstick/benchmark/scenarios/compute/cachestat.py b/yardstick/benchmark/scenarios/compute/cachestat.py
index 8873b9683..40f6ed773 100644
--- a/yardstick/benchmark/scenarios/compute/cachestat.py
+++ b/yardstick/benchmark/scenarios/compute/cachestat.py
@@ -76,14 +76,8 @@ class CACHEstat(base.Scenario):
CACHEstat.TARGET_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
diff --git a/yardstick/benchmark/scenarios/compute/computecapacity.py b/yardstick/benchmark/scenarios/compute/computecapacity.py
index 9d518f7a0..688661c5f 100644
--- a/yardstick/benchmark/scenarios/compute/computecapacity.py
+++ b/yardstick/benchmark/scenarios/compute/computecapacity.py
@@ -42,13 +42,9 @@ class ComputeCapacity(base.Scenario):
nodes = self.context_cfg['nodes']
node = nodes.get('host', None)
- host_user = node.get('user', 'ubuntu')
- ssh_port = node.get('ssh_port', ssh.DEFAULT_PORT)
- host_ip = node.get('ip', None)
- host_pwd = node.get('password', 'root')
- LOG.debug("user:%s, host:%s", host_user, host_ip)
- self.client = ssh.SSH(host_user, host_ip, password=host_pwd,
- port=ssh_port)
+ self.client = ssh.SSH.from_node(node, defaults={
+ "user": "ubuntu", "password": "root"
+ })
self.client.wait(timeout=600)
# copy script to host
diff --git a/yardstick/benchmark/scenarios/compute/cpuload.py b/yardstick/benchmark/scenarios/compute/cpuload.py
index 121d5a75d..c65396185 100644
--- a/yardstick/benchmark/scenarios/compute/cpuload.py
+++ b/yardstick/benchmark/scenarios/compute/cpuload.py
@@ -68,14 +68,8 @@ class CPULoad(base.Scenario):
def setup(self):
"""Scenario setup."""
host = self.context_cfg['host']
- user = host.get('user', 'ubuntu')
- ip = host.get('ip', None)
- ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
- 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)
# Check if mpstat prog is installed
diff --git a/yardstick/benchmark/scenarios/compute/cyclictest.py b/yardstick/benchmark/scenarios/compute/cyclictest.py
index 9ca3a8a37..594c6091e 100644
--- a/yardstick/benchmark/scenarios/compute/cyclictest.py
+++ b/yardstick/benchmark/scenarios/compute/cyclictest.py
@@ -85,24 +85,17 @@ class Cyclictest(base.Scenario):
def _connect_host(self):
host = self.context_cfg["host"]
- user = host.get("user", "root")
- ip = host.get("ip", None)
- key_filename = host.get("key_filename", "~/.ssh/id_rsa")
- LOG.debug("user:%s, host:%s", user, ip)
- self.host = ssh.SSH(user, ip, key_filename=key_filename)
+ self.host = ssh.SSH.from_node(host, defaults={"user": "root"})
self.host.wait(timeout=600)
def _connect_guest(self):
host = self.context_cfg["host"]
- user = host.get("user", "root")
- ip = host.get("ip", None)
- ssh_port = host.get("ssh_port", 5555)
- key_filename = host.get("key_filename", "~/.ssh/id_rsa")
-
- LOG.debug("user:%s, host:%s", user, ip)
- self.guest = ssh.SSH(user, ip, port=ssh_port,
- key_filename=key_filename)
+ # why port 5555?
+ self.guest = ssh.SSH.from_node(host,
+ defaults={
+ "user": "root", "ssh_port": 5555
+ })
self.guest.wait(timeout=600)
def _run_setup_cmd(self, client, cmd):
diff --git a/yardstick/benchmark/scenarios/compute/lmbench.py b/yardstick/benchmark/scenarios/compute/lmbench.py
index 6a17ae8a1..c99fc988d 100644
--- a/yardstick/benchmark/scenarios/compute/lmbench.py
+++ b/yardstick/benchmark/scenarios/compute/lmbench.py
@@ -80,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
diff --git a/yardstick/benchmark/scenarios/compute/memload.py b/yardstick/benchmark/scenarios/compute/memload.py
index 2ef5a6302..93d10c0b5 100644
--- a/yardstick/benchmark/scenarios/compute/memload.py
+++ b/yardstick/benchmark/scenarios/compute/memload.py
@@ -49,14 +49,8 @@ class MEMLoad(base.Scenario):
def setup(self):
"""Scenario setup."""
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)
self.setup_done = True
diff --git a/yardstick/benchmark/scenarios/compute/perf.py b/yardstick/benchmark/scenarios/compute/perf.py
index ae4990688..0b8ed9b28 100644
--- a/yardstick/benchmark/scenarios/compute/perf.py
+++ b/yardstick/benchmark/scenarios/compute/perf.py
@@ -50,14 +50,8 @@ class Perf(base.Scenario):
self.target_script = pkg_resources.resource_filename(
'yardstick.benchmark.scenarios.compute', Perf.TARGET_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 script to host
diff --git a/yardstick/benchmark/scenarios/compute/plugintest.py b/yardstick/benchmark/scenarios/compute/plugintest.py
index c9d025964..0ddf6b4a2 100644
--- a/yardstick/benchmark/scenarios/compute/plugintest.py
+++ b/yardstick/benchmark/scenarios/compute/plugintest.py
@@ -32,13 +32,10 @@ class PluginTest(base.Scenario):
nodes = self.context_cfg['nodes']
node = nodes.get('host1', None)
- host_user = node.get('user', 'ubuntu')
- host_ssh_port = node.get('ssh_port', ssh.DEFAULT_PORT)
- host_ip = node.get('ip', None)
- host_pwd = node.get('password', 'root')
- LOG.debug("user:%s, host:%s", host_user, host_ip)
- self.client = ssh.SSH(host_user, host_ip, password=host_pwd,
- port=host_ssh_port)
+
+ self.client = ssh.SSH.from_node(node, defaults={
+ "user": "ubuntu", "password": "root"
+ })
self.client.wait(timeout=600)
self.setup_done = True
diff --git a/yardstick/benchmark/scenarios/compute/ramspeed.py b/yardstick/benchmark/scenarios/compute/ramspeed.py
index 4330202de..850ee5934 100644
--- a/yardstick/benchmark/scenarios/compute/ramspeed.py
+++ b/yardstick/benchmark/scenarios/compute/ramspeed.py
@@ -89,14 +89,8 @@ class Ramspeed(base.Scenario):
Ramspeed.RAMSPEED_MEM_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
diff --git a/yardstick/benchmark/scenarios/compute/unixbench.py b/yardstick/benchmark/scenarios/compute/unixbench.py
index 4a2eb9766..cdb345717 100644
--- a/yardstick/benchmark/scenarios/compute/unixbench.py
+++ b/yardstick/benchmark/scenarios/compute/unixbench.py
@@ -70,14 +70,8 @@ class Unixbench(base.Scenario):
Unixbench.TARGET_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
diff --git a/yardstick/benchmark/scenarios/networking/iperf3.py b/yardstick/benchmark/scenarios/networking/iperf3.py
index 4d4c7e7ee..334f3a920 100644
--- a/yardstick/benchmark/scenarios/networking/iperf3.py
+++ b/yardstick/benchmark/scenarios/networking/iperf3.py
@@ -59,25 +59,14 @@ For more info see http://software.es.net/iperf
def setup(self):
host = self.context_cfg['host']
- host_user = host.get('user', 'ubuntu')
- host_ssh_port = host.get('ssh_port', ssh.DEFAULT_PORT)
- 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_ssh_port = target.get('ssh_port', ssh.DEFAULT_PORT)
- target_ip = target.get('ip', None)
- target_key_filename = target.get('key_filename', '~/.ssh/id_rsa')
-
- LOG.info("user:%s, target:%s", target_user, target_ip)
- self.target = ssh.SSH(target_user, target_ip,
- key_filename=target_key_filename,
- port=target_ssh_port)
+
+ LOG.info("user:%s, target:%s", target['user'], target['ip'])
+ self.target = ssh.SSH.from_node(target, defaults={"user": "ubuntu"})
self.target.wait(timeout=600)
- LOG.info("user:%s, host:%s", host_user, host_ip)
- self.host = ssh.SSH(host_user, host_ip,
- key_filename=host_key_filename, port=host_ssh_port)
+ LOG.info("user:%s, host:%s", host['user'], host['ip'])
+ self.host = ssh.SSH.from_node(host, defaults={"user": "ubuntu"})
self.host.wait(timeout=600)
cmd = "iperf3 -s -D"
diff --git a/yardstick/benchmark/scenarios/networking/netperf.py b/yardstick/benchmark/scenarios/networking/netperf.py
index d0528826f..08d5dd166 100755
--- a/yardstick/benchmark/scenarios/networking/netperf.py
+++ b/yardstick/benchmark/scenarios/networking/netperf.py
@@ -65,27 +65,15 @@ class Netperf(base.Scenario):
'yardstick.benchmark.scenarios.networking',
Netperf.TARGET_SCRIPT)
host = self.context_cfg['host']
- host_user = host.get('user', 'ubuntu')
- host_ssh_port = host.get('ssh_port', ssh.DEFAULT_PORT)
- 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_ssh_port = target.get('ssh_port', ssh.DEFAULT_PORT)
- 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,
- port=target_ssh_port)
+ 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,
- port=host_ssh_port)
+ 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
diff --git a/yardstick/benchmark/scenarios/networking/netperf_node.py b/yardstick/benchmark/scenarios/networking/netperf_node.py
index fd9fa0a50..d52e6b9e1 100755
--- a/yardstick/benchmark/scenarios/networking/netperf_node.py
+++ b/yardstick/benchmark/scenarios/networking/netperf_node.py
@@ -66,27 +66,16 @@ class NetperfNode(base.Scenario):
'yardstick.benchmark.scenarios.networking',
NetperfNode.TARGET_SCRIPT)
host = self.context_cfg['host']
- host_user = host.get('user', 'ubuntu')
- host_ssh_port = host.get('ssh_port', ssh.DEFAULT_PORT)
- host_ip = host.get('ip', None)
target = self.context_cfg['target']
- target_user = target.get('user', 'ubuntu')
- target_ssh_port = target.get('ssh_port', ssh.DEFAULT_PORT)
- target_ip = target.get('ip', None)
- self.target_ip = target.get('ip', None)
- host_password = host.get('password', None)
- target_password = target.get('password', None)
-
- LOG.info("host_pw:%s, target_pw:%s", host_password, target_password)
+ self.target_ip = target['ip']
+
# 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,
- password=target_password, port=target_ssh_port)
+ 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,
- password=host_password, port=host_ssh_port)
+ 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
diff --git a/yardstick/benchmark/scenarios/networking/netutilization.py b/yardstick/benchmark/scenarios/networking/netutilization.py
index 37da7f895..cecb64fa0 100644
--- a/yardstick/benchmark/scenarios/networking/netutilization.py
+++ b/yardstick/benchmark/scenarios/networking/netutilization.py
@@ -71,14 +71,8 @@ class NetUtilization(base.Scenario):
def setup(self):
"""Scenario setup."""
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)
self.setup_done = True
diff --git a/yardstick/benchmark/scenarios/networking/networkcapacity.py b/yardstick/benchmark/scenarios/networking/networkcapacity.py
index e7ce83570..63634061c 100644
--- a/yardstick/benchmark/scenarios/networking/networkcapacity.py
+++ b/yardstick/benchmark/scenarios/networking/networkcapacity.py
@@ -42,14 +42,8 @@ class NetworkCapacity(base.Scenario):
host = self.context_cfg['host']
if host is None:
raise RuntimeError('No right node.please check the configuration')
- host_user = host.get('user', 'ubuntu')
- ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
- host_ip = host.get('ip', None)
- host_pwd = host.get('password', None)
-
- LOG.debug("user:%s, host:%s", host_user, host_ip)
- self.client = ssh.SSH(host_user, host_ip, password=host_pwd,
- port=ssh_port)
+
+ self.client = ssh.SSH.from_node(host, defaults={"user": "ubuntu"})
self.client.wait(timeout=600)
# copy script to host
diff --git a/yardstick/benchmark/scenarios/networking/nstat.py b/yardstick/benchmark/scenarios/networking/nstat.py
index df96dbda7..10c560769 100644
--- a/yardstick/benchmark/scenarios/networking/nstat.py
+++ b/yardstick/benchmark/scenarios/networking/nstat.py
@@ -36,14 +36,8 @@ class Nstat(base.Scenario):
def setup(self):
"""scenario setup"""
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)
self.setup_done = True
diff --git a/yardstick/benchmark/scenarios/networking/ping.py b/yardstick/benchmark/scenarios/networking/ping.py
index d20814697..95367b3bb 100644
--- a/yardstick/benchmark/scenarios/networking/ping.py
+++ b/yardstick/benchmark/scenarios/networking/ping.py
@@ -40,22 +40,8 @@ class Ping(base.Scenario):
self.target_script = pkg_resources.resource_filename(
'yardstick.benchmark.scenarios.networking', Ping.TARGET_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', '/root/.ssh/id_rsa')
- password = host.get('password', None)
-
- if password is not None:
- LOG.info("Log in via pw, user:%s, host:%s, pw:%s",
- user, ip, password)
- self.connection = ssh.SSH(user, ip, password=password,
- port=ssh_port)
- else:
- LOG.info("Log in via key, user:%s, host:%s, key_filename:%s",
- user, ip, key_filename)
- self.connection = ssh.SSH(user, ip, key_filename=key_filename,
- port=ssh_port)
+
+ self.connection = ssh.SSH.from_node(host, defaults={"user": "ubuntu"})
self.connection.wait(timeout=600)
diff --git a/yardstick/benchmark/scenarios/networking/ping6.py b/yardstick/benchmark/scenarios/networking/ping6.py
index 142a35664..74855a10f 100644
--- a/yardstick/benchmark/scenarios/networking/ping6.py
+++ b/yardstick/benchmark/scenarios/networking/ping6.py
@@ -51,20 +51,7 @@ class Ping6(base.Scenario): # pragma: no cover
def _ssh_host(self, node_name):
# ssh host
node = self.nodes.get(node_name, None)
- user = node.get('user', 'ubuntu')
- ssh_port = node.get("ssh_port", ssh.DEFAULT_PORT)
- ip = node.get('ip', None)
- pwd = node.get('password', None)
- key_fname = node.get('key_filename', '/root/.ssh/id_rsa')
- if pwd is not None:
- LOG.debug("Log in via pw, user:%s, host:%s, password:%s",
- user, ip, pwd)
- self.client = ssh.SSH(user, ip, password=pwd, port=ssh_port)
- else:
- LOG.debug("Log in via key, user:%s, host:%s, key_filename:%s",
- user, ip, key_fname)
- self.client = ssh.SSH(user, ip, key_filename=key_fname,
- port=ssh_port)
+ self.client = ssh.SSH.from_node(node, defaults={"user": "ubuntu"})
self.client.wait(timeout=60)
def _pre_setup(self):
diff --git a/yardstick/benchmark/scenarios/networking/pktgen.py b/yardstick/benchmark/scenarios/networking/pktgen.py
index 9a8725cfd..e6aa7e5fb 100644
--- a/yardstick/benchmark/scenarios/networking/pktgen.py
+++ b/yardstick/benchmark/scenarios/networking/pktgen.py
@@ -52,26 +52,14 @@ class Pktgen(base.Scenario):
'yardstick.benchmark.scenarios.networking',
Pktgen.TARGET_SCRIPT)
host = self.context_cfg['host']
- host_user = host.get('user', 'ubuntu')
- host_ssh_port = host.get('ssh_port', ssh.DEFAULT_PORT)
- 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_ssh_port = target.get('ssh_port', ssh.DEFAULT_PORT)
- target_ip = target.get('ip', None)
- target_key_filename = target.get('key_filename', '~/.ssh/id_rsa')
-
- LOG.info("user:%s, target:%s", target_user, target_ip)
- self.server = ssh.SSH(target_user, target_ip,
- key_filename=target_key_filename,
- port=target_ssh_port)
+
+ 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,
- port=host_ssh_port)
+ 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
diff --git a/yardstick/benchmark/scenarios/networking/pktgen_dpdk.py b/yardstick/benchmark/scenarios/networking/pktgen_dpdk.py
index 7e3044dbb..f57ca843a 100644
--- a/yardstick/benchmark/scenarios/networking/pktgen_dpdk.py
+++ b/yardstick/benchmark/scenarios/networking/pktgen_dpdk.py
@@ -45,28 +45,16 @@ class PktgenDPDKLatency(base.Scenario):
'yardstick.benchmark.scenarios.networking',
PktgenDPDKLatency.TESTPMD_SCRIPT)
host = self.context_cfg['host']
- host_user = host.get('user', 'ubuntu')
- host_ssh_port = host.get('ssh_port', ssh.DEFAULT_PORT)
- 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_ssh_port = target.get('ssh_port', ssh.DEFAULT_PORT)
- target_ip = target.get('ip', None)
- target_key_filename = target.get('key_filename', '~/.ssh/id_rsa')
- LOG.info("user:%s, target:%s", target_user, target_ip)
- self.server = ssh.SSH(target_user, target_ip,
- key_filename=target_key_filename,
- port=target_ssh_port)
+ 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)
# copy script to host
self.server._put_file_shell(self.testpmd_script, '~/testpmd_fwd.sh')
- LOG.info("user:%s, host:%s", host_user, host_ip)
- self.client = ssh.SSH(host_user, host_ip,
- key_filename=host_key_filename,
- port=host_ssh_port)
+ 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
diff --git a/yardstick/benchmark/scenarios/networking/sfc.py b/yardstick/benchmark/scenarios/networking/sfc.py
index bf4ed5f7c..c682082d9 100644
--- a/yardstick/benchmark/scenarios/networking/sfc.py
+++ b/yardstick/benchmark/scenarios/networking/sfc.py
@@ -53,15 +53,12 @@ class Sfc(base.Scenario): # pragma: no cover
subprocess.call(cmd_tacker, shell=True)
target = self.context_cfg['target']
- target_user = target.get('user', 'root')
- target_ssh_port = target.get('ssh_port', ssh.DEFAULT_PORT)
- target_pwd = target.get('password', 'opnfv')
- target_ip = target.get('ip', None)
""" webserver start automatically during the vm boot """
- LOG.info("user:%s, target:%s", target_user, target_ip)
- self.server = ssh.SSH(target_user, target_ip, password=target_pwd,
- port=target_ssh_port)
+ LOG.info("user:%s, target:%s", target['user'], target['ip'])
+ self.server = ssh.SSH.from_node(target, defaults={
+ "user": "root", "password": "opnfv"
+ })
self.server.wait(timeout=600)
self.server._put_file_shell(self.server_script, '~/server.sh')
cmd_server = "sudo bash server.sh"
@@ -72,36 +69,35 @@ class Sfc(base.Scenario): # pragma: no cover
ips = sfc_openstack.get_an_IP()
target = self.context_cfg['target']
- SF1_user = target.get('user', 'root')
- SF1_ssh_port = target.get('ssh_port', ssh.DEFAULT_PORT)
- SF1_pwd = target.get('password', 'opnfv')
- SF1_ip = ips[0]
-
- LOG.info("user:%s, host:%s", SF1_user, SF1_ip)
- self.server = ssh.SSH(SF1_user, SF1_ip, password=SF1_pwd,
- port=SF1_ssh_port)
+
+ LOG.info("user:%s, target:%s", target['user'], target['ip'])
+ self.server = ssh.SSH.from_node(
+ target,
+ defaults={"user": "root", "password": "opnfv"},
+ # we must override ip
+ overrides={"ip": ips[0]}
+ )
self.server.wait(timeout=600)
cmd_SF1 = ("nohup python vxlan_tool.py -i eth0 "
"-d forward -v off -b 80 &")
LOG.debug("Starting HTTP firewall in SF1")
- status, stdout, stderr = self.server.execute(cmd_SF1)
+ self.server.execute(cmd_SF1)
result = self.server.execute("ps lax | grep python")
if "vxlan_tool.py" in result[1]: # pragma: no cover
LOG.debug("HTTP firewall started")
- SF2_user = target.get('user', 'root')
- SF2_ssh_port = target.get('ssh_port', ssh.DEFAULT_PORT)
- SF2_pwd = target.get('password', 'opnfv')
- SF2_ip = ips[1]
-
- LOG.info("user:%s, host:%s", SF2_user, SF2_ip)
- self.server = ssh.SSH(SF2_user, SF2_ip, password=SF2_pwd,
- port=SF2_ssh_port)
+ LOG.info("user:%s, target:%s", target['user'], target['ip'])
+ self.server = ssh.SSH.from_node(
+ target,
+ defaults={"user": "root", "password": "opnfv"},
+ # we must override ip
+ overrides={"ip": ips[1]}
+ )
self.server.wait(timeout=600)
cmd_SF2 = ("nohup python vxlan_tool.py -i eth0 "
"-d forward -v off -b 22 &")
LOG.debug("Starting SSH firewall in SF2")
- status, stdout, stderr = self.server.execute(cmd_SF2)
+ self.server.execute(cmd_SF2)
result = self.server.execute("ps lax | grep python")
if "vxlan_tool.py" in result[1]: # pragma: no cover
@@ -112,14 +108,11 @@ class Sfc(base.Scenario): # pragma: no cover
def run(self, result):
""" Creating client and server VMs to perform the test"""
host = self.context_cfg['host']
- host_user = host.get('user', 'root')
- ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
- host_pwd = host.get('password', 'opnfv')
- host_ip = host.get('ip', None)
-
- LOG.info("user:%s, host:%s", host_user, host_ip)
- self.client = ssh.SSH(host_user, host_ip, password=host_pwd,
- port=ssh_port)
+
+ LOG.info("user:%s, host:%s", host['user'], host['ip'])
+ self.client = ssh.SSH.from_node(host, defaults={
+ "user": "root", "password": "opnfv"
+ })
self.client.wait(timeout=600)
if not self.setup_done: # pragma: no cover
diff --git a/yardstick/benchmark/scenarios/networking/vnf_generic.py b/yardstick/benchmark/scenarios/networking/vnf_generic.py
index 447c550ed..be179631e 100644
--- a/yardstick/benchmark/scenarios/networking/vnf_generic.py
+++ b/yardstick/benchmark/scenarios/networking/vnf_generic.py
@@ -60,13 +60,9 @@ class SshManager(object):
returns -> ssh connection ready to be used
"""
try:
- ssh_port = self.node.get("ssh_port", ssh.DEFAULT_PORT)
- self.conn = ssh.SSH(user=self.node["user"],
- host=self.node["ip"],
- password=self.node["password"],
- port=ssh_port)
+ self.conn = ssh.SSH.from_node(self.node)
self.conn.wait()
- except (SSHError) as error:
+ except SSHError as error:
LOG.info("connect failed to %s, due to %s", self.node["ip"], error)
# self.conn defaults to None
return self.conn
diff --git a/yardstick/benchmark/scenarios/networking/vsperf.py b/yardstick/benchmark/scenarios/networking/vsperf.py
index f2c2ea9b8..705544c41 100644
--- a/yardstick/benchmark/scenarios/networking/vsperf.py
+++ b/yardstick/benchmark/scenarios/networking/vsperf.py
@@ -114,10 +114,6 @@ class Vsperf(base.Scenario):
def setup(self):
"""scenario setup"""
vsperf = self.context_cfg['host']
- vsperf_user = vsperf.get('user', 'ubuntu')
- vsperf_ssh_port = vsperf.get('ssh_port', ssh.DEFAULT_PORT)
- vsperf_password = vsperf.get('password', 'ubuntu')
- vsperf_ip = vsperf.get('ip', None)
# add trafficgen interfaces to the external bridge
if self.tg_port1:
@@ -128,9 +124,9 @@ class Vsperf(base.Scenario):
(self.br_ex, self.tg_port2), shell=True)
# copy vsperf conf to VM
- LOG.info("user:%s, host:%s", vsperf_user, vsperf_ip)
- self.client = ssh.SSH(vsperf_user, vsperf_ip,
- password=vsperf_password, port=vsperf_ssh_port)
+ self.client = ssh.SSH.from_node(vsperf, defaults={
+ "user": "ubuntu", "password": "ubuntu"
+ })
# traffic generation could last long
self.client.wait(timeout=1800)
diff --git a/yardstick/benchmark/scenarios/storage/fio.py b/yardstick/benchmark/scenarios/storage/fio.py
index e28bd7bcc..ad34817a7 100644
--- a/yardstick/benchmark/scenarios/storage/fio.py
+++ b/yardstick/benchmark/scenarios/storage/fio.py
@@ -63,14 +63,8 @@ class Fio(base.Scenario):
"yardstick.benchmark.scenarios.storage",
Fio.TARGET_SCRIPT)
host = self.context_cfg["host"]
- user = host.get("user", "root")
- 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": "root"})
self.client.wait(timeout=600)
# copy script to host
diff --git a/yardstick/benchmark/scenarios/storage/storagecapacity.py b/yardstick/benchmark/scenarios/storage/storagecapacity.py
index c437f22c0..b6c403f47 100644
--- a/yardstick/benchmark/scenarios/storage/storagecapacity.py
+++ b/yardstick/benchmark/scenarios/storage/storagecapacity.py
@@ -57,14 +57,10 @@ class StorageCapacity(base.Scenario):
host = self.context_cfg['host']
if host is None:
raise RuntimeError('No right node.Please check the configuration')
- host_user = host.get('user', 'ubuntu')
- ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
- host_ip = host.get('ip', None)
- host_pwd = host.get('password', 'root')
- LOG.debug("user:%s, host:%s", host_user, host_ip)
-
- self.client = ssh.SSH(host_user, host_ip, password=host_pwd,
- port=ssh_port)
+
+ self.client = ssh.SSH.from_node(host, defaults={
+ "user": "ubuntu", "password": "root"
+ })
self.client.wait(timeout=600)
# copy script to host
diff --git a/yardstick/network_services/nfvi/resource.py b/yardstick/network_services/nfvi/resource.py
index d71e1e995..18b0d8952 100644
--- a/yardstick/network_services/nfvi/resource.py
+++ b/yardstick/network_services/nfvi/resource.py
@@ -40,13 +40,11 @@ class ResourceProfile(object):
self.cores = cores
mgmt_interface = vnfd.get("mgmt-interface")
- user = mgmt_interface.get("user")
- passwd = mgmt_interface.get("password")
- ip_addr = mgmt_interface.get("ip")
- self.vnfip = mgmt_interface.get("host", ip_addr)
- ssh_port = mgmt_interface.get("ssh_port", ssh.DEFAULT_PORT)
- self.connection = ssh.SSH(user, self.vnfip,
- password=passwd, port=ssh_port)
+ # why the host or ip?
+ self.vnfip = mgmt_interface.get("host", mgmt_interface["ip"])
+ self.connection = ssh.SSH.from_node(mgmt_interface,
+ overrides={"ip": self.vnfip})
+
self.connection.wait()
def check_if_sa_running(self, process):
diff --git a/yardstick/network_services/vnf_generic/vnf/tg_ping.py b/yardstick/network_services/vnf_generic/vnf/tg_ping.py
index 2844a5c01..000a91db4 100644
--- a/yardstick/network_services/vnf_generic/vnf/tg_ping.py
+++ b/yardstick/network_services/vnf_generic/vnf/tg_ping.py
@@ -69,12 +69,7 @@ class PingTrafficGen(GenericTrafficGen):
self._traffic_process = None
mgmt_interface = vnfd["mgmt-interface"]
- ssh_port = mgmt_interface.get("ssh_port", ssh.DEFAULT_PORT)
- LOG.debug("Connecting to %s", mgmt_interface["ip"])
-
- self.connection = ssh.SSH(mgmt_interface["user"], mgmt_interface["ip"],
- password=mgmt_interface["password"],
- port=ssh_port)
+ self.connection = ssh.SSH.from_node(mgmt_interface)
self.connection.wait()
def _bind_device_kernel(self, connection):
@@ -130,10 +125,7 @@ class PingTrafficGen(GenericTrafficGen):
def _traffic_runner(self, traffic_profile, filewrapper):
mgmt_interface = self.vnfd["mgmt-interface"]
- ssh_port = mgmt_interface.get("ssh_port", ssh.DEFAULT_PORT)
- self.connection = ssh.SSH(mgmt_interface["user"], mgmt_interface["ip"],
- password=mgmt_interface["password"],
- port=ssh_port)
+ self.connection = ssh.SSH.from_node(mgmt_interface)
self.connection.wait()
external_interface = self.vnfd["vdu"][0]["external-interface"]
virtual_interface = external_interface[0]["virtual-interface"]
diff --git a/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_trex.py b/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_trex.py
index 37c1a7345..7da4b31e9 100644
--- a/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_trex.py
+++ b/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_trex.py
@@ -55,10 +55,8 @@ class TrexTrafficGenRFC(GenericTrafficGen):
self.my_ports = None
mgmt_interface = self.vnfd["mgmt-interface"]
- ssh_port = mgmt_interface.get("ssh_port", ssh.DEFAULT_PORT)
- self.connection = ssh.SSH(mgmt_interface["user"], mgmt_interface["ip"],
- password=mgmt_interface["password"],
- port=ssh_port)
+
+ self.connection = ssh.SSH.from_node(mgmt_interface)
self.connection.wait()
@classmethod
@@ -166,10 +164,8 @@ class TrexTrafficGenRFC(GenericTrafficGen):
def _start_server(self):
mgmt_interface = self.vnfd["mgmt-interface"]
- ssh_port = mgmt_interface.get("ssh_port", ssh.DEFAULT_PORT)
- _server = ssh.SSH(mgmt_interface["user"], mgmt_interface["ip"],
- password=mgmt_interface["password"],
- port=ssh_port)
+
+ _server = ssh.SSH.from_node(mgmt_interface)
_server.wait()
_server.execute("fuser -n tcp %s %s -k > /dev/null 2>&1" %
diff --git a/yardstick/network_services/vnf_generic/vnf/tg_trex.py b/yardstick/network_services/vnf_generic/vnf/tg_trex.py
index 2731476e0..61182a23b 100644
--- a/yardstick/network_services/vnf_generic/vnf/tg_trex.py
+++ b/yardstick/network_services/vnf_generic/vnf/tg_trex.py
@@ -52,12 +52,9 @@ class TrexTrafficGen(GenericTrafficGen):
self.my_ports = None
self.client_started = multiprocessing.Value('i', 0)
- mgmt_interface = self.vnfd["mgmt-interface"]
- ssh_port = mgmt_interface.get("ssh_port", ssh.DEFAULT_PORT)
- self.connection = ssh.SSH(mgmt_interface["user"],
- mgmt_interface["ip"],
- password=mgmt_interface["password"],
- port=ssh_port)
+ mgmt_interface = vnfd["mgmt-interface"]
+
+ self.connection = ssh.SSH.from_node(mgmt_interface)
self.connection.wait()
@classmethod
@@ -198,10 +195,8 @@ class TrexTrafficGen(GenericTrafficGen):
def _start_server(self):
mgmt_interface = self.vnfd["mgmt-interface"]
- ssh_port = mgmt_interface.get("ssh_port", ssh.DEFAULT_PORT)
- _server = ssh.SSH(mgmt_interface["user"], mgmt_interface["ip"],
- password=mgmt_interface["password"],
- port=ssh_port)
+
+ _server = ssh.SSH.from_node(mgmt_interface)
_server.wait()
_server.execute("fuser -n tcp %s %s -k > /dev/null 2>&1" %
diff --git a/yardstick/network_services/vnf_generic/vnf/vpe_vnf.py b/yardstick/network_services/vnf_generic/vnf/vpe_vnf.py
index 8c766f01e..e9e80bdfb 100644
--- a/yardstick/network_services/vnf_generic/vnf/vpe_vnf.py
+++ b/yardstick/network_services/vnf_generic/vnf/vpe_vnf.py
@@ -120,14 +120,11 @@ class VpeApproxVnf(GenericVNF):
def instantiate(self, scenario_cfg, context_cfg):
vnf_cfg = scenario_cfg['vnf_options']['vpe']['cfg']
- mgmt_interface = self.vnfd["mgmt-interface"]
- ssh_port = mgmt_interface.get("ssh_port", ssh.DEFAULT_PORT)
- self.connection = ssh.SSH(mgmt_interface["user"], mgmt_interface["ip"],
- password=mgmt_interface["password"],
- port=ssh_port)
+ mgmt_interface = self.vnfd["mgmt-interface"]
+ self.connection = ssh.SSH.from_node(mgmt_interface)
- self.connection.wait()
+ self.tc_file_name = '{0}.yaml'.format(scenario_cfg['tc'])
self.setup_vnf_environment(self.connection)
@@ -189,11 +186,10 @@ class VpeApproxVnf(GenericVNF):
def _run_vpe(self, filewrapper, vnf_cfg):
mgmt_interface = self.vnfd["mgmt-interface"]
- ssh_port = mgmt_interface.get("ssh_port", ssh.DEFAULT_PORT)
- self.connection = ssh.SSH(mgmt_interface["user"], mgmt_interface["ip"],
- password=mgmt_interface["password"],
- port=ssh_port)
+
+ self.connection = ssh.SSH.from_node(mgmt_interface)
self.connection.wait()
+
interfaces = self.vnfd["vdu"][0]['external-interface']
port0_ip = ipaddress.ip_interface(six.text_type(
"%s/%s" % (interfaces[0]["virtual-interface"]["local_ip"],
diff --git a/yardstick/network_services/vnf_generic/vnfdgen.py b/yardstick/network_services/vnf_generic/vnfdgen.py
index 64554cdaf..97dd97198 100644
--- a/yardstick/network_services/vnf_generic/vnfdgen.py
+++ b/yardstick/network_services/vnf_generic/vnfdgen.py
@@ -28,7 +28,9 @@ def generate_vnfd(vnf_model, node):
:return: Complete VNF Descriptor that will be taken
as input for GenericVNF.__init__
"""
+ # get is unused as global method inside template
node["get"] = get
+ # Set Node details to default if not defined in pod file
rendered_vnfd = TaskTemplate.render(vnf_model, **node)
# This is done to get rid of issues with serializing node
del node["get"]
diff --git a/yardstick/ssh.py b/yardstick/ssh.py
index cfbc3ca96..cf9adf0dc 100644
--- a/yardstick/ssh.py
+++ b/yardstick/ssh.py
@@ -70,13 +70,15 @@ import time
import re
import logging
+
import paramiko
+from chainmap import ChainMap
from oslo_utils import encodeutils
from scp import SCPClient
import six
-DEFAULT_PORT = 22
+SSH_PORT = paramiko.config.SSH_PORT
class SSHError(Exception):
@@ -90,7 +92,7 @@ class SSHTimeout(SSHError):
class SSH(object):
"""Represent ssh connection."""
- def __init__(self, user, host, port=DEFAULT_PORT, pkey=None,
+ def __init__(self, user, host, port=SSH_PORT, pkey=None,
key_filename=None, password=None, name=None):
"""Initialize SSH client.
@@ -109,6 +111,9 @@ class SSH(object):
self.user = user
self.host = host
+ # everybody wants to debug this in the caller, do it here instead
+ self.log.debug("user:%s host:%s", user, host)
+
# we may get text port from YAML, convert to int
self.port = int(port)
self.pkey = self._get_pkey(pkey) if pkey else None
@@ -123,6 +128,23 @@ class SSH(object):
else:
logging.getLogger("paramiko").setLevel(logging.WARN)
+ @classmethod
+ def from_node(cls, node, overrides=None, defaults=None):
+ if overrides is None:
+ overrides = {}
+ if defaults is None:
+ defaults = {}
+ params = ChainMap(overrides, node, defaults)
+ return cls(
+ user=params['user'],
+ host=params['ip'],
+ # paramiko doesn't like None default, requires SSH_PORT default
+ port=params.get('ssh_port', SSH_PORT),
+ pkey=params.get('pkey'),
+ key_filename=params.get('key_filename'),
+ password=params.get('password'),
+ name=params.get('name'))
+
def _get_pkey(self, key):
if isinstance(key, six.string_types):
key = six.moves.StringIO(key)