X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=nfvbench%2Futils.py;h=b92c75e4038b113c2a8becf5848a7c3fb4665df4;hb=143c4ff68068fd704e7eb4df1c82af29f087c871;hp=d4482fd3f95d0d33c0ee0fb8e4517f52082d7c21;hpb=caac5c7f6e80d33d5031f26e5e0f0ea6f1d3789b;p=nfvbench.git diff --git a/nfvbench/utils.py b/nfvbench/utils.py index d4482fd..b92c75e 100644 --- a/nfvbench/utils.py +++ b/nfvbench/utils.py @@ -24,7 +24,7 @@ import fcntl from functools import wraps import json from .log import LOG - +from nfvbench.traffic_gen.traffic_utils import multiplier_map class TimeoutError(Exception): pass @@ -72,22 +72,6 @@ def save_json_result(result, json_file, std_json_path, service_chain, service_ch default=lambda obj: obj.to_json()) -def byteify(data, ignore_dicts=False): - # if this is a unicode string, return its string representation - if isinstance(data, str): - return data.encode('utf-8') - # if this is a list of values, return list of byteified values - if isinstance(data, list): - return [byteify(item, ignore_dicts=ignore_dicts) for item in data] - # if this is a dictionary, return dictionary of byteified keys and values - # but only if we haven't already byteified it - if isinstance(data, dict) and not ignore_dicts: - return {byteify(key, ignore_dicts=ignore_dicts): byteify(value, ignore_dicts=ignore_dicts) - for key, value in list(data.items())} - # if it's anything else, return it in its original form - return data - - def dict_to_json_dict(record): return json.loads(json.dumps(record, default=lambda obj: obj.to_json())) @@ -170,12 +154,6 @@ def get_intel_pci(nic_slot=None, nic_ports=None): return pcis -multiplier_map = { - 'K': 1000, - 'M': 1000000, - 'G': 1000000000 -} - def parse_flow_count(flow_count): flow_count = str(flow_count) @@ -194,7 +172,8 @@ def parse_flow_count(flow_count): def cast_integer(value): - return int(value) if not isnan(value) else value + # force 0 value if NaN value from TRex to avoid error in JSON result parsing + return int(value) if not isnan(value) else 0 class RunLock(object):