aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/benchmark/scenarios/compute
diff options
context:
space:
mode:
authorRoss Brattain <ross.b.brattain@intel.com>2017-03-01 17:28:46 -0800
committerRoss Brattain <ross.b.brattain@intel.com>2017-04-11 21:58:20 -0700
commit99abbb424007da2e01762f3c040a39c0157cbe1f (patch)
treebaab901a9e7444c9fd36aa4a19c1e51d03cb8e7f /yardstick/benchmark/scenarios/compute
parent2240fcc201fa9665e42e92c29e201cb62490acfa (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>
Diffstat (limited to 'yardstick/benchmark/scenarios/compute')
-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
10 files changed, 27 insertions, 83 deletions
diff --git a/yardstick/benchmark/scenarios/compute/cachestat.py b/yardstick/benchmark/scenarios/compute/cachestat.py
index b4c3463e5..a365968c7 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 ae1d37324..37d8472ef 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