From 7567166ca52bd136ce08c06dcbd48c0dfd67210f Mon Sep 17 00:00:00 2001 From: imarom Date: Thu, 10 Dec 2015 03:43:55 -0500 Subject: removed session id - not necessary --- .../automation/trex_control_plane/client/trex_port.py | 4 +--- .../trex_control_plane/client/trex_stateless_client.py | 17 +++++++++++------ .../trex_control_plane/client_utils/jsonrpc_client.py | 2 +- .../trex_control_plane/console/trex_console.py | 3 ++- .../automation/trex_control_plane/console/trex_tui.py | 1 - 5 files changed, 15 insertions(+), 12 deletions(-) (limited to 'scripts/automation/trex_control_plane') diff --git a/scripts/automation/trex_control_plane/client/trex_port.py b/scripts/automation/trex_control_plane/client/trex_port.py index 68d89775..5c5702dd 100644 --- a/scripts/automation/trex_control_plane/client/trex_port.py +++ b/scripts/automation/trex_control_plane/client/trex_port.py @@ -18,7 +18,7 @@ class Port(object): STATE_PAUSE: "PAUSE"} - def __init__ (self, port_id, speed, driver, user, session_id, comm_link): + def __init__ (self, port_id, speed, driver, user, comm_link): self.port_id = port_id self.state = self.STATE_IDLE self.handler = None @@ -26,7 +26,6 @@ class Port(object): self.transmit = comm_link.transmit self.transmit_batch = comm_link.transmit_batch self.user = user - self.session_id = session_id self.driver = driver self.speed = speed self.streams = {} @@ -48,7 +47,6 @@ class Port(object): def acquire(self, force = False): params = {"port_id": self.port_id, "user": self.user, - "session_id": self.session_id, "force": force} command = RpcCmdData("acquire", params) 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 43ebea9d..6907c9c2 100755 --- a/scripts/automation/trex_control_plane/client/trex_stateless_client.py +++ b/scripts/automation/trex_control_plane/client/trex_stateless_client.py @@ -54,7 +54,6 @@ class CTRexStatelessClient(object): super(CTRexStatelessClient, self).__init__() self.user = username - self.session_id = random.getrandbits(32) self.comm_link = CTRexStatelessClient.CCommLink(server, sync_port, virtual) @@ -85,10 +84,6 @@ class CTRexStatelessClient(object): self.connected = False - # when the client gets out - def shutdown (self): - self.release(self.get_acquired_ports()) - # returns the port object def get_port (self, port_id): @@ -296,6 +291,9 @@ class CTRexStatelessClient(object): # connection sequence def connect(self, force = False): + if self.is_connected(): + self.disconnect() + # clear this flag self.connected = False @@ -335,7 +333,7 @@ class CTRexStatelessClient(object): speed = self.system_info['ports'][port_id]['speed'] driver = self.system_info['ports'][port_id]['driver'] - self.ports[port_id] = Port(port_id, speed, driver, self.user, self.session_id, self.comm_link) + self.ports[port_id] = Port(port_id, speed, driver, self.user, self.comm_link) # sync the ports @@ -365,8 +363,15 @@ class CTRexStatelessClient(object): def disconnect(self): + # release any previous acquired ports + if self.is_connected(): + self.release(self.get_acquired_ports()) + self.comm_link.disconnect() self.async_client.disconnect() + + self.connected = False + return RC_OK() 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 f55d7798..3de0bb5f 100755 --- a/scripts/automation/trex_control_plane/client_utils/jsonrpc_client.py +++ b/scripts/automation/trex_control_plane/client_utils/jsonrpc_client.py @@ -112,7 +112,7 @@ class JsonRpcClient(object): def invoke_rpc_method (self, method_name, params = {}): if not self.connected: - return False, "Not connected to server" + return CmdResponse(False, "Not connected to server") id, msg = self.create_jsonrpc_v2(method_name, params) diff --git a/scripts/automation/trex_control_plane/console/trex_console.py b/scripts/automation/trex_control_plane/console/trex_console.py index 495e1c22..e8f90186 100755 --- a/scripts/automation/trex_control_plane/console/trex_console.py +++ b/scripts/automation/trex_control_plane/console/trex_console.py @@ -575,6 +575,7 @@ def main(): rc.annotate() else: rc.annotate(show_status = False) + print format_text("Switching to read only mode - only few commands will be available", 'bold') if options.batch: @@ -590,7 +591,7 @@ def main(): print "\n\n*** Caught Ctrl + C... Exiting...\n\n" finally: - stateless_client.shutdown() + stateless_client.disconnect() if __name__ == '__main__': main() diff --git a/scripts/automation/trex_control_plane/console/trex_tui.py b/scripts/automation/trex_control_plane/console/trex_tui.py index 3ddf7a7f..2e6be4a6 100644 --- a/scripts/automation/trex_control_plane/console/trex_tui.py +++ b/scripts/automation/trex_control_plane/console/trex_tui.py @@ -289,7 +289,6 @@ class TrexTUIPanelManager(): self.generate_legend() def show (self): - print self.ports self.main_panel.show() self.print_legend() self.log.show() -- cgit 1.2.3-korg