From a94f1cdde418a7e96fce6f9c5ec52da5bafbd4b9 Mon Sep 17 00:00:00 2001 From: imarom Date: Tue, 9 Feb 2016 09:02:04 -0500 Subject: YAML profiles fixup --- .../trex_control_plane/stl/trex_stl_lib/trex_stl_sim.py | 9 ++++++++- .../trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py | 8 ++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'scripts/automation/trex_control_plane/stl/trex_stl_lib') 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 1252b752..9cea3ea8 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 @@ -140,7 +140,14 @@ class STLSim(object): # handle YAMLs for input_file in input_files: - stream_list += STLClient.load_profile(input_file) + try: + profile = STLProfile.load(input_file) + except STLError as e: + print format_text("\nError while loading profile '{0}'\n".format(input_file), 'bold') + print e.brief() + "\n" + return + + stream_list += profile.get_streams() # load streams 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 8ad15a52..9c190dad 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 @@ -271,7 +271,7 @@ class YAMLLoader(object): # hack the VM fields for now if 'vm' in s_obj: - stream.fields['vm'] = s_obj['vm'] + stream.fields['vm'].update(s_obj['vm']) return stream @@ -281,7 +281,11 @@ class YAMLLoader(object): # read YAML and pass it down to stream object yaml_str = f.read() - objects = yaml.load(yaml_str) + try: + objects = yaml.load(yaml_str) + except yaml.parser.ParserError as e: + raise STLError(str(e)) + streams = [self.__parse_stream(object) for object in objects] return streams -- cgit 1.2.3-korg