summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/stl/trex_stl_lib
diff options
context:
space:
mode:
authorHanoh Haim <hhaim@cisco.com>2016-02-10 17:07:27 +0200
committerHanoh Haim <hhaim@cisco.com>2016-02-10 17:07:27 +0200
commit18d20a3b25f5f1077a872c84a7e1869de56c19fd (patch)
tree48c7fee90980ca2c191208fe83883364a6cf264d /scripts/automation/trex_control_plane/stl/trex_stl_lib
parent15783cbf852a4733fff97cad00421d45de549d37 (diff)
parent82a5a558113c7111a6269e411513b83a410df596 (diff)
Merge functional tests
Diffstat (limited to 'scripts/automation/trex_control_plane/stl/trex_stl_lib')
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py4
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py14
2 files changed, 13 insertions, 5 deletions
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py
index 732cfc1e..b1cf9ebc 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py
@@ -52,7 +52,7 @@ class Port(object):
self.port_stats = trex_stl_stats.CPortStats(self)
- self.next_available_id = 1
+ self.next_available_id = long(1)
def err(self, msg):
@@ -132,7 +132,7 @@ class Port(object):
# TODO: handle syncing the streams into stream_db
- self.next_available_id = rc.data()['max_stream_id']
+ self.next_available_id = long(rc.data()['max_stream_id'])
return self.ok()
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 53e15417..c9c34e4b 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
@@ -90,7 +90,7 @@ class STLTXMultiBurst(STLTXMode):
class STLStream(object):
def __init__ (self,
- name = random_name(8),
+ name = None,
packet = None,
mode = STLTXCont(1),
enabled = True,
@@ -120,7 +120,7 @@ class STLStream(object):
raise STLError("continuous stream cannot have a next stream ID")
# tag for the stream and next - can be anything
- self.name = name
+ self.name = name if name else random_name(8)
self.next = next
self.set_id(stream_id)
@@ -179,7 +179,15 @@ class STLStream(object):
def to_yaml (self):
return {'name': self.name, 'stream': self.fields}
+ def dump_to_yaml (self, yaml_file = None):
+ yaml_dump = yaml.dump([self.to_yaml()], default_flow_style = False)
+
+ # write to file if provided
+ if yaml_file:
+ with open(yaml_file, 'w') as f:
+ f.write(yaml_dump)
+ return yaml_dump
class YAMLLoader(object):
@@ -303,7 +311,7 @@ class STLProfile(object):
streams = [streams]
if not all([isinstance(stream, STLStream) for stream in streams]):
- raise STLArgumentError('streams', streams)
+ raise STLArgumentError('streams', streams, valid_values = STLStream)
self.streams = streams