summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2017-01-22 16:20:45 +0200
committerimarom <imarom@cisco.com>2017-01-22 16:20:45 +0200
commit904eacd9be1230efb7ae0ab7997ec131b588ec8a (patch)
tree8e4bcd1b1a5f683efdb8f3eeb962acefc3201961 /scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
parentd2f1c8451e2e8ffc47b208f68f9b16697d706d60 (diff)
parentb81cdb6c2d6d118c1c346e7c8dae6a5e747d867d (diff)
Merge branch 'master' into capture
Signed-off-by: imarom <imarom@cisco.com> Conflicts: scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_jsonrpc_client.py scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py src/main_dpdk.cpp
Diffstat (limited to 'scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py')
-rwxr-xr-xscripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py45
1 files changed, 30 insertions, 15 deletions
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
index c82d77fb..f7432107 100755
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
@@ -452,16 +452,16 @@ class CCommLink(object):
if not self.virtual:
return self.rpc_link.disconnect()
- def transmit(self, method_name, params = None, api_class = 'core'):
+ def transmit(self, method_name, params = None, api_class = 'core', retry = 0):
if self.virtual:
self._prompt_virtual_tx_msg()
_, msg = self.rpc_link.create_jsonrpc_v2(method_name, params, api_class)
print(msg)
return
else:
- return self.rpc_link.invoke_rpc_method(method_name, params, api_class)
+ return self.rpc_link.invoke_rpc_method(method_name, params, api_class, retry = retry)
- def transmit_batch(self, batch_list):
+ def transmit_batch(self, batch_list, retry = 0):
if self.virtual:
self._prompt_virtual_tx_msg()
print([msg
@@ -472,7 +472,7 @@ class CCommLink(object):
for command in batch_list:
batch.add(command.method, command.params, command.api_class)
# invoke the batch
- return batch.invoke()
+ return batch.invoke(retry = retry)
def _prompt_virtual_tx_msg(self):
print("Transmitting virtually over tcp://{server}:{port}".format(server=self.server,
@@ -2322,7 +2322,7 @@ class STLClient(object):
@__api_check(True)
- def stop (self, ports = None, rx_delay_ms = 10):
+ def stop (self, ports = None, rx_delay_ms = None):
"""
Stop port(s)
@@ -2356,6 +2356,12 @@ class STLClient(object):
if not rc:
raise STLError(rc)
+ if rx_delay_ms is None:
+ if self.ports[ports[0]].is_virtual(): # assume all ports have same type
+ rx_delay_ms = 100
+ else:
+ rx_delay_ms = 10
+
# remove any RX filters
rc = self._remove_rx_filters(ports, rx_delay_ms = rx_delay_ms)
if not rc:
@@ -2827,7 +2833,7 @@ class STLClient(object):
@__api_check(True)
- def wait_on_traffic (self, ports = None, timeout = None, rx_delay_ms = 10):
+ def wait_on_traffic (self, ports = None, timeout = None, rx_delay_ms = None):
"""
.. _wait_on_traffic:
@@ -2871,6 +2877,12 @@ class STLClient(object):
if timer.has_expired():
raise STLTimeoutError(timeout)
+ if rx_delay_ms is None:
+ if self.ports[ports[0]].is_virtual(): # assume all ports have same type
+ rx_delay_ms = 100
+ else:
+ rx_delay_ms = 10
+
# remove any RX filters
rc = self._remove_rx_filters(ports, rx_delay_ms = rx_delay_ms)
if not rc:
@@ -2965,7 +2977,7 @@ class STLClient(object):
:parameters:
ports - which ports to resolve
- retires - how many times to retry on each port (intervals of 100 milliseconds)
+ retries - how many times to retry on each port (intervals of 100 milliseconds)
verbose - log for each request the response
:raises:
+ :exe:'STLError'
@@ -3835,7 +3847,7 @@ class STLClient(object):
parsing_opts.SUPPORTED,
)
- opts = parser.parse_args(line.split(), default_ports = self.get_acquired_ports(), verify_acquired = True)
+ opts = parser.parse_args(line.split(), default_ports = self.get_acquired_ports())
if not opts:
return opts
@@ -3845,8 +3857,9 @@ class STLClient(object):
opts.flow_ctrl = parsing_opts.FLOW_CTRL_DICT.get(opts.flow_ctrl)
# if no attributes - fall back to printing the status
- if not list(filter(lambda x:x is not None, [opts.prom, opts.link, opts.led, opts.flow_ctrl, opts.supp])):
- self.show_stats_line("--ps --port {0}".format(' '.join(str(port) for port in opts.ports)))
+ if not list(filter(lambda opt:opt[0] not in ('all_ports', 'ports') and opt[1] is not None, opts._get_kwargs())):
+ ports = opts.ports if opts.ports else self.get_all_ports()
+ self.show_stats_line("--ps --port {0}".format(' '.join(str(port) for port in ports)))
return
if opts.supp:
@@ -3859,11 +3872,13 @@ class STLClient(object):
print(' Flow control: %s' % info['fc_supported'])
print('')
else:
- self.set_port_attr(opts.ports,
- opts.prom,
- opts.link,
- opts.led,
- opts.flow_ctrl)
+ if not opts.ports:
+ raise STLError('No acquired ports!')
+ self.set_port_attr(opts.ports,
+ opts.prom,
+ opts.link,
+ opts.led,
+ opts.flow_ctrl)