summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/client/trex_stateless_client.py
diff options
context:
space:
mode:
authorDan Klein <danklei@cisco.com>2015-10-27 16:02:29 +0200
committerDan Klein <danklei@cisco.com>2015-10-27 16:02:29 +0200
commit3bebf60874ec07d157944088ee3cfd5909eccc0f (patch)
tree1473005a65f44ec6bd5abad8c133d8e3917a10a6 /scripts/automation/trex_control_plane/client/trex_stateless_client.py
parentd2453a6b449762b478975418289dfcfc51dcc395 (diff)
More HLTAPI
Diffstat (limited to 'scripts/automation/trex_control_plane/client/trex_stateless_client.py')
-rwxr-xr-xscripts/automation/trex_control_plane/client/trex_stateless_client.py19
1 files changed, 14 insertions, 5 deletions
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 97d3ec0a..3079ee5e 100755
--- a/scripts/automation/trex_control_plane/client/trex_stateless_client.py
+++ b/scripts/automation/trex_control_plane/client/trex_stateless_client.py
@@ -114,6 +114,9 @@ class CTRexStatelessClient(object):
def get_port_count(self):
return self.system_info.get("port_count")
+ def get_acquired_ports(self):
+ return self._conn_handler.keys()
+
def acquire(self, port_id, force=False):
if not self._is_ports_valid(port_id):
raise ValueError("Provided illegal port id input")
@@ -145,14 +148,16 @@ class CTRexStatelessClient(object):
for p_id in port_ids]
rc, resp_list = self.transmit_batch(commands)
if rc:
- self._process_batch_result(commands, resp_list, self._handle_release_response)
+ return self._process_batch_result(commands, resp_list, self._handle_release_response,
+ success_test=self.ack_success_test)
else:
self._conn_handler.pop(port_id)
params = {"handler": self._conn_handler.get(port_id),
"port_id": port_id}
command = RpcCmdData("release", params)
- self._handle_release_response(command, self.transmit(command.method, command.params))
- return
+ return self._handle_release_response(command,
+ self.transmit(command.method, command.params),
+ self.ack_success_test)
@force_status(owned=True)
def add_stream(self, stream_id, stream_obj, port_id=None):
@@ -362,8 +367,12 @@ class CTRexStatelessClient(object):
return RpcResponseStatus(False, port_id, response.data)
def _handle_release_response(self, request, response, success_test):
- if response.success:
- del self._conn_handler[request.get("port_id")]
+ port_id = request.params.get("port_id")
+ if success_test(response):
+ del self._conn_handler[port_id]
+ return RpcResponseStatus(True, port_id, "Released")
+ else:
+ return RpcResponseStatus(False, port_id, response.data)
def _handle_start_traffic_response(self, request, response, success_test):
if response.success: