Code Review
/
yardstick.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Merge "standardize ssh auth"
[yardstick.git]
/
yardstick
/
benchmark
/
scenarios
/
networking
/
netutilization.py
diff --git
a/yardstick/benchmark/scenarios/networking/netutilization.py
b/yardstick/benchmark/scenarios/networking/netutilization.py
index
ea43e60
..
cecb64f
100644
(file)
--- a/
yardstick/benchmark/scenarios/networking/netutilization.py
+++ b/
yardstick/benchmark/scenarios/networking/netutilization.py
@@
-6,11
+6,13
@@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+from __future__ import absolute_import
import logging
import re
import yardstick.ssh as ssh
from yardstick.benchmark.scenarios import base
import logging
import re
import yardstick.ssh as ssh
from yardstick.benchmark.scenarios import base
+from six.moves import zip
LOG = logging.getLogger(__name__)
LOG = logging.getLogger(__name__)
@@
-69,19
+71,15
@@
class NetUtilization(base.Scenario):
def setup(self):
"""Scenario setup."""
host = self.context_cfg['host']
def setup(self):
"""Scenario setup."""
host = self.context_cfg['host']
- user = host.get('user', 'ubuntu')
- 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.from_node(host, defaults={"user": "ubuntu"})
self.client.wait(timeout=600)
self.setup_done = True
def _execute_command(self, cmd):
"""Execute a command on target."""
self.client.wait(timeout=600)
self.setup_done = True
def _execute_command(self, cmd):
"""Execute a command on target."""
- LOG.info("Executing: %s"
%
cmd)
+ LOG.info("Executing: %s"
,
cmd)
status, stdout, stderr = self.client.execute(cmd)
if status:
raise RuntimeError("Failed executing command: ",
status, stdout, stderr = self.client.execute(cmd)
if status:
raise RuntimeError("Failed executing command: ",
@@
-96,25
+94,17
@@
class NetUtilization(base.Scenario):
average = {}
time_marker = re.compile("^([0-9]+):([0-9]+):([0-9]+)$")
average = {}
time_marker = re.compile("^([0-9]+):([0-9]+):([0-9]+)$")
- ampm_marker = re.compile("(AM|PM)$")
# Parse network utilization stats
# Parse network utilization stats
- for row in raw_result.split
('\n'
):
+ for row in raw_result.split
lines(
):
line = row.split()
if line and re.match(time_marker, line[0]):
line = row.split()
if line and re.match(time_marker, line[0]):
- if re.match(ampm_marker, line[1]):
- del line[:2]
- if line[0] == 'IFACE':
- # header fields
- fields = line[1:]
- if len(fields) != NetUtilization.\
- NET_UTILIZATION_FIELD_SIZE:
- raise RuntimeError("network_utilization: unexpected\
- field size", fields)
- else:
- # value fields
+ try:
+ index = line.index('IFACE')
+ except ValueError:
+ del line[:index]
net_interface = line[0]
values = line[1:]
net_interface = line[0]
values = line[1:]
@@
-140,6
+130,13
@@
class NetUtilization(base.Scenario):
else:
raise RuntimeError("network_utilization: parse error",
fields, line)
else:
raise RuntimeError("network_utilization: parse error",
fields, line)
+ else:
+ del line[:index]
+ fields = line[1:]
+ if len(fields) != NetUtilization.\
+ NET_UTILIZATION_FIELD_SIZE:
+ raise RuntimeError("network_utilization: unexpected\
+ field size", fields)
elif line and line[0] == 'Average:':
del line[:1]
elif line and line[0] == 'Average:':
del line[:1]
@@
-156,7
+153,8
@@
class NetUtilization(base.Scenario):
net_interface = line[0]
values = line[1:]
if values and len(values) == len(fields):
net_interface = line[0]
values = line[1:]
if values and len(values) == len(fields):
- average[net_interface] = dict(zip(fields, values))
+ average[net_interface] = dict(
+ zip(fields, values))
else:
raise RuntimeError("network_utilization average: \
parse error", fields, line)
else:
raise RuntimeError("network_utilization average: \
parse error", fields, line)