summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/client_utils
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-01-17 04:28:55 -0500
committerimarom <imarom@cisco.com>2016-01-21 10:11:54 -0500
commit11d328d3e40b04540489eec83ac484d5b06254bb (patch)
tree63e512cd9d6a6911eddecc38dd9b17374e53bff3 /scripts/automation/trex_control_plane/client_utils
parent9c9173a53fc09d08cf39e614dffa24f4e21a69e9 (diff)
draft of test API for stateless
Diffstat (limited to 'scripts/automation/trex_control_plane/client_utils')
-rwxr-xr-xscripts/automation/trex_control_plane/client_utils/jsonrpc_client.py22
1 files changed, 6 insertions, 16 deletions
diff --git a/scripts/automation/trex_control_plane/client_utils/jsonrpc_client.py b/scripts/automation/trex_control_plane/client_utils/jsonrpc_client.py
index bdae7bd9..a5e01340 100755
--- a/scripts/automation/trex_control_plane/client_utils/jsonrpc_client.py
+++ b/scripts/automation/trex_control_plane/client_utils/jsonrpc_client.py
@@ -42,8 +42,8 @@ class BatchMessage(object):
# JSON RPC v2.0 client
class JsonRpcClient(object):
- def __init__ (self, default_server, default_port, prn_func = None):
- self.verbose = False
+ def __init__ (self, default_server, default_port, logger):
+ self.logger = logger
self.connected = False
# default values
@@ -51,7 +51,6 @@ class JsonRpcClient(object):
self.server = default_server
self.id_gen = general_utils.random_id_gen()
- self.prn_func = prn_func
def get_connection_details (self):
rc = {}
@@ -82,10 +81,7 @@ class JsonRpcClient(object):
return pretty_str
def verbose_msg (self, msg):
- if not self.verbose:
- return
-
- print "[verbose] " + msg
+ self.logger.log("[verbose] " + msg, level = self.logger.VERBOSE_HIGH)
# batch messages
@@ -183,10 +179,7 @@ class JsonRpcClient(object):
return RC_OK(response_json["result"])
-
- def set_verbose(self, mode):
- self.verbose = mode
def disconnect (self):
if self.connected:
@@ -198,7 +191,7 @@ class JsonRpcClient(object):
return RC_ERR("Not connected to server")
- def connect(self, server = None, port = None, prn_func = None):
+ def connect(self, server = None, port = None):
if self.connected:
self.disconnect()
@@ -211,10 +204,7 @@ class JsonRpcClient(object):
self.transport = "tcp://{0}:{1}".format(self.server, self.port)
msg = "\nConnecting To RPC Server On {0}".format(self.transport)
- if self.prn_func:
- self.prn_func(msg)
- else:
- print msg
+ self.logger.log(msg)
self.socket = self.context.socket(zmq.REQ)
try:
@@ -245,7 +235,7 @@ class JsonRpcClient(object):
return self.connected
def __del__(self):
- print "Shutting down RPC client\n"
+ self.logger.log("Shutting down RPC client\n")
if hasattr(self, "context"):
self.context.destroy(linger=0)