diff options
author | Ross Brattain <ross.b.brattain@intel.com> | 2016-11-02 15:10:59 -0700 |
---|---|---|
committer | Ross Brattain <ross.b.brattain@intel.com> | 2016-11-10 07:47:53 +0000 |
commit | eb527820ddb21081399b27deaacc8a651ea5f06a (patch) | |
tree | d41757caf9737e2001479191f30f223fce20740f | |
parent | e80a6484956de102d14b2b42349ac1e90510cd82 (diff) |
add option to connect to non-standard ssh port
not all enviroments have port 22 enabled for SSH.
In particular for network isolation NAT and port forwarding may be used.
example pod.yaml:
nodes:
- ip: 10.2.45.145
name: node1
password: ''
role: Controller
ssh_port: 5000
user: root
- ip: 10.2.45.145
name: node2
password: ''
role: Controller
ssh_port: 5001
user: root
- ip: 10.2.45.145
name: node3
password: ''
role: Controller
ssh_port: 5002
user: root
JIRA: YARDSTICK-407
Change-Id: I8f9d6e388f31d291dd15cb900d7f71f347e41ef6
Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
33 files changed, 138 insertions, 50 deletions
diff --git a/yardstick/benchmark/scenarios/availability/attacker/attacker_baremetal.py b/yardstick/benchmark/scenarios/availability/attacker/attacker_baremetal.py index b35869d07..6561f6b65 100644 --- a/yardstick/benchmark/scenarios/availability/attacker/attacker_baremetal.py +++ b/yardstick/benchmark/scenarios/availability/attacker/attacker_baremetal.py @@ -31,7 +31,6 @@ def _execute_shell_command(command, stdin=None): class BaremetalAttacker(BaseAttacker): - __attacker_type__ = 'bare-metal-down' def setup(self): @@ -39,9 +38,11 @@ class BaremetalAttacker(BaseAttacker): 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) + self.connection = ssh.SSH(user, ip, key_filename=key_filename, + port=ssh_port) self.connection.wait(timeout=600) LOG.debug("ssh host success!") self.host_ip = ip @@ -87,10 +88,12 @@ class BaremetalAttacker(BaseAttacker): 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) + self.jump_connection = ssh.SSH(user, ip, password=pwd, + port=ssh_port) self.jump_connection.wait(timeout=600) LOG.debug("ssh jump host success!") diff --git a/yardstick/benchmark/scenarios/availability/attacker/attacker_general.py b/yardstick/benchmark/scenarios/availability/attacker/attacker_general.py index 816e7e37d..5e7716e49 100644 --- a/yardstick/benchmark/scenarios/availability/attacker/attacker_general.py +++ b/yardstick/benchmark/scenarios/availability/attacker/attacker_general.py @@ -24,9 +24,11 @@ class GeneralAttacker(BaseAttacker): 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) + self.connection = ssh.SSH(user, ip, key_filename=key_filename, + port=ssh_port) 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 5118ad628..0a844f56c 100644 --- a/yardstick/benchmark/scenarios/availability/attacker/attacker_process.py +++ b/yardstick/benchmark/scenarios/availability/attacker/attacker_process.py @@ -23,9 +23,11 @@ class ProcessAttacker(BaseAttacker): 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) + self.connection = ssh.SSH(user, ip, key_filename=key_filename, + port=ssh_port) 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 c285024e1..b55cc3134 100644 --- a/yardstick/benchmark/scenarios/availability/monitor/monitor_command.py +++ b/yardstick/benchmark/scenarios/availability/monitor/monitor_command.py @@ -42,9 +42,11 @@ class MonitorOpenstackCmd(basemonitor.BaseMonitor): 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) + self.connection = ssh.SSH(user, ip, key_filename=key_filename, + port=ssh_port) 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 61efc0520..f9ddb2505 100644 --- a/yardstick/benchmark/scenarios/availability/monitor/monitor_general.py +++ b/yardstick/benchmark/scenarios/availability/monitor/monitor_general.py @@ -25,6 +25,7 @@ class GeneralMonitor(basemonitor.BaseMonitor): 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"] @@ -40,7 +41,8 @@ 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) + self.connection = ssh.SSH(user, ip, key_filename=key_filename, + port=ssh_port) 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 53a6d8e4d..403ec4d37 100644 --- a/yardstick/benchmark/scenarios/availability/monitor/monitor_process.py +++ b/yardstick/benchmark/scenarios/availability/monitor/monitor_process.py @@ -23,9 +23,11 @@ class MonitorProcess(basemonitor.BaseMonitor): 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) + self.connection = ssh.SSH(user, ip, key_filename=key_filename, + port=ssh_port) 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 e43f6e1d5..aa28472f7 100644 --- a/yardstick/benchmark/scenarios/availability/operation/operation_general.py +++ b/yardstick/benchmark/scenarios/availability/operation/operation_general.py @@ -23,9 +23,11 @@ class GeneralOperaion(BaseOperation): 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) + self.connection = ssh.SSH(user, ip, key_filename=key_filename, + port=ssh_port) 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 681fbf63f..ae896c2b2 100644 --- a/yardstick/benchmark/scenarios/availability/result_checker/result_checker_general.py +++ b/yardstick/benchmark/scenarios/availability/result_checker/result_checker_general.py @@ -17,7 +17,6 @@ LOG = logging.getLogger(__name__) class GeneralResultChecker(BaseResultChecker): - __result_checker__type__ = "general-result-checker" def setup(self): @@ -25,9 +24,11 @@ class GeneralResultChecker(BaseResultChecker): 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) + self.connection = ssh.SSH(user, ip, key_filename=key_filename, + port=ssh_port) 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 da4aa754f..117702098 100644 --- a/yardstick/benchmark/scenarios/compute/cachestat.py +++ b/yardstick/benchmark/scenarios/compute/cachestat.py @@ -75,11 +75,13 @@ class CACHEstat(base.Scenario): 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) + self.client = ssh.SSH(user, ip, key_filename=key_filename, + port=ssh_port) 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 0d7d76143..9d7a923b1 100644 --- a/yardstick/benchmark/scenarios/compute/computecapacity.py +++ b/yardstick/benchmark/scenarios/compute/computecapacity.py @@ -40,10 +40,12 @@ 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) + self.client = ssh.SSH(host_user, host_ip, password=host_pwd, + port=ssh_port) 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 f45313e91..a7fae44ec 100644 --- a/yardstick/benchmark/scenarios/compute/cpuload.py +++ b/yardstick/benchmark/scenarios/compute/cpuload.py @@ -67,10 +67,12 @@ class CPULoad(base.Scenario): 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) + self.client = ssh.SSH(user, ip, key_filename=key_filename, + port=ssh_port) 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 478b0a1a2..6a1afe223 100644 --- a/yardstick/benchmark/scenarios/compute/cyclictest.py +++ b/yardstick/benchmark/scenarios/compute/cyclictest.py @@ -93,10 +93,12 @@ class Cyclictest(base.Scenario): 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=5555, key_filename=key_filename) + self.guest = ssh.SSH(user, ip, port=ssh_port, + key_filename=key_filename) 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 d3e802f3b..9ceb2484c 100644 --- a/yardstick/benchmark/scenarios/compute/lmbench.py +++ b/yardstick/benchmark/scenarios/compute/lmbench.py @@ -77,11 +77,13 @@ class Lmbench(base.Scenario): 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) + self.client = ssh.SSH(user, ip, key_filename=key_filename, + port=ssh_port) 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 bafd89617..48088f87c 100644 --- a/yardstick/benchmark/scenarios/compute/memload.py +++ b/yardstick/benchmark/scenarios/compute/memload.py @@ -48,11 +48,13 @@ class MEMLoad(base.Scenario): """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) + self.client = ssh.SSH(user, ip, key_filename=key_filename, + port=ssh_port) 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 f408e9cb4..6c827efc2 100644 --- a/yardstick/benchmark/scenarios/compute/perf.py +++ b/yardstick/benchmark/scenarios/compute/perf.py @@ -47,11 +47,13 @@ class Perf(base.Scenario): '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) + self.client = ssh.SSH(user, ip, key_filename=key_filename, + port=ssh_port) 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 e41fb8399..e7ec91c5c 100644 --- a/yardstick/benchmark/scenarios/compute/plugintest.py +++ b/yardstick/benchmark/scenarios/compute/plugintest.py @@ -30,10 +30,12 @@ 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) + self.client = ssh.SSH(host_user, host_ip, password=host_pwd, + port=host_ssh_port) 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 819ef769b..bc33f8af2 100644 --- a/yardstick/benchmark/scenarios/compute/ramspeed.py +++ b/yardstick/benchmark/scenarios/compute/ramspeed.py @@ -87,11 +87,13 @@ class Ramspeed(base.Scenario): 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) + self.client = ssh.SSH(user, ip, key_filename=key_filename, + port=ssh_port) 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 e6318b92e..e6299346f 100644 --- a/yardstick/benchmark/scenarios/compute/unixbench.py +++ b/yardstick/benchmark/scenarios/compute/unixbench.py @@ -67,11 +67,13 @@ class Unixbench(base.Scenario): 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) + self.client = ssh.SSH(user, ip, key_filename=key_filename, + port=ssh_port) self.client.wait(timeout=600) # copy scripts to host @@ -152,5 +154,6 @@ def _test(): # pragma: no cover p.run(result) print result + if __name__ == '__main__': _test() diff --git a/yardstick/benchmark/scenarios/networking/iperf3.py b/yardstick/benchmark/scenarios/networking/iperf3.py index bb41c3df1..13fa0155b 100644 --- a/yardstick/benchmark/scenarios/networking/iperf3.py +++ b/yardstick/benchmark/scenarios/networking/iperf3.py @@ -56,21 +56,24 @@ 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) + key_filename=target_key_filename, + port=target_ssh_port) 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) + key_filename=host_key_filename, port=host_ssh_port) 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 dcd4ef7b6..08901e12b 100755 --- a/yardstick/benchmark/scenarios/networking/netperf.py +++ b/yardstick/benchmark/scenarios/networking/netperf.py @@ -62,22 +62,26 @@ class Netperf(base.Scenario): 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) + key_filename=target_key_filename, + port=target_ssh_port) 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) + key_filename=host_key_filename, + port=host_ssh_port) self.client.wait(timeout=600) # copy script to host @@ -174,5 +178,6 @@ def _test(): netperf.run(result) print result + if __name__ == '__main__': _test() diff --git a/yardstick/benchmark/scenarios/networking/netperf_node.py b/yardstick/benchmark/scenarios/networking/netperf_node.py index 87aa8d78d..1578da7d8 100755 --- a/yardstick/benchmark/scenarios/networking/netperf_node.py +++ b/yardstick/benchmark/scenarios/networking/netperf_node.py @@ -63,9 +63,11 @@ class NetperfNode(base.Scenario): 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) @@ -75,12 +77,12 @@ class NetperfNode(base.Scenario): # 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) + password=target_password, port=target_ssh_port) 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) + password=host_password, port=host_ssh_port) 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 ea43e6077..ecde7568e 100644 --- a/yardstick/benchmark/scenarios/networking/netutilization.py +++ b/yardstick/benchmark/scenarios/networking/netutilization.py @@ -70,11 +70,13 @@ class NetUtilization(base.Scenario): """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) + self.client = ssh.SSH(user, ip, key_filename=key_filename, + port=ssh_port) 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 57d3b5072..fed2fbd65 100644 --- a/yardstick/benchmark/scenarios/networking/networkcapacity.py +++ b/yardstick/benchmark/scenarios/networking/networkcapacity.py @@ -40,11 +40,13 @@ class NetworkCapacity(base.Scenario): 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)
+ self.client = ssh.SSH(host_user, host_ip, password=host_pwd,
+ port=ssh_port)
self.client.wait(timeout=600)
# copy script to host
diff --git a/yardstick/benchmark/scenarios/networking/ping.py b/yardstick/benchmark/scenarios/networking/ping.py index 54c192294..2becdaf36 100644 --- a/yardstick/benchmark/scenarios/networking/ping.py +++ b/yardstick/benchmark/scenarios/networking/ping.py @@ -39,6 +39,7 @@ class Ping(base.Scenario): '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) @@ -46,11 +47,13 @@ class Ping(base.Scenario): 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) + 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) + self.connection = ssh.SSH(user, ip, key_filename=key_filename, + port=ssh_port) self.connection.wait() diff --git a/yardstick/benchmark/scenarios/networking/ping6.py b/yardstick/benchmark/scenarios/networking/ping6.py index 91183be25..c6ec33e3e 100644 --- a/yardstick/benchmark/scenarios/networking/ping6.py +++ b/yardstick/benchmark/scenarios/networking/ping6.py @@ -51,6 +51,7 @@ class Ping6(base.Scenario): # pragma: no cover # 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') @@ -58,11 +59,12 @@ class Ping6(base.Scenario): # pragma: no cover 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) + 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) + self.client = ssh.SSH(user, ip, key_filename=key_fname, + port=ssh_port) 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 9dac4c90c..3e105767a 100644 --- a/yardstick/benchmark/scenarios/networking/pktgen.py +++ b/yardstick/benchmark/scenarios/networking/pktgen.py @@ -49,21 +49,25 @@ class Pktgen(base.Scenario): 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) + key_filename=target_key_filename, + port=target_ssh_port) 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) + key_filename=host_key_filename, + port=host_ssh_port) self.client.wait(timeout=600) # copy script to host @@ -169,5 +173,6 @@ def _test(): p.run(result) print result + if __name__ == '__main__': _test() diff --git a/yardstick/benchmark/scenarios/networking/pktgen_dpdk.py b/yardstick/benchmark/scenarios/networking/pktgen_dpdk.py index 86585eca3..189cc7895 100644 --- a/yardstick/benchmark/scenarios/networking/pktgen_dpdk.py +++ b/yardstick/benchmark/scenarios/networking/pktgen_dpdk.py @@ -45,15 +45,18 @@ class PktgenDPDKLatency(base.Scenario): 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) + key_filename=target_key_filename, + port=target_ssh_port) self.server.wait(timeout=600) # copy script to host @@ -62,7 +65,8 @@ class PktgenDPDKLatency(base.Scenario): LOG.info("user:%s, host:%s", host_user, host_ip) self.client = ssh.SSH(host_user, host_ip, - key_filename=host_key_filename) + key_filename=host_key_filename, + port=host_ssh_port) 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 a126bb52a..9494e70d2 100644 --- a/yardstick/benchmark/scenarios/networking/sfc.py +++ b/yardstick/benchmark/scenarios/networking/sfc.py @@ -41,12 +41,14 @@ class Sfc(base.Scenario): # pragma: no cover 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) + self.server = ssh.SSH(target_user, target_ip, password=target_pwd, + port=target_ssh_port) self.server.wait(timeout=600) self.server.run("cat > ~/server.sh", stdin=open(self.server_script, "rb")) @@ -59,11 +61,13 @@ class Sfc(base.Scenario): # pragma: no cover 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) + self.server = ssh.SSH(SF1_user, SF1_ip, password=SF1_pwd, + port=SF1_ssh_port) self.server.wait(timeout=600) cmd_SF1 = ("nohup python vxlan_tool.py -i eth0 " "-d forward -v off -b 80 &") @@ -74,11 +78,13 @@ class Sfc(base.Scenario): # 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) + self.server = ssh.SSH(SF2_user, SF2_ip, password=SF2_pwd, + port=SF2_ssh_port) self.server.wait(timeout=600) cmd_SF2 = ("nohup python vxlan_tool.py -i eth0 " "-d forward -v off -b 22 &") @@ -95,11 +101,13 @@ class Sfc(base.Scenario): # pragma: no cover ''' 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) + self.client = ssh.SSH(host_user, host_ip, password=host_pwd, + port=ssh_port) self.client.wait(timeout=600) if not self.setup_done: # pragma: no cover diff --git a/yardstick/benchmark/scenarios/networking/vsperf.py b/yardstick/benchmark/scenarios/networking/vsperf.py index d3123083a..82db1e254 100644 --- a/yardstick/benchmark/scenarios/networking/vsperf.py +++ b/yardstick/benchmark/scenarios/networking/vsperf.py @@ -104,6 +104,7 @@ class Vsperf(base.Scenario): '''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) @@ -118,7 +119,7 @@ class Vsperf(base.Scenario): # 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) + password=vsperf_password, port=vsperf_ssh_port) # 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 a8d27faba..0e4153643 100644 --- a/yardstick/benchmark/scenarios/storage/fio.py +++ b/yardstick/benchmark/scenarios/storage/fio.py @@ -60,11 +60,13 @@ class Fio(base.Scenario): 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) + self.client = ssh.SSH(user, ip, key_filename=key_filename, + port=ssh_port) 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 49e3a0339..bed45fa6d 100644 --- a/yardstick/benchmark/scenarios/storage/storagecapacity.py +++ b/yardstick/benchmark/scenarios/storage/storagecapacity.py @@ -54,11 +54,13 @@ class StorageCapacity(base.Scenario): 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) + self.client = ssh.SSH(host_user, host_ip, password=host_pwd, + port=ssh_port) self.client.wait(timeout=600) # copy script to host diff --git a/yardstick/cmd/commands/plugin.py b/yardstick/cmd/commands/plugin.py index 9936942d8..10e5cdfbe 100644 --- a/yardstick/cmd/commands/plugin.py +++ b/yardstick/cmd/commands/plugin.py @@ -84,6 +84,7 @@ class PluginCommands(object): '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") deployment_password = deployment.get("password") @@ -92,12 +93,14 @@ class PluginCommands(object): LOG.info("user:%s, host:%s", deployment_user, installer_ip) self.client = ssh.SSH(deployment_user, installer_ip, - password=deployment_password) + password=deployment_password, + port=deployment_ssh_port) self.client.wait(timeout=600) else: LOG.info("user:%s, host:%s", deployment_user, deployment_ip) self.client = ssh.SSH(deployment_user, deployment_ip, - password=deployment_password) + password=deployment_password, + port=deployment_ssh_port) self.client.wait(timeout=600) # copy script to host @@ -113,6 +116,7 @@ class PluginCommands(object): '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") deployment_password = deployment.get("password") @@ -121,12 +125,14 @@ class PluginCommands(object): LOG.info("user:%s, host:%s", deployment_user, installer_ip) self.client = ssh.SSH(deployment_user, installer_ip, - password=deployment_password) + password=deployment_password, + port=deployment_ssh_port) self.client.wait(timeout=600) else: LOG.info("user:%s, host:%s", deployment_user, deployment_ip) self.client = ssh.SSH(deployment_user, deployment_ip, - password=deployment_password) + password=deployment_password, + port=deployment_ssh_port) self.client.wait(timeout=600) # copy script to host @@ -145,6 +151,7 @@ class PluginCommands(object): class PluginParser(object): '''Parser for plugin configration files in yaml format''' + def __init__(self, path): self.path = path diff --git a/yardstick/ssh.py b/yardstick/ssh.py index cf890df6f..8b71fe606 100644 --- a/yardstick/ssh.py +++ b/yardstick/ssh.py @@ -69,6 +69,8 @@ import logging LOG = logging.getLogger(__name__) +DEFAULT_PORT = 22 + class SSHError(Exception): pass @@ -81,7 +83,7 @@ class SSHTimeout(SSHError): class SSH(object): """Represent ssh connection.""" - def __init__(self, user, host, port=22, pkey=None, + def __init__(self, user, host, port=DEFAULT_PORT, pkey=None, key_filename=None, password=None): """Initialize SSH client. @@ -95,7 +97,8 @@ class SSH(object): self.user = user self.host = host - self.port = port + # we may get text port from YAML, convert to int + self.port = int(port) self.pkey = self._get_pkey(pkey) if pkey else None self.password = password self.key_filename = key_filename |