summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_jsonrpc_client.py
diff options
context:
space:
mode:
authorYaroslav Brustinov <ybrustin@cisco.com>2017-01-12 16:24:03 +0200
committerYaroslav Brustinov <ybrustin@cisco.com>2017-01-12 16:24:03 +0200
commit83861b490b5ce17212830a425d7c8cfd00090c40 (patch)
tree8a2ee522cf6740d015de8153a726af9937d683fd /scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_jsonrpc_client.py
parent6cdb4a984508a27a94df24ba9dabf050f3c319fd (diff)
Add help message for --no-scapy-server flag
Python API: fix arp resolve console message Python API: retry ZMQ send/recv only for push_pcap Console: portattr fix for readonly mode Change-Id: I69587987deb4edfbe192ee422ce6aad74b1ecaf3 Signed-off-by: Yaroslav Brustinov <ybrustin@cisco.com>
Diffstat (limited to 'scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_jsonrpc_client.py')
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_jsonrpc_client.py28
1 files changed, 14 insertions, 14 deletions
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_jsonrpc_client.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_jsonrpc_client.py
index 72c9317a..db216532 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_jsonrpc_client.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_jsonrpc_client.py
@@ -32,7 +32,7 @@ class BatchMessage(object):
id, msg = self.rpc_client.create_jsonrpc_v2(method_name, params, api_class, encode = False)
self.batch_list.append(msg)
- def invoke(self, block = False, chunk_size = 500000):
+ def invoke(self, block = False, chunk_size = 500000, retry = 0):
if not self.rpc_client.connected:
return RC_ERR("Not connected to server")
@@ -54,7 +54,7 @@ class BatchMessage(object):
return response_batch
else:
batch_json = json.dumps(self.batch_list)
- return self.rpc_client.send_msg(batch_json)
+ return self.rpc_client.send_msg(batch_json, retry = retry)
# JSON RPC v2.0 client
@@ -127,16 +127,16 @@ class JsonRpcClient(object):
return id, msg
- def invoke_rpc_method (self, method_name, params = None, api_class = 'core'):
+ def invoke_rpc_method (self, method_name, params = None, api_class = 'core', retry = 0):
if not self.connected:
return RC_ERR("Not connected to server")
id, msg = self.create_jsonrpc_v2(method_name, params, api_class)
- return self.send_msg(msg)
+ return self.send_msg(msg, retry = retry)
- def send_msg (self, msg):
+ def send_msg (self, msg, retry = 0):
# print before
if self.logger.check_verbose(self.logger.VERBOSE_HIGH):
self.verbose_msg("Sending Request To Server:\n\n" + self.pretty_json(msg) + "\n")
@@ -145,9 +145,9 @@ class JsonRpcClient(object):
buffer = msg.encode()
if self.zipper.check_threshold(buffer):
- response = self.send_raw_msg(self.zipper.compress(buffer))
+ response = self.send_raw_msg(self.zipper.compress(buffer), retry = retry)
else:
- response = self.send_raw_msg(buffer)
+ response = self.send_raw_msg(buffer, retry = retry)
if not response:
return response
@@ -175,16 +175,16 @@ class JsonRpcClient(object):
# low level send of string message
- def send_raw_msg (self, msg):
+ def send_raw_msg (self, msg, retry = 0):
- tries = 0
+ retry_left = retry
while True:
try:
self.socket.send(msg)
break
except zmq.Again:
- tries += 1
- if tries > 5:
+ retry_left -= 1
+ if retry_left < 0:
self.disconnect()
return RC_ERR("*** [RPC] - Failed to send message to server")
@@ -193,14 +193,14 @@ class JsonRpcClient(object):
self.reconnect()
raise e
- tries = 0
+ retry_left = retry
while True:
try:
response = self.socket.recv()
break
except zmq.Again:
- tries += 1
- if tries > 5:
+ retry_left -= 1
+ if retry_left < 0:
self.disconnect()
return RC_ERR("*** [RPC] - Failed to get server response from {0}".format(self.transport))