diff options
author | 2015-11-23 18:02:14 +0200 | |
---|---|---|
committer | 2015-11-23 18:02:14 +0200 | |
commit | 1f6977d1e109acba69f1bf2230d6b9f5e4aae54e (patch) | |
tree | 21292c73ea16f456d4deee455dcb9e1f96397141 /scripts | |
parent | 903b855393acd411e85b25e6b2df1158d9fe2856 (diff) |
add stream graph + support for console to use any of the following
bps, kbps, mbps, gbps, pps, kpps, mbps
percentage is not working yet
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/automation/trex_control_plane/console/parsing_opts.py | 64 |
1 files changed, 51 insertions, 13 deletions
diff --git a/scripts/automation/trex_control_plane/console/parsing_opts.py b/scripts/automation/trex_control_plane/console/parsing_opts.py index d5c21af0..732ba764 100755 --- a/scripts/automation/trex_control_plane/console/parsing_opts.py +++ b/scripts/automation/trex_control_plane/console/parsing_opts.py @@ -44,22 +44,60 @@ def match_time_unit(val): def match_multiplier(val): '''match some val against multiplier shortcut inputs ''' - match = re.match("^(\d+)(gb|kpps|%?)$", val) + + match = re.match("^(\d+(\.\d+)?)(bps|kbps|mbps|gbps|pps|kpps|mbps|%?)$", val) + + result = {} + if match: - digit = int(match.group(1)) - unit = match.group(2) + + value = float(match.group(1)) + unit = match.group(3) + + # raw type (factor) if not unit: - return digit - elif unit == 'gb': - raise NotImplementedError("gb units are not supported yet") - else: - raise NotImplementedError("kpps units are not supported yet") + result['type'] = 'raw' + result['factor'] = value + + elif unit == 'bps': + result['type'] = 'max_bps' + result['max'] = value + + elif unit == 'kbps': + result['type'] = 'max_bps' + result['max'] = value * 1000 + + elif unit == 'mbps': + result['type'] = 'max_bps' + result['max'] = value * 1000 * 1000 + + elif unit == 'gbps': + result['type'] = 'max_bps' + result['max'] = value * 1000 * 1000 * 1000 + + elif unit == 'pps': + result['type'] = 'max_pps' + result['max'] = value + + elif unit == "kpps": + result['type'] = 'max_pps' + result['max'] = value * 1000 + + elif unit == "mpps": + result['type'] = 'max_pps' + result['max'] = value * 1000 * 1000 + + elif unit == "%": + raise argparse.ArgumentTypeError("percetange is currently unsupported...") + + return result + else: - raise argparse.ArgumentTypeError("Multiplier should be passed in the following format: \n" - "-m 100 : multiply stream file by this factor \n" - "-m 10gb : from graph calculate the maximum rate as this bandwidth (for each port)\n" - "-m 10kpps : from graph calculate the maximum rate as this pps (for each port)\n" - "-m 40% : from graph calculate the maximum rate as this percent from total port (for each port)") + raise argparse.ArgumentTypeError("\n\nMultiplier should be passed in the following format: \n\n" + "-m 100 : multiply by factor \n" + "-m 1bps / 1kbps / 1mbps / 1gbps : normalize to bps \n" + "-m 1pps / 1kpps / 1mbps : normalize to pps \n" + "-m 40% : normalize to % from port line rate\n") |