summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorHanoh Haim <hhaim@cisco.com>2015-12-16 12:19:52 +0200
committerHanoh Haim <hhaim@cisco.com>2015-12-16 12:19:52 +0200
commita1fbf1730da1b7db6270cd9aa84fa1c63f3f3932 (patch)
tree1a870baaf99262e13476f5d3ea9c0be696c469b8 /scripts
parent31b92c62f1ce84ba44c9fdf6c2f12ae51655f86c (diff)
parentf0919e280a6a7b74a52f05b8e6f591e1b7e08200 (diff)
Merge from master
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/automation/trex_control_plane/client/trex_client.py4
-rwxr-xr-xscripts/automation/trex_control_plane/client_utils/packet_builder.py24
-rwxr-xr-xscripts/automation/trex_control_plane/common/trex_stats.py2
-rw-r--r--scripts/automation/trex_control_plane/console/trex_tui.py5
4 files changed, 29 insertions, 6 deletions
diff --git a/scripts/automation/trex_control_plane/client/trex_client.py b/scripts/automation/trex_control_plane/client/trex_client.py
index a8669011..5709b7a5 100755
--- a/scripts/automation/trex_control_plane/client/trex_client.py
+++ b/scripts/automation/trex_control_plane/client/trex_client.py
@@ -125,7 +125,7 @@ class CTRexClient(object):
user = user or self.__default_user
try:
d = int(d)
- if d < 30 and not trex_development: # specify a test should take at least 30 seconds long.
+ if d < 30 and not trex_development: # test duration should be at least 30 seconds, unless trex_development flag is specified.
raise ValueError
except ValueError:
raise ValueError('d parameter must be integer, specifying how long TRex run, and must be larger than 30 secs.')
@@ -133,6 +133,8 @@ class CTRexClient(object):
trex_cmd_options.update( {'f' : f, 'd' : d} )
if not trex_cmd_options.get('l'):
self.result_obj.latency_checked = False
+ if 'k' in trex_cmd_options:
+ timeout += int(trex_cmd_options['k']) # during 'k' seconds TRex stays in 'Starting' state
self.result_obj.clear_results()
try:
diff --git a/scripts/automation/trex_control_plane/client_utils/packet_builder.py b/scripts/automation/trex_control_plane/client_utils/packet_builder.py
index 3aeb6a34..d8070c74 100755
--- a/scripts/automation/trex_control_plane/client_utils/packet_builder.py
+++ b/scripts/automation/trex_control_plane/client_utils/packet_builder.py
@@ -301,6 +301,30 @@ class CTRexPktBuilder(object):
break
return
+ def load_packet_from_pcap(self, pcap_path):
+ """
+ This method loads a pcap file into a parsed packet builder object.
+
+ :parameters:
+ pcap_path: str
+ a path to a pcap file, containing a SINGLE packet.
+
+ :raises:
+ + :exc:`IOError`, in case provided path doesn't exists.
+
+ """
+ with open(pcap_path, 'r') as f:
+ pcap = dpkt.pcap.Reader(f)
+ first_packet = True
+ for _, buf in pcap:
+ # this is an iterator, can't evaluate the number of files in advance
+ if first_packet:
+ self.load_packet(dpkt.ethernet.Ethernet(buf))
+ else:
+ raise ValueError("Provided pcap file contains more than single packet.")
+ # arrive here ONLY if pcap contained SINGLE packet
+ return
+
def get_packet(self, get_ptr=False):
"""
This method provides access to the built packet, as an instance or as a pointer to packet itself.
diff --git a/scripts/automation/trex_control_plane/common/trex_stats.py b/scripts/automation/trex_control_plane/common/trex_stats.py
index 20255f41..9562f1f5 100755
--- a/scripts/automation/trex_control_plane/common/trex_stats.py
+++ b/scripts/automation/trex_control_plane/common/trex_stats.py
@@ -244,7 +244,6 @@ class CTRexStats(object):
class CGlobalStats(CTRexStats):
- pass
def __init__(self, connection_info, server_version, ports_dict_ref):
super(CGlobalStats, self).__init__()
@@ -270,7 +269,6 @@ class CGlobalStats(CTRexStats):
)
class CPortStats(CTRexStats):
- pass
def __init__(self, port_obj):
super(CPortStats, self).__init__()
diff --git a/scripts/automation/trex_control_plane/console/trex_tui.py b/scripts/automation/trex_control_plane/console/trex_tui.py
index 6b0aa50a..febe62f4 100644
--- a/scripts/automation/trex_control_plane/console/trex_tui.py
+++ b/scripts/automation/trex_control_plane/console/trex_tui.py
@@ -32,12 +32,11 @@ class TrexTUIPanel(object):
self.name = name
self.stateless_client = mng.stateless_client
-
def show (self):
- raise Exception("must implement this")
+ raise NotImplementedError("must implement this")
def get_key_actions (self):
- raise Exception("must implement this")
+ raise NotImplementedError("must implement this")
def get_name (self):
return self.name