diff options
Diffstat (limited to 'scripts/automation/trex_control_plane/client')
-rw-r--r-- | scripts/automation/trex_control_plane/client/trex_async_client.py | 2 | ||||
-rwxr-xr-x | scripts/automation/trex_control_plane/client/trex_stateless_client.py | 20 |
2 files changed, 19 insertions, 3 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) |