diff options
author | imarom <imarom@cisco.com> | 2016-03-16 14:23:53 +0200 |
---|---|---|
committer | imarom <imarom@cisco.com> | 2016-03-16 14:23:53 +0200 |
commit | 7d0f9e5efeae033151b5442b00c8055376de9c6b (patch) | |
tree | d351996ebb07285e7064443acba3071ef670afb9 /scripts/automation | |
parent | 7d7cb50d7e75ca1beccc00daf74227c4320685f6 (diff) |
tunables for console
Diffstat (limited to 'scripts/automation')
3 files changed, 46 insertions, 2 deletions
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py index 6202e126..3d12f32c 100644 --- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py @@ -1930,6 +1930,7 @@ class STLClient(object): parsing_opts.FORCE, parsing_opts.FILE_PATH, parsing_opts.DURATION, + parsing_opts.TUNABLES, parsing_opts.MULTIPLIER_STRICT, parsing_opts.DRY_RUN) @@ -1950,14 +1951,33 @@ class STLClient(object): else: self.stop(active_ports) + + # default value for tunables (empty) + tunables = [{}] * len(opts.ports) + + # process tunables + if opts.tunables: + + # for one tunable - duplicate for all ports + if len(opts.tunables) == 1: + tunables = opts.tunables * len(opts.ports) + + else: + # must be exact + if len(opts.ports) != len(opts.tunables): + self.logger.log('tunables section count must be 1 or exactly as the number of ports: got {0}'.format(len(opts.tunables))) + return + tunables = opts.tunables + + # remove all streams self.remove_all_streams(opts.ports) # pack the profile try: - for port in opts.ports: - profile = STLProfile.load(opts.file[0], direction = (port % 2), port = port) + for port, t in zip(opts.ports, tunables): + profile = STLProfile.load(opts.file[0], direction = (port % 2), port = port, **t) self.add_streams(profile.get_streams(), ports = port) except STLError as e: diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py index 9edc279f..e0334c7e 100644 --- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py @@ -902,6 +902,8 @@ class STLProfile(object): if ipg_usec < 1: raise STLError("ipg_usec cannot be less than 1 usec: '{0}'".format(ipg_usec)) + if loop_count < 0: + raise STLError("'loop_count' cannot be negative") streams = [] last_ts_usec = 0 diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/parsing_opts.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/parsing_opts.py index 0390ac9c..c4f2b358 100755 --- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/parsing_opts.py +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/parsing_opts.py @@ -30,6 +30,7 @@ COUNT = 18 PROMISCUOUS = 19 NO_PROMISCUOUS = 20 PROMISCUOUS_SWITCH = 21 +TUNABLES = 22 GLOBAL_STATS = 50 PORT_STATS = 51 @@ -190,6 +191,19 @@ def is_valid_file(filename): return filename +def decode_tunables_to_dict (**kwargs): + return kwargs + +def decode_tunables (tunable_str): + try: + tunables = [eval('decode_tunables_to_dict({0})'.format(t)) for t in tunable_str.split('#')] + + except (SyntaxError, NameError): + raise argparse.ArgumentTypeError("bad syntax for tunables: {0}".format(tunable_str)) + + return tunables + + OPTIONS_DB = {MULTIPLIER: ArgumentPack(['-m', '--multiplier'], {'help': match_multiplier_help, 'dest': "mult", @@ -233,6 +247,14 @@ OPTIONS_DB = {MULTIPLIER: ArgumentPack(['-m', '--multiplier'], 'default': None, 'action': "store_true"}), + + TUNABLES: ArgumentPack(['-t'], + {'help': "sets tunable for a profile", + 'dest': "tunables", + 'default': None, + 'type': decode_tunables}), + + NO_PROMISCUOUS: ArgumentPack(['--no_prom'], {'help': "sets port promiscuous off", 'dest': "prom", |