diff options
author | imarom <imarom@cisco.com> | 2015-12-10 03:43:55 -0500 |
---|---|---|
committer | imarom <imarom@cisco.com> | 2015-12-10 05:54:45 -0500 |
commit | 7567166ca52bd136ce08c06dcbd48c0dfd67210f (patch) | |
tree | a579cd80a0cd47476d0ac4fd47c0e6a5e9628d3c | |
parent | 95c2405d6373ca3c6b69efc3faf293cd41a55c76 (diff) |
removed session id - not necessary
9 files changed, 23 insertions, 32 deletions
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() diff --git a/src/rpc-server/commands/trex_rpc_cmd_general.cpp b/src/rpc-server/commands/trex_rpc_cmd_general.cpp index 6c239bf3..a2d4c284 100644 --- a/src/rpc-server/commands/trex_rpc_cmd_general.cpp +++ b/src/rpc-server/commands/trex_rpc_cmd_general.cpp @@ -235,14 +235,13 @@ TrexRpcCmdAcquire::_run(const Json::Value ¶ms, Json::Value &result) { uint8_t port_id = parse_port(params, result); const string &new_owner = parse_string(params, "user", result); - uint32_t session_id = parse_uint32(params, "session_id", result); bool force = parse_bool(params, "force", result); /* if not free and not you and not force - fail */ TrexStatelessPort *port = get_stateless_obj()->get_port_by_id(port_id); try { - port->acquire(new_owner, session_id, force); + port->acquire(new_owner, force); } catch (const TrexRpcException &ex) { generate_execute_err(result, ex.what()); } diff --git a/src/rpc-server/commands/trex_rpc_cmds.h b/src/rpc-server/commands/trex_rpc_cmds.h index b9be1fbe..c22ef390 100644 --- a/src/rpc-server/commands/trex_rpc_cmds.h +++ b/src/rpc-server/commands/trex_rpc_cmds.h @@ -70,7 +70,7 @@ void get_hostname(std::string &hostname); * ownership */ TREX_RPC_CMD_DEFINE(TrexRpcCmdGetOwner, "get_owner", 1, false); -TREX_RPC_CMD_DEFINE(TrexRpcCmdAcquire, "acquire", 4, false); +TREX_RPC_CMD_DEFINE(TrexRpcCmdAcquire, "acquire", 3, false); TREX_RPC_CMD_DEFINE(TrexRpcCmdRelease, "release", 1, true); diff --git a/src/stateless/cp/trex_stateless_port.cpp b/src/stateless/cp/trex_stateless_port.cpp index 96194321..9770c735 100644 --- a/src/stateless/cp/trex_stateless_port.cpp +++ b/src/stateless/cp/trex_stateless_port.cpp @@ -84,22 +84,16 @@ TrexStatelessPort::TrexStatelessPort(uint8_t port_id, const TrexPlatformApi *api * @param force */ void -TrexStatelessPort::acquire(const std::string &user, uint32_t session_id, bool force) { +TrexStatelessPort::acquire(const std::string &user, bool force) { /* if port is free - just take it */ if (get_owner().is_free()) { - get_owner().own(user, session_id); + get_owner().own(user); return; } - /* not free - but it might be the same user that owns the port */ - if ( (get_owner().get_name() == user) && (get_owner().get_session_id() == session_id) ) { - return; - } - - /* so different session id or different user */ if (force) { - get_owner().own(user, session_id); + get_owner().own(user); /* inform the other client of the steal... */ Json::Value data; diff --git a/src/stateless/cp/trex_stateless_port.h b/src/stateless/cp/trex_stateless_port.h index 1310fdb2..4988b46a 100644 --- a/src/stateless/cp/trex_stateless_port.h +++ b/src/stateless/cp/trex_stateless_port.h @@ -58,11 +58,10 @@ public: return ( !m_is_free && (m_owner_name == user) ); } - void own(const std::string &owner_name, uint32_t session_id) { + void own(const std::string &owner_name) { /* save user data */ m_owner_name = owner_name; - m_session_id = session_id; /* internal data */ m_handler = generate_handler(); @@ -81,9 +80,6 @@ public: return (!m_is_free ? m_handler : g_unowned_handler); } - uint32_t get_session_id() { - return m_session_id; - } private: std::string generate_handler(); @@ -91,9 +87,8 @@ private: /* is this port owned by someone ? */ bool m_is_free; - /* user provided info - name and session id */ + /* user provided info */ std::string m_owner_name; - uint32_t m_session_id; /* handler genereated internally */ std::string m_handler; @@ -143,7 +138,7 @@ public: * acquire port * throws TrexException in case of an error */ - void acquire(const std::string &user, uint32_t session_id, bool force = false); + void acquire(const std::string &user, bool force = false); /** * release the port from the current user |