summaryrefslogtreecommitdiffstats
path: root/scripts/automation
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-02-09 09:02:04 -0500
committerimarom <imarom@cisco.com>2016-02-09 09:10:23 -0500
commita94f1cdde418a7e96fce6f9c5ec52da5bafbd4b9 (patch)
tree856a6b21ec5ee2ba16fdcc1ec721f0b6e0c8e087 /scripts/automation
parente8ba50a8940c1288011b434bb1a7df2159578d67 (diff)
YAML profiles fixup
Diffstat (limited to 'scripts/automation')
-rw-r--r--scripts/automation/trex_control_plane/stl/examples/stl_imix.py3
-rw-r--r--scripts/automation/trex_control_plane/stl/examples/stl_simple_burst.py27
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_sim.py9
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py8
4 files changed, 17 insertions, 30 deletions
diff --git a/scripts/automation/trex_control_plane/stl/examples/stl_imix.py b/scripts/automation/trex_control_plane/stl/examples/stl_imix.py
index ad329e16..b9fbbbb6 100644
--- a/scripts/automation/trex_control_plane/stl/examples/stl_imix.py
+++ b/scripts/automation/trex_control_plane/stl/examples/stl_imix.py
@@ -35,7 +35,8 @@ def imix_test ():
dir_1 = table['dir'][1]
# load IMIX profile
- streams = c.load_profile('../../../../stl/profiles/imix.py')
+ profile = STLProfile.load_py('../../../../stl/profiles/imix.py')
+ streams = profile.get_streams()
# add both streams to ports
c.add_streams(streams, ports = dir_0)
diff --git a/scripts/automation/trex_control_plane/stl/examples/stl_simple_burst.py b/scripts/automation/trex_control_plane/stl/examples/stl_simple_burst.py
index fd3bd0d1..ed0cb93a 100644
--- a/scripts/automation/trex_control_plane/stl/examples/stl_simple_burst.py
+++ b/scripts/automation/trex_control_plane/stl/examples/stl_simple_burst.py
@@ -59,31 +59,6 @@ def simple_burst ():
print "\nTest has failed :-(\n"
-#
-def sheker ():
- pkt = STLPktBuilder(pkt = Ether()/IP(src="16.0.0.1",dst="48.0.0.1")/UDP(dport=12,sport=1025)/IP()/'a_payload_example')
-
- # create two bursts and link them
- s1 = STLStream(name = 'A',
- packet = pkt,
- mode = STLTXSingleBurst(total_pkts = 5000),
- next = 'B')
-
- s2 = STLStream(name = 'B',
- self_start = False,
- packet = pkt,
- mode = STLTXSingleBurst(total_pkts = 3000))
-
- profile = STLProfile([s1, s2])
- print "**** BEFORE ****\n"
- print profile
- profile.to_yaml('1.yaml')
- loaded_profile = STLProfile.load_yaml('1.yaml')
- print "**** AFTER ****\n"
- print loaded_profile
- exit(0)
-
-sheker()
# run the tests
-#simple_burst()
+simple_burst()
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