diff options
author | 2015-08-26 14:27:43 +0300 | |
---|---|---|
committer | 2015-08-26 14:27:43 +0300 | |
commit | cdcc62972d42f009f55e6aeb2ca5c60c3acd75eb (patch) | |
tree | 5c3fef81ac01407a89740f2d9b8b01b0f3a47c7f /scripts/automation/trex_control_plane/client_utils | |
parent | 42053c95419042f36242b19d2416d112f7643e14 (diff) |
added dpkt package, initial stateless client implementation
Diffstat (limited to 'scripts/automation/trex_control_plane/client_utils')
3 files changed, 20 insertions, 7 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 1631c494..89ac9127 100644 --- a/scripts/automation/trex_control_plane/client_utils/jsonrpc_client.py +++ b/scripts/automation/trex_control_plane/client_utils/jsonrpc_client.py @@ -34,16 +34,16 @@ class JsonRpcClient(object): print "[verbose] " + msg - def create_jsonrpc_v2 (self, method_name, params = {}, id = None): + def create_jsonrpc_v2 (self, method_name, params = {}): msg = {} msg["jsonrpc"] = "2.0" msg["method"] = method_name msg["params"] = params - msg["id"] = id + msg["id"] = self.id_gen.next() - return json.dumps(msg) + return id, json.dumps(msg) def invoke_rpc_method (self, method_name, params = {}, block = False): rc, msg = self._invoke_rpc_method(method_name, params, block) @@ -56,8 +56,7 @@ class JsonRpcClient(object): if not self.connected: return False, "Not connected to server" - id = self.id_gen.next() - msg = self.create_jsonrpc_v2(method_name, params, id = id) + id, msg = self.create_jsonrpc_v2(method_name, params) self.verbose_msg("Sending Request To Server:\n\n" + self.pretty_json(msg) + "\n") @@ -180,7 +179,8 @@ class JsonRpcClient(object): def __del__(self): print "Shutting down RPC client\n" - self.context.destroy(linger=0) + if hasattr(self, "context"): + self.context.destroy(linger=0) if __name__ == "__main__": pass diff --git a/scripts/automation/trex_control_plane/client_utils/outer_packages.py b/scripts/automation/trex_control_plane/client_utils/outer_packages.py index 53cce991..81672c91 100644 --- a/scripts/automation/trex_control_plane/client_utils/outer_packages.py +++ b/scripts/automation/trex_control_plane/client_utils/outer_packages.py @@ -9,7 +9,9 @@ ROOT_PATH = os.path.abspath(os.path.join(CURRENT_PATH, os.pardir)) PATH_TO_PYTHON_LIB = os.path.abspath(os.path.join(ROOT_PATH, os.pardir, os.pardir, os.pardir, 'external_libs', 'python')) -CLIENT_UTILS_MODULES = ['zmq'] +CLIENT_UTILS_MODULES = ['zmq', + 'dpkt-1.8.6.2' + ] def import_client_utils_modules(): diff --git a/scripts/automation/trex_control_plane/client_utils/packet_builder.py b/scripts/automation/trex_control_plane/client_utils/packet_builder.py new file mode 100644 index 00000000..c33444a7 --- /dev/null +++ b/scripts/automation/trex_control_plane/client_utils/packet_builder.py @@ -0,0 +1,11 @@ +#!/router/bin/python + + +import outer_packages +import dpkt + +class CTRexPktBuilder(object): + """docstring for CTRexPktBuilder""" + def __init__(self, arg): + super(CTRexPktBuilder, self).__init__() + self.arg = arg
\ No newline at end of file |