aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKubi <jean.gaoliang@huawei.com>2017-03-17 09:07:37 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-03-17 09:07:37 +0000
commit1ffaf9851b2695bd9129cfe20afe834a9d732adb (patch)
treed5477039a6e9fc3b5a5451521c1fb80f6cf1e1fc
parent7a4472954122ce97cc67acab2dc3207a1582370d (diff)
parent2ac38407edf3d9e305f36842d7ba56a9ee788a1e (diff)
Merge "Bugfix: network_utilization: parse error" into stable/danube
-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)