diff options
author | imarom <imarom@cisco.com> | 2016-03-16 11:30:40 +0200 |
---|---|---|
committer | imarom <imarom@cisco.com> | 2016-03-16 11:31:20 +0200 |
commit | f803e5b2b997e02f30bf747ce799f42b7aa61c13 (patch) | |
tree | 8c1b92b9d4c3e61fdd55dbe1eff4d7a4b37f9e93 /scripts/automation/trex_control_plane | |
parent | 9de939585468e18c6aa57f626530841029bb7e86 (diff) |
FIX: direction for profile
Diffstat (limited to 'scripts/automation/trex_control_plane')
3 files changed, 22 insertions, 12 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 f7e63ccf..6202e126 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 @@ -1956,15 +1956,16 @@ class STLClient(object): # pack the profile try: - profile = STLProfile.load(opts.file[0]) + for port in opts.ports: + profile = STLProfile.load(opts.file[0], direction = (port % 2), port = port) + self.add_streams(profile.get_streams(), ports = port) + except STLError as e: self.logger.log(format_text("\nError while loading profile '{0}'\n".format(opts.file[0]), 'bold')) self.logger.log(e.brief() + "\n") return - self.add_streams(profile.get_streams(), ports = opts.ports) - if opts.dry: self.validate(opts.ports, opts.mult, opts.duration, opts.total) else: diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_sim.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_sim.py index 614d8b77..42c37e63 100644 --- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_sim.py +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_sim.py @@ -141,7 +141,7 @@ class STLSim(object): # handle YAMLs for input_file in input_files: try: - profile = STLProfile.load(input_file) + profile = STLProfile.load(input_file, direction = (self.port_id % 2), port = self.port_id) except STLError as e: s = format_text("\nError while loading profile '{0}'\n".format(input_file), 'bold') s += "\n" + e.brief() @@ -360,6 +360,13 @@ def setParserOptions(): default = None, type = int) + parser.add_argument("-i", "--port", + help = "Simulate a specific port ID [default is 0]", + dest = "port_id", + default = 0, + type = int) + + parser.add_argument("-r", "--release", help = "runs on release image instead of debug [default is False]", action = "store_true", @@ -465,7 +472,7 @@ def main (args = None): mode = 'none' try: - r = STLSim(bp_sim_path = options.bp_sim_path) + r = STLSim(bp_sim_path = options.bp_sim_path, port_id = options.port_id) r.run(input_list = options.input_file, outfile = options.output_file, 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 2baa645c..d4b817cc 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 @@ -835,7 +835,7 @@ class STLProfile(object): @staticmethod - def load_py (python_file): + def load_py (python_file, direction = 0, **kwargs): """ load from Python profile """ # check filename @@ -850,13 +850,13 @@ class STLProfile(object): module = __import__(file, globals(), locals(), [], -1) reload(module) # reload the update - streams = module.register().get_streams() + streams = module.register().get_streams(direction = direction, **kwargs) return STLProfile(streams) except Exception as e: a, b, tb = sys.exc_info() - x =''.join(traceback.format_list(traceback.extract_tb(tb)[1:])) + a.__name__ + ": " + str(b) + "\n" + x =''.join(traceback.format_list(traceback.extract_tb(tb)[0:])) + a.__name__ + ": " + str(b) + "\n" summary = "\nPython Traceback follows:\n\n" + x raise STLError(summary) @@ -940,14 +940,16 @@ class STLProfile(object): @staticmethod - def load (filename): + def load (filename, direction = 0, **kwargs): """ load a profile by its type supported type are * py * yaml * pcap file that converted to profile automaticly :parameters: - filename : string as filename + filename : string as filename + direction : profile's direction (if supported by the profile) + kwargs : forward those key-value pairs to the profile """ @@ -955,7 +957,7 @@ class STLProfile(object): suffix = x[1] if (len(x) == 2) else None if suffix == 'py': - profile = STLProfile.load_py(filename) + profile = STLProfile.load_py(filename, direction, **kwargs) elif suffix == 'yaml': profile = STLProfile.load_yaml(filename) @@ -996,7 +998,7 @@ class STLProfile(object): from trex_stl_lib.api import * class STLS1(object): - def get_streams(self): + def get_streams(self, direction = 0, **kwargs): streams = [] ''' for stream in self.streams: |