summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/client
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/automation/trex_control_plane/client')
-rwxr-xr-xscripts/automation/trex_control_plane/client/trex_client.py2
-rw-r--r--scripts/automation/trex_control_plane/client/trex_hltapi.py18
-rw-r--r--scripts/automation/trex_control_plane/client/trex_root_path.py15
-rw-r--r--scripts/automation/trex_control_plane/client/trex_stateless_client.py51
4 files changed, 84 insertions, 2 deletions
diff --git a/scripts/automation/trex_control_plane/client/trex_client.py b/scripts/automation/trex_control_plane/client/trex_client.py
index 0fbb4719..56775766 100755
--- a/scripts/automation/trex_control_plane/client/trex_client.py
+++ b/scripts/automation/trex_control_plane/client/trex_client.py
@@ -1062,5 +1062,3 @@ class CTRexResult(object):
if __name__ == "__main__":
pass
-
-
diff --git a/scripts/automation/trex_control_plane/client/trex_hltapi.py b/scripts/automation/trex_control_plane/client/trex_hltapi.py
new file mode 100644
index 00000000..46c283f8
--- /dev/null
+++ b/scripts/automation/trex_control_plane/client/trex_hltapi.py
@@ -0,0 +1,18 @@
+#!/router/bin/python
+
+import trex_root_path
+from client_utils.packet_builder import CTRexPktBuilder
+
+print "done!"
+
+class CTRexHltApi(object):
+
+ def __init__(self):
+ pass
+
+ def config_traffic(self):
+ pass
+
+if __name__ == "__main__":
+ pass
+
diff --git a/scripts/automation/trex_control_plane/client/trex_root_path.py b/scripts/automation/trex_control_plane/client/trex_root_path.py
new file mode 100644
index 00000000..de4ec03b
--- /dev/null
+++ b/scripts/automation/trex_control_plane/client/trex_root_path.py
@@ -0,0 +1,15 @@
+#!/router/bin/python
+
+import os
+import sys
+
+def add_root_to_path ():
+ """adds trex_control_plane root dir to script path, up to `depth` parent dirs"""
+ root_dirname = 'trex_control_plane'
+ file_path = os.path.dirname(os.path.realpath(__file__))
+
+ components = file_path.split(os.sep)
+ sys.path.append( str.join(os.sep, components[:components.index(root_dirname)+1]) )
+ return
+
+add_root_to_path()
diff --git a/scripts/automation/trex_control_plane/client/trex_stateless_client.py b/scripts/automation/trex_control_plane/client/trex_stateless_client.py
new file mode 100644
index 00000000..5513f420
--- /dev/null
+++ b/scripts/automation/trex_control_plane/client/trex_stateless_client.py
@@ -0,0 +1,51 @@
+#!/router/bin/python
+
+try:
+ # support import for Python 2
+ import outer_packages
+except ImportError:
+ # support import for Python 3
+ import client.outer_packages
+from client_utils.jsonrpc_client import JsonRpcClient
+
+
+
+class CTRexStatelessClient(object):
+ """docstring for CTRexStatelessClient"""
+ def __init__(self, server="localhost", port=5050, virtual=False):
+ super(CTRexStatelessClient, self).__init__()
+ self.tx_link = CTRexStatelessClient.CTxLink(server, port, virtual)
+
+
+ def transmit(self, method_name, params = {}):
+ return self.tx_link.transmit(method_name, params)
+
+
+
+ class CTxLink(object):
+ """describes the connectivity of the stateless client method"""
+ def __init__(self, server="localhost", port=5050, virtual=False):
+ super(CTRexStatelessClient.CTxLink, self).__init__()
+ self.virtual = virtual
+ self.server = server
+ self.port = port
+ self.rpc_link = JsonRpcClient(self.server, self.port)
+ if not self.virtual:
+ self.rpc_link.connect()
+
+ def transmit(self, method_name, params = {}):
+ if self.virtual:
+ print "Transmitting virtually over tcp://{server}:{port}".format(
+ server=self.server,
+ port=self.port)
+ id, msg = self.rpc_link.create_jsonrpc_v2(method_name, params)
+ print msg
+ return
+ else:
+ return self.rpc_link.invoke_rpc_method(method_name, params)
+
+
+
+
+if __name__ == "__main__":
+ pass