summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/client
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/automation/trex_control_plane/client')
-rw-r--r--scripts/automation/trex_control_plane/client/trex_port.py25
-rwxr-xr-xscripts/automation/trex_control_plane/client/trex_stateless_client.py41
2 files changed, 38 insertions, 28 deletions
diff --git a/scripts/automation/trex_control_plane/client/trex_port.py b/scripts/automation/trex_control_plane/client/trex_port.py
index 94240f2a..d32d2a01 100644
--- a/scripts/automation/trex_control_plane/client/trex_port.py
+++ b/scripts/automation/trex_control_plane/client/trex_port.py
@@ -6,12 +6,12 @@ from client_utils import packet_builder
StreamOnPort = namedtuple('StreamOnPort', ['compiled_stream', 'metadata'])
########## utlity ############
-def mult_to_factor (mult, max_bps, max_pps, line_util):
+def mult_to_factor (mult, max_bps_l2, max_pps, line_util):
if mult['type'] == 'raw':
return mult['value']
if mult['type'] == 'bps':
- return mult['value'] / max_bps
+ return mult['value'] / max_bps_l2
if mult['type'] == 'pps':
return mult['value'] / max_pps
@@ -398,16 +398,19 @@ class Port(object):
print format_text("Profile Map Per Port\n", 'underline', 'bold')
- factor = mult_to_factor(mult, rate['max_bps'], rate['max_pps'], rate['max_line_util'])
+ factor = mult_to_factor(mult, rate['max_bps_l2'], rate['max_pps'], rate['max_line_util'])
- print "Profile max BPS (base / req): {:^12} / {:^12}".format(format_num(rate['max_bps'], suffix = "bps"),
- format_num(rate['max_bps'] * factor, suffix = "bps"))
+ print "Profile max BPS L2 (base / req): {:^12} / {:^12}".format(format_num(rate['max_bps_l2'], suffix = "bps"),
+ format_num(rate['max_bps_l2'] * factor, suffix = "bps"))
- print "Profile max PPS (base / req): {:^12} / {:^12}".format(format_num(rate['max_pps'], suffix = "pps"),
- format_num(rate['max_pps'] * factor, suffix = "pps"),)
+ print "Profile max BPS L1 (base / req): {:^12} / {:^12}".format(format_num(rate['max_bps_l1'], suffix = "bps"),
+ format_num(rate['max_bps_l1'] * factor, suffix = "bps"))
- print "Profile line util. (base / req): {:^12} / {:^12}".format(format_percentage(rate['max_line_util'] * 100),
- format_percentage(rate['max_line_util'] * factor * 100))
+ print "Profile max PPS (base / req): {:^12} / {:^12}".format(format_num(rate['max_pps'], suffix = "pps"),
+ format_num(rate['max_pps'] * factor, suffix = "pps"),)
+
+ print "Profile line util. (base / req): {:^12} / {:^12}".format(format_percentage(rate['max_line_util']),
+ format_percentage(rate['max_line_util'] * factor))
# duration
@@ -422,8 +425,8 @@ class Port(object):
exp_time_factor_sec = duration
- print "Duration (base / req): {:^12} / {:^12}".format(format_time(exp_time_base_sec),
- format_time(exp_time_factor_sec))
+ print "Duration (base / req): {:^12} / {:^12}".format(format_time(exp_time_base_sec),
+ format_time(exp_time_factor_sec))
print "\n"
diff --git a/scripts/automation/trex_control_plane/client/trex_stateless_client.py b/scripts/automation/trex_control_plane/client/trex_stateless_client.py
index c1a4d1d1..c59da7b4 100755
--- a/scripts/automation/trex_control_plane/client/trex_stateless_client.py
+++ b/scripts/automation/trex_control_plane/client/trex_stateless_client.py
@@ -54,7 +54,7 @@ class STLStateError(STLError):
# port state error
class STLPortStateError(STLError):
def __init__ (self, port, op, state):
- self.msg = "Operation '{0}' on port '{1}' is not valid for state '{2}'".format(op, port, state)
+ self.msg = "Operation '{0}' on port(s) '{1}' is not valid while port(s) '{2}'".format(op, port, state)
# raised when argument is not valid for operation
@@ -766,18 +766,6 @@ class STLClient(object):
# start command
def __start (self, port_id_list, stream_list, mult, force, duration, dry):
- active_ports = list(set(self.get_active_ports()).intersection(port_id_list))
-
- if active_ports:
- if not force:
- msg = "Port(s) {0} are active - please stop them or add '--force'".format(active_ports)
- self.logger.log(format_text(msg, 'bold'))
- return RC_ERR(msg)
- else:
- rc = self.__stop(active_ports)
- if not rc:
- return rc
-
self.logger.pre_cmd("Removing all streams from port(s) {0}:".format(port_id_list))
rc = self.__remove_all_streams(port_id_list)
@@ -804,11 +792,7 @@ class STLClient(object):
return rc
else:
- self.logger.pre_cmd("Validating traffic profile on port(s) {0}:".format(port_id_list))
rc = self.__validate(port_id_list)
- self.logger.post_cmd(rc)
-
-
if rc.bad():
return rc
@@ -1335,6 +1319,19 @@ class STLClient(object):
if not rc:
raise STLError(rc)
+
+ # verify ports are stopped or force stop them
+ active_ports = list(set(self.get_active_ports()).intersection(ports))
+ if active_ports:
+ if not force:
+ msg = "Port(s) {0} are active - please stop them or specify 'force'".format(active_ports)
+ raise STLError(msg)
+ else:
+ rc = self.__stop(active_ports)
+ if not rc:
+ raise STLError(rc)
+
+
# dry run
if dry:
self.logger.log(format_text("\n*** DRY RUN ***", 'bold'))
@@ -1582,6 +1579,16 @@ class STLClient(object):
if opts is None:
return
+
+ active_ports = list(set(self.get_active_ports()).intersection(opts.ports))
+
+ if active_ports:
+ if not opts.force:
+ msg = "Port(s) {0} are active - please stop them or add '--force'\n".format(active_ports)
+ self.logger.log(format_text(msg, 'bold'))
+ return
+
+
# pack the profile
profiles = [opts.file[0]]