diff options
Diffstat (limited to 'scripts/automation')
6 files changed, 31 insertions, 8 deletions
diff --git a/scripts/automation/trex_control_plane/client/trex_async_client.py b/scripts/automation/trex_control_plane/client/trex_async_client.py index 4c17603d..419448bb 100644 --- a/scripts/automation/trex_control_plane/client/trex_async_client.py +++ b/scripts/automation/trex_control_plane/client/trex_async_client.py @@ -149,7 +149,7 @@ class TrexAsyncStatsManager(): -class TrexAsyncClient(): +class CTRexAsyncClient(): def __init__ (self, port): self.port = port 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 c180e0d1..aeb25422 100755 --- a/scripts/automation/trex_control_plane/client/trex_stateless_client.py +++ b/scripts/automation/trex_control_plane/client/trex_stateless_client.py @@ -13,7 +13,7 @@ from common.trex_stats import * from common.trex_streams import * from collections import namedtuple -from trex_async_client import TrexAsyncClient +from trex_async_client import CTRexAsyncClient RpcCmdData = namedtuple('RpcCmdData', ['method', 'params']) @@ -41,7 +41,7 @@ class CTRexStatelessClient(object): self._server_version = None self.__err_log = None - self._async_client = TrexAsyncClient(async_port) + self._async_client = CTRexAsyncClient(async_port) # ----- decorator methods ----- # @@ -136,6 +136,9 @@ class CTRexStatelessClient(object): else: return port_ids + def sync_user(self, sync_streams=False): + return self.transmit("sync_user", {"user": self.user, "sync_streams": sync_streams}) + def get_acquired_ports(self): return self._conn_handler.keys() @@ -359,8 +362,21 @@ class CTRexStatelessClient(object): if self.server_version == "Unknown" or self.system_info == "Unknown": self.disconnect() return False, self.__err_log + # sync with previous session + res_ok, port_info = self.sync_user() + if not res_ok: + self.disconnect() + return False, port_info + else: + # handle sync data + for port in port_info: + self._conn_handler[port.get("port_id")] = port.get("handler") + if port.get("state") == "transmitting": + # port is active + self._active_ports.add(port.get("port_id")) return True, "" + def transmit(self, method_name, params={}): return self.comm_link.transmit(method_name, params) diff --git a/scripts/automation/trex_control_plane/client_utils/general_utils.py b/scripts/automation/trex_control_plane/client_utils/general_utils.py index 3c025608..69ad14b2 100755 --- a/scripts/automation/trex_control_plane/client_utils/general_utils.py +++ b/scripts/automation/trex_control_plane/client_utils/general_utils.py @@ -24,7 +24,7 @@ def user_input(): def get_current_user(): if pwd: - return pwd.getpwuid( os.geteuid() ).pw_name + return pwd.getpwuid(os.geteuid()).pw_name else: return getpass.getuser() 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 fe94e5ef..58491aba 100755 --- a/scripts/automation/trex_control_plane/client_utils/jsonrpc_client.py +++ b/scripts/automation/trex_control_plane/client_utils/jsonrpc_client.py @@ -514,3 +514,6 @@ class TrexStatelessClient(JsonRpcClient): return True, resp_list # return self.invoke_rpc_method('add_stream', params = params) + +if __name__ == "__main__": + pass
\ No newline at end of file diff --git a/scripts/automation/trex_control_plane/console/line_parsing.py b/scripts/automation/trex_control_plane/console/line_parsing.py new file mode 100644 index 00000000..34776424 --- /dev/null +++ b/scripts/automation/trex_control_plane/console/line_parsing.py @@ -0,0 +1,5 @@ +__author__ = 'danklei' + + +if __name__ == "__main__": + pass
\ No newline at end of file diff --git a/scripts/automation/trex_control_plane/console/trex_console.py b/scripts/automation/trex_control_plane/console/trex_console.py index 549262c5..e707a9e1 100755 --- a/scripts/automation/trex_control_plane/console/trex_console.py +++ b/scripts/automation/trex_control_plane/console/trex_console.py @@ -31,8 +31,7 @@ import trex_root_path from common.trex_streams import * from client.trex_stateless_client import CTRexStatelessClient from common.text_opts import * -from client_utils.general_utils import user_input - +from client_utils.general_utils import user_input, get_current_user import trex_status from collections import namedtuple @@ -778,8 +777,8 @@ def setParserOptions(): default = 4500, type = int) - parser.add_argument("-u", "--user", help = "User Name [default is random generated]\n", - default = 'user_' + ''.join(random.choice(string.digits) for _ in range(5)), + parser.add_argument("-u", "--user", help = "User Name [default is currently logged in user]\n", + default = get_current_user(), type = str) parser.add_argument("--verbose", dest="verbose", |