summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKubi <jean.gaoliang@huawei.com>2017-03-17 09:07:58 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-03-17 09:07:58 +0000
commitcf967b8bf46b5b1ea77b5ca9a8ccee00fbb1e1d6 (patch)
treeb254b27d52c208a7b41a5ac6b2aea50416cbdf23
parent9229d66abb1a2266bd8bbabc1e79f0ee46632bcf (diff)
parenta416a8f615be4555dbfe15951c7b414c0daa6d34 (diff)
Merge "Bugfix: network_utilization: parse error"
-rw-r--r--yardstick/benchmark/scenarios/networking/netutilization.py29
1 files changed, 14 insertions, 15 deletions
diff --git a/yardstick/benchmark/scenarios/networking/netutilization.py b/yardstick/benchmark/scenarios/networking/netutilization.py
index 1ba6f1ec3..37da7f895 100644
--- a/yardstick/benchmark/scenarios/networking/netutilization.py
+++ b/yardstick/benchmark/scenarios/networking/netutilization.py
@@ -100,30 +100,22 @@ class NetUtilization(base.Scenario):
average = {}
time_marker = re.compile("^([0-9]+):([0-9]+):([0-9]+)$")
- ampm_marker = re.compile("(AM|PM)$")
# Parse network utilization stats
- for row in raw_result.split('\n'):
+ for row in raw_result.splitlines():
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:]
if values and len(values) == len(fields):
- temp_dict = dict(list(zip(fields, values)))
+ temp_dict = dict(zip(fields, values))
if net_interface not in maximum:
maximum[net_interface] = temp_dict
else:
@@ -144,6 +136,13 @@ class NetUtilization(base.Scenario):
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]
@@ -161,7 +160,7 @@ class NetUtilization(base.Scenario):
values = line[1:]
if values and len(values) == len(fields):
average[net_interface] = dict(
- list(zip(fields, values)))
+ zip(fields, values))
else:
raise RuntimeError("network_utilization average: \
parse error", fields, line)