From 3f1495c6f4ca3f63f6e1802c0e5ce9f0bbaf02b0 Mon Sep 17 00:00:00 2001 From: hna Date: Thu, 29 Jun 2023 09:59:51 +0000 Subject: [PATCH 1/7] Merge RX and TX pp_commands for both Pre/Gray Coding --- xoa_driver/enums.py | 8 +- xoa_driver/internals/commands/enums.py | 8 +- xoa_driver/internals/commands/pp_commands.py | 202 ++++++------------- 3 files changed, 75 insertions(+), 143 deletions(-) diff --git a/xoa_driver/enums.py b/xoa_driver/enums.py index 6cb61d3c..df5ff44a 100644 --- a/xoa_driver/enums.py +++ b/xoa_driver/enums.py @@ -161,8 +161,8 @@ LinkTrainEncoding, LinkTrainPresets, AnLtLogControl, - PreCodingStatus, - GrayCodingStatus, + PreCodingMode, + GrayCodingMode, Endianness ) @@ -327,7 +327,7 @@ "LinkTrainEncoding", "LinkTrainPresets", "AnLtLogControl", - "PreCodingStatus", - "GrayCodingStatus", + "PreCodingMode", + "GrayCodingMode", "Endianness" ) diff --git a/xoa_driver/internals/commands/enums.py b/xoa_driver/internals/commands/enums.py index 470a6009..bb529d11 100644 --- a/xoa_driver/internals/commands/enums.py +++ b/xoa_driver/internals/commands/enums.py @@ -2458,8 +2458,8 @@ class AnLtLogControl(IntEnum): LOG_TYPE_FSM_LT_ALG1 = 0x800000 """link training algorithm -1 state machine transitions""" -class PreCodingStatus(IntEnum): - """Rx/Tx Pre-Coding Status.""" +class PreCodingMode(IntEnum): + """Rx/Tx Pre-Coding Mode.""" OFF = 0 """Off""" @@ -2470,8 +2470,8 @@ class PreCodingStatus(IntEnum): AUTO = 2 """Auto""" -class GrayCodingStatus(IntEnum): - """Rx/Tx Gray-Coding Status.""" +class GrayCodingMode(IntEnum): + """Rx/Tx Gray-Coding Mode.""" OFF = 0 """Off""" diff --git a/xoa_driver/internals/commands/pp_commands.py b/xoa_driver/internals/commands/pp_commands.py index f09bab6c..6c0078e6 100644 --- a/xoa_driver/internals/commands/pp_commands.py +++ b/xoa_driver/internals/commands/pp_commands.py @@ -55,8 +55,8 @@ PRBSPattern, PHYSignalStatus, OnOffDefault, - PreCodingStatus, - GrayCodingStatus, + PreCodingMode, + GrayCodingMode, Endianness ) @@ -2094,11 +2094,11 @@ def get(self) -> Token[GetDataAttr]: @register_command @dataclass -class PP_RXPRECODING: +class PP_PRECODING: """ - GET/SET Rx Pre-Coding Configurations. + GET/SET Pre-Coding Configurations. """ - + code: typing.ClassVar[int] = 420 pushed: typing.ClassVar[bool] = True @@ -2108,139 +2108,58 @@ class PP_RXPRECODING: _serdes_xindex: int class GetDataAttr(ResponseBodyStruct): - status: PreCodingStatus = field(XmpInt()) - """Status Off/On/Auto""" - endianness: Endianness = field(XmpInt()) - """Endianness Normal/Reverted(BigEndian/LittleEndian)) """ + rx_mode: PreCodingMode = field(XmpInt()) + """RX Mode Off/On/Auto""" + rx_endianness: Endianness = field(XmpInt()) + """RX Endianness Normal/Reverted(BigEndian/LittleEndian)) """ + tx_mode: PreCodingMode = field(XmpInt()) + """TX Mode Off/On/Auto""" + tx_endianness: Endianness = field(XmpInt()) + """TX Endianness Normal/Reverted(BigEndian/LittleEndian)) """ class SetDataAttr(RequestBodyStruct): - status: PreCodingStatus = field(XmpInt()) - """Status Off/On/Auto""" - endianness: Endianness = field(XmpInt()) - """Endianness Normal/Reverted(BigEndian/LittleEndian)) """ + rx_mode: PreCodingMode = field(XmpInt()) + """RX Mode Off/On/Auto""" + rx_endianness: Endianness = field(XmpInt()) + """RX Endianness Normal/Reverted(BigEndian/LittleEndian)) """ + tx_mode: PreCodingMode = field(XmpInt()) + """TX Mode Off/On/Auto""" + tx_endianness: Endianness = field(XmpInt()) + """TX Endianness Normal/Reverted(BigEndian/LittleEndian)) """ def get(self) -> Token[GetDataAttr]: - """Get the Rx Pre-Coding Configurations. + """Get the Pre-Coding Configurations. - :return: Rx Pre-Coding configurations including status, and endianness type. - :rtype: PP_RXPRECODING.GetDataAttr + :return: Pre-Coding configurations including rx_mode, rx_endianness, tx_mode, and tx_endianness. + :rtype: PP_PRECODING.GetDataAttr """ return Token(self._connection, build_get_request(self, module=self._module, port=self._port, indices=[self._serdes_xindex])) - def set(self, status: PreCodingStatus, endianness: Endianness) -> Token[None]: + def set(self, rx_mode: PreCodingMode, rx_endianness: Endianness, tx_mode: PreCodingMode, tx_endianness: Endianness) -> Token[None]: """Set the Rx Pre-coding settings of the PHY. - :param status: The status(Off/On/Auto) - :type status: PreCodingStatus - :param endianness: Endianness type + :param rx_mode: The RX Mode(Off/On/Auto) + :type rx_mode: PreCodingMode + :param rx_endianness: RX Endianness type + :type rx_endianness: Endianness + :param tx_mode: The TX Mode(Off/On/Auto) + :type tx_mode: PreCodingMode + :param tx_endianness: TX Endianness type :type endianness: Endianness """ - return Token(self._connection, build_set_request(self, module=self._module, port=self._port, indices=[self._serdes_xindex], status=status, endianness=endianness)) - -@register_command -@dataclass -class PP_TXPRECODING: - """ - GET/SET Tx Pre-Coding Configurations. - """ - - code: typing.ClassVar[int] = 421 - pushed: typing.ClassVar[bool] = True - - _connection: 'interfaces.IConnection' - _module: int - _port: int - _serdes_xindex: int - - class GetDataAttr(ResponseBodyStruct): - status: PreCodingStatus = field(XmpInt()) - """Status Off/On/Auto""" - endianness: Endianness = field(XmpInt()) - """Endianness Normal/Reverted(BigEndian/LittleEndian)) """ - - class SetDataAttr(RequestBodyStruct): - status: PreCodingStatus = field(XmpInt()) - """Status Off/On/Auto""" - endianness: Endianness = field(XmpInt()) - """Endianness Normal/Reverted(BigEndian/LittleEndian)) """ - - def get(self) -> Token[GetDataAttr]: - """Get the Tx Pre-Coding Configurations. - - :return: Tx Pre-Coding configurations including status, and endianness type. - :rtype: PP_TXPRECODING.GetDataAttr - """ - - return Token(self._connection, build_get_request(self, module=self._module, port=self._port, indices=[self._serdes_xindex])) - - def set(self, status: PreCodingStatus, endianness: Endianness) -> Token[None]: - """Set the Tx Pre-coding settings of the PHY. + return Token(self._connection, build_set_request(self, module=self._module, port=self._port, indices=[self._serdes_xindex], + rx_mode=rx_mode, rx_endianness=rx_endianness, tx_mode=tx_mode, tx_endianness=tx_endianness)) - :param status: The status(Off/On/Auto) - :type status: PreCodingStatus - :param endianness: Endianness type - :type endianness: Endianness - """ - - return Token(self._connection, build_set_request(self, module=self._module, port=self._port, indices=[self._serdes_xindex], status=status, endianness=endianness)) - @register_command @dataclass -class PP_RXGRAYCODING: +class PP_GRAYCODING: """ - GET/SET Rx Gray-Coding Configurations. + GET/SET Gray-Coding Configurations. """ - - code: typing.ClassVar[int] = 422 - pushed: typing.ClassVar[bool] = True - - _connection: 'interfaces.IConnection' - _module: int - _port: int - _serdes_xindex: int - - class GetDataAttr(ResponseBodyStruct): - status: GrayCodingStatus = field(XmpInt()) - """Status Off/On""" - endianness: Endianness = field(XmpInt()) - """Endianness Normal/Reverted(BigEndian/LittleEndian)) """ - - class SetDataAttr(RequestBodyStruct): - status: GrayCodingStatus = field(XmpInt()) - """Status Off/On""" - endianness: Endianness = field(XmpInt()) - """Endianness Normal/Reverted(BigEndian/LittleEndian)) """ - - def get(self) -> Token[GetDataAttr]: - """Get the Rx Gray-Coding Configurations. - - :return: Rx Gray-Coding configurations including status, and endianness type. - :rtype: PP_RXGRAYCODING.GetDataAttr - """ - - return Token(self._connection, build_get_request(self, module=self._module, port=self._port, indices=[self._serdes_xindex])) - - def set(self, status: GrayCodingStatus, endianness: Endianness) -> Token[None]: - """Set the Rx Gray-coding settings of the PHY. - - :param status: The status(Off/On) - :type status: GrayCodingStatus - :param endianness: Endianness type - :type endianness: Endianness - """ - - return Token(self._connection, build_set_request(self, module=self._module, port=self._port, indices=[self._serdes_xindex], status=status, endianness=endianness)) -@register_command -@dataclass -class PP_TXGRAYCODING: - """ - GET/SET Tx Gray-Coding Configurations. - """ - - code: typing.ClassVar[int] = 423 + code: typing.ClassVar[int] = 421 pushed: typing.ClassVar[bool] = True _connection: 'interfaces.IConnection' @@ -2249,33 +2168,46 @@ class PP_TXGRAYCODING: _serdes_xindex: int class GetDataAttr(ResponseBodyStruct): - status: GrayCodingStatus = field(XmpInt()) - """Status Off/On/Auto""" - endianness: Endianness = field(XmpInt()) - """Endianness Normal/Reverted(BigEndian/LittleEndian)) """ + rx_mode: GrayCodingMode = field(XmpInt()) + """RX Mode Off/On/Auto""" + rx_endianness: Endianness = field(XmpInt()) + """RX Endianness Normal/Reverted(BigEndian/LittleEndian)) """ + tx_mode: GrayCodingMode = field(XmpInt()) + """TX Mode Off/On/Auto""" + tx_endianness: Endianness = field(XmpInt()) + """TX Endianness Normal/Reverted(BigEndian/LittleEndian)) """ class SetDataAttr(RequestBodyStruct): - status: GrayCodingStatus = field(XmpInt()) - """Status Off/On/Auto""" - endianness: Endianness = field(XmpInt()) - """Endianness Normal/Reverted(BigEndian/LittleEndian)) """ + rx_mode: GrayCodingMode = field(XmpInt()) + """RX Mode Off/On/Auto""" + rx_endianness: Endianness = field(XmpInt()) + """RX Endianness Normal/Reverted(BigEndian/LittleEndian)) """ + tx_mode: GrayCodingMode = field(XmpInt()) + """TX Mode Off/On/Auto""" + tx_endianness: Endianness = field(XmpInt()) + """TX Endianness Normal/Reverted(BigEndian/LittleEndian)) """ def get(self) -> Token[GetDataAttr]: - """Get the Tx Gray-Coding Configurations. + """Get the Gray-Coding Configurations. - :return: Tx Gray-Coding configurations including status, and endianness type. - :rtype: PP_TXGRAYCODING.GetDataAttr + :return: Gray-Coding configurations including rx_mode, rx_endianness, tx_mode, and tx_endianness. + :rtype: PP_GRAYCODING.GetDataAttr """ return Token(self._connection, build_get_request(self, module=self._module, port=self._port, indices=[self._serdes_xindex])) - def set(self, status: GrayCodingStatus, endianness: Endianness) -> Token[None]: - """Set the Tx Gray-coding settings of the PHY. + def set(self, rx_mode: GrayCodingMode, rx_endianness: Endianness, tx_mode: GrayCodingMode, tx_endianness: Endianness) -> Token[None]: + """Set the Rx Gray-coding settings of the PHY. - :param status: The status(Off/On/Auto) - :type status: GrayCodingStatus - :param endianness: Endianness type + :param rx_mode: The RX Mode(Off/On/Auto) + :type rx_mode: GrayCodingMode + :param rx_endianness: RX Endianness type + :type rx_endianness: Endianness + :param tx_mode: The TX Mode(Off/On/Auto) + :type tx_mode: GrayCodingMode + :param tx_endianness: TX Endianness type :type endianness: Endianness """ - return Token(self._connection, build_set_request(self, module=self._module, port=self._port, indices=[self._serdes_xindex], status=status, endianness=endianness)) \ No newline at end of file + return Token(self._connection, build_set_request(self, module=self._module, port=self._port, indices=[self._serdes_xindex], + rx_mode=rx_mode, rx_endianness=rx_endianness, tx_mode=tx_mode, tx_endianness=tx_endianness)) \ No newline at end of file From ce335a19459a7471012bf20037cc9d05a89fd0e8 Mon Sep 17 00:00:00 2001 From: hna Date: Thu, 29 Jun 2023 10:04:02 +0000 Subject: [PATCH 2/7] Change Status parameter to Mode for Pre/Gray Coding --- xoa_driver/internals/commands/enums.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xoa_driver/internals/commands/enums.py b/xoa_driver/internals/commands/enums.py index f7c24b95..45925b83 100644 --- a/xoa_driver/internals/commands/enums.py +++ b/xoa_driver/internals/commands/enums.py @@ -2459,8 +2459,8 @@ class AnLtLogControl(IntEnum): """link training algorithm -1 state machine transitions""" -class PreCodingStatus(IntEnum): - """Rx/Tx Pre-Coding Status.""" +class PreCodingMode(IntEnum): + """Rx/Tx Pre-Coding Mode.""" OFF = 0 """Off""" From 78aee55657784ed15aac2bc39dac1a8384c003cb Mon Sep 17 00:00:00 2001 From: hna Date: Thu, 29 Jun 2023 13:02:33 +0000 Subject: [PATCH 3/7] Change status parameter to mode for RXEQ_EXT command --- xoa_driver/enums.py | 4 ++-- xoa_driver/internals/commands/enums.py | 8 ++++---- xoa_driver/internals/commands/pp_commands.py | 20 ++++++++++---------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/xoa_driver/enums.py b/xoa_driver/enums.py index b1d726ba..9715dc16 100644 --- a/xoa_driver/enums.py +++ b/xoa_driver/enums.py @@ -162,7 +162,7 @@ LinkTrainPresets, AnLtLogControl, RxEqExtCap, - RxEqExtCapStatus, + RxEqExtCapMode, PreCodingMode, GrayCodingMode, Endianness @@ -330,7 +330,7 @@ "LinkTrainPresets", "AnLtLogControl", "RxEqExtCap", - "RxEqExtCapStatus", + "RxEqExtCapMode", "PreCodingMode", "GrayCodingMode", "Endianness" diff --git a/xoa_driver/internals/commands/enums.py b/xoa_driver/internals/commands/enums.py index 06ffc7ad..99d296ac 100644 --- a/xoa_driver/internals/commands/enums.py +++ b/xoa_driver/internals/commands/enums.py @@ -2469,16 +2469,16 @@ class RxEqExtCap(IntEnum): """CTLE high frequency.""" -class RxEqExtCapStatus(IntEnum): +class RxEqExtCapMode(IntEnum): """Status for Rx Equalizer Advanced Capability.""" - STATUS_AUTO = 0 + AUTO = 0 """Auto.""" - STATUS_MANUAL = 1 + MANUAL = 1 """Manual.""" - STATUS_FREEZE = 2 + FREEZE = 2 """Freeze.""" class PreCodingMode(IntEnum): diff --git a/xoa_driver/internals/commands/pp_commands.py b/xoa_driver/internals/commands/pp_commands.py index a15fd990..4be34408 100644 --- a/xoa_driver/internals/commands/pp_commands.py +++ b/xoa_driver/internals/commands/pp_commands.py @@ -56,7 +56,7 @@ PHYSignalStatus, OnOffDefault, RxEqExtCap, - RxEqExtCapStatus, + RxEqExtCapMode, PreCodingMode, GrayCodingMode, Endianness @@ -1875,37 +1875,37 @@ class PP_PHYRXEQ_EXT: _capability_type: RxEqExtCap class GetDataAttr(ResponseBodyStruct): - status: RxEqExtCapStatus = field(XmpInt()) - """The status of the capability""" + mode: RxEqExtCapMode = field(XmpInt()) + """The capability mode""" value: int = field(XmpInt()) """The value for the capability""" class SetDataAttr(RequestBodyStruct): - status: RxEqExtCapStatus = field(XmpInt()) - """The status of the capability Auto/Manual/Freeze""" + mode: RxEqExtCapMode = field(XmpInt()) + """The capability mode Auto/Manual/Freeze""" value: int = field(XmpInt()) """The value for the capability""" def get(self) -> Token[GetDataAttr]: """Get RX EQ Advanced parameters. - :return: status Auto/Manual/Freeze, value. + :return: mode Auto/Manual/Freeze, value. :rtype: PP_PHYRXEQ_EXT.GetDataAttr """ return Token(self._connection, build_get_request(self, module=self._module, port=self._port, indices=[self._serdes_xindex, self._capability_type])) - def set(self, status: RxEqExtCapStatus, value: int) -> Token[None]: + def set(self, mode: RxEqExtCapMode, value: int) -> Token[None]: """Set RX EQ Advanced parameters. The type of the capability(RxEqExtCap) should be passed as the second index. - :param status: Auto/Manual/Freeze - :type status: RxEqExtCapStatus + :param mode: Auto/Manual/Freeze + :type mode: RxEqExtCapMode :param value: The value for the capability :type value: int """ - return Token(self._connection, build_set_request(self, module=self._module, port=self._port, indices=[self._serdes_xindex, self._capability_type], status=status, value=value)) + return Token(self._connection, build_set_request(self, module=self._module, port=self._port, indices=[self._serdes_xindex, self._capability_type], mode=mode, value=value)) @register_command From 99c10e8e7b6b1234a8ea0b78ad0180e7c0662ba1 Mon Sep 17 00:00:00 2001 From: ArtemConstantinov Date: Mon, 14 Aug 2023 17:02:54 +0800 Subject: [PATCH 4/7] expose changing of the session timeout --- .../internals/hli_v1/testers/_base_tester.py | 11 ++++++--- .../internals/hli_v1/testers/l23_tester.py | 13 ++++++---- .../internals/hli_v1/testers/l23ve_tester.py | 13 ++++++---- .../internals/hli_v1/testers/l47_tester.py | 13 ++++++---- .../internals/hli_v1/testers/l47ve_tester.py | 13 ++++++---- .../internals/hli_v2/testers/_base_tester.py | 22 ++++++++++++++++- .../internals/hli_v2/testers/l23_tester.py | 24 ++++++++++++++++--- .../internals/hli_v2/testers/l23ve_tester.py | 24 ++++++++++++++++--- .../internals/hli_v2/testers/l47_tester.py | 24 ++++++++++++++++--- .../internals/hli_v2/testers/l47ve_tester.py | 24 ++++++++++++++++--- xoa_driver/internals/utils/session.py | 11 ++++++++- 11 files changed, 159 insertions(+), 33 deletions(-) diff --git a/xoa_driver/internals/hli_v1/testers/_base_tester.py b/xoa_driver/internals/hli_v1/testers/_base_tester.py index 02a99d12..23f99ffa 100644 --- a/xoa_driver/internals/hli_v1/testers/_base_tester.py +++ b/xoa_driver/internals/hli_v1/testers/_base_tester.py @@ -52,11 +52,15 @@ class BaseTester(ABC, Generic[TesterStateStorage]): :type password: str, optional :param port: the port number for connection establishment, default to 22606 :type port: int, optional - :param debug: `True` if debug log output from the tester is needed, and `False` otherwise - :type debug: int, optional + :param enable_logging: `True` if debug log output from the tester is needed, and `False` otherwise + :type enable_logging: bool + :param custom_logger: `None` allow to specify logger with custom configurations + :type enable_logging: CustomLogger | None + :param session_timeout: `130` Session timeout in seconds + :type session_timeout: int """ - def __init__(self, host: str, username: str, password: str = "xena", port: int = 22606, *, enable_logging: bool = False, custom_logger: CustomLogger | None = None) -> None: + def __init__(self, host: str, username: str, password: str = "xena", port: int = 22606, *, enable_logging: bool = False, custom_logger: CustomLogger | None = None, session_timeout: int = 130) -> None: self.__host = host self.__port = port self._conn = TransportationHandler( @@ -67,6 +71,7 @@ def __init__(self, host: str, username: str, password: str = "xena", port: int = self._conn, username, password=password, + timeout_seconds=session_timeout, keepalive=True, ) """ diff --git a/xoa_driver/internals/hli_v1/testers/l23_tester.py b/xoa_driver/internals/hli_v1/testers/l23_tester.py index 991610b7..16c32202 100644 --- a/xoa_driver/internals/hli_v1/testers/l23_tester.py +++ b/xoa_driver/internals/hli_v1/testers/l23_tester.py @@ -67,18 +67,23 @@ class L23Tester(BaseTester["testers_state.GenuineTesterLocalState"]): :type password: str, optional :param port: the port number for connection establishment, default to 22606 :type port: int, optional - :param debug: `True` if debug log output from the tester is needed, and `False` otherwise - :type debug: int, optional + :param enable_logging: `True` if debug log output from the tester is needed, and `False` otherwise + :type enable_logging: bool + :param custom_logger: `None` allow to specify logger with custom configurations + :type enable_logging: CustomLogger | None + :param session_timeout: `130` Session timeout in seconds + :type session_timeout: int """ - def __init__(self, host: str, username: str, password: str = "xena", port: int = 22606, *, enable_logging: bool = False, custom_logger: CustomLogger | None = None) -> None: + def __init__(self, host: str, username: str, password: str = "xena", port: int = 22606, *, enable_logging: bool = False, custom_logger: CustomLogger | None = None, session_timeout: int = 130) -> None: super().__init__( host=host, username=username, password=password, port=port, enable_logging=enable_logging, - custom_logger=custom_logger + custom_logger=custom_logger, + session_timeout=session_timeout ) self._local_states = testers_state.GenuineTesterLocalState(host, port) diff --git a/xoa_driver/internals/hli_v1/testers/l23ve_tester.py b/xoa_driver/internals/hli_v1/testers/l23ve_tester.py index 35480f1d..f30eca46 100644 --- a/xoa_driver/internals/hli_v1/testers/l23ve_tester.py +++ b/xoa_driver/internals/hli_v1/testers/l23ve_tester.py @@ -37,18 +37,23 @@ class L23VeTester(BaseTester["testers_state.TesterLocalState"]): :type password: str, optional :param port: the port number for connection establishment, default to 22606 :type port: int, optional - :param debug: `True` if debug log output from the tester is needed, and `False` otherwise - :type debug: int, optional + :param enable_logging: `True` if debug log output from the tester is needed, and `False` otherwise + :type enable_logging: bool + :param custom_logger: `None` allow to specify logger with custom configurations + :type enable_logging: CustomLogger | None + :param session_timeout: `130` Session timeout in seconds + :type session_timeout: int """ - def __init__(self, host: str, username: str, password: str = "xena", port: int = 22606, *, enable_logging: bool = False, custom_logger: CustomLogger | None = None) -> None: + def __init__(self, host: str, username: str, password: str = "xena", port: int = 22606, *, enable_logging: bool = False, custom_logger: CustomLogger | None = None, session_timeout: int = 130) -> None: super().__init__( host=host, username=username, password=password, port=port, enable_logging=enable_logging, - custom_logger=custom_logger + custom_logger=custom_logger, + session_timeout=session_timeout ) self._local_states = testers_state.TesterLocalState(host, port) diff --git a/xoa_driver/internals/hli_v1/testers/l47_tester.py b/xoa_driver/internals/hli_v1/testers/l47_tester.py index f75cad18..b879f386 100644 --- a/xoa_driver/internals/hli_v1/testers/l47_tester.py +++ b/xoa_driver/internals/hli_v1/testers/l47_tester.py @@ -44,18 +44,23 @@ class L47Tester(BaseTester["testers_state.GenuineTesterLocalState"]): :type password: str, optional :param port: the port number for connection establishment, default to 22606 :type port: int, optional - :param debug: `True` if debug log output from the tester is needed, and `False` otherwise - :type debug: int, optional + :param enable_logging: `True` if debug log output from the tester is needed, and `False` otherwise + :type enable_logging: bool + :param custom_logger: `None` allow to specify logger with custom configurations + :type enable_logging: CustomLogger | None + :param session_timeout: `130` Session timeout in seconds + :type session_timeout: int """ - def __init__(self, host: str, username: str, password: str = "xena", port: int = 22606, *, enable_logging: bool = False, custom_logger: CustomLogger | None = None) -> None: + def __init__(self, host: str, username: str, password: str = "xena", port: int = 22606, *, enable_logging: bool = False, custom_logger: CustomLogger | None = None, session_timeout: int = 130) -> None: super().__init__( host=host, username=username, password=password, port=port, enable_logging=enable_logging, - custom_logger=custom_logger + custom_logger=custom_logger, + session_timeout=session_timeout ) self._local_states = testers_state.GenuineTesterLocalState(host, port) diff --git a/xoa_driver/internals/hli_v1/testers/l47ve_tester.py b/xoa_driver/internals/hli_v1/testers/l47ve_tester.py index a86b632b..a077eef0 100644 --- a/xoa_driver/internals/hli_v1/testers/l47ve_tester.py +++ b/xoa_driver/internals/hli_v1/testers/l47ve_tester.py @@ -21,18 +21,23 @@ class L47VeTester(L47Tester): :type password: str, optional :param port: the port number for connection establishment, default to 22606 :type port: int, optional - :param debug: `True` if debug log output from the tester is needed, and `False` otherwise - :type debug: int, optional + :param enable_logging: `True` if debug log output from the tester is needed, and `False` otherwise + :type enable_logging: bool + :param custom_logger: `None` allow to specify logger with custom configurations + :type enable_logging: CustomLogger | None + :param session_timeout: `130` Session timeout in seconds + :type session_timeout: int """ - def __init__(self, host: str, username: str, password: str = "xena", port: int = 22606, *, enable_logging: bool = False, custom_logger: CustomLogger | None = None) -> None: + def __init__(self, host: str, username: str, password: str = "xena", port: int = 22606, *, enable_logging: bool = False, custom_logger: CustomLogger | None = None, session_timeout: int = 130) -> None: super().__init__( host=host, username=username, password=password, port=port, enable_logging=enable_logging, - custom_logger=custom_logger + custom_logger=custom_logger, + session_timeout=session_timeout ) self.version_no_minor = C_VERSIONNO_MINOR(self._conn) """ diff --git a/xoa_driver/internals/hli_v2/testers/_base_tester.py b/xoa_driver/internals/hli_v2/testers/_base_tester.py index f7d36570..05ef2711 100644 --- a/xoa_driver/internals/hli_v2/testers/_base_tester.py +++ b/xoa_driver/internals/hli_v2/testers/_base_tester.py @@ -41,7 +41,26 @@ # min version = rel v83.2 eq fw v446.5 class BaseTester(ABC, Generic[TesterStateStorage]): - def __init__(self, host: str, username: str, password: str = "xena", port: int = 22606, *, enable_logging: bool = False, custom_logger: CustomLogger | None = None) -> None: + """ + Basic Tester class of APIv2. + + :param host: tester's address/hostname + :type host: str + :param username: username of the user + :type username: str + :param password: login password of the tester, defaults to "xena" + :type password: str, optional + :param port: the port number for connection establishment, default to 22606 + :type port: int, optional + :param enable_logging: `True` if debug log output from the tester is needed, and `False` otherwise + :type enable_logging: bool + :param custom_logger: `None` allow to specify logger with custom configurations + :type enable_logging: CustomLogger | None + :param session_timeout: `130` Session timeout in seconds + :type session_timeout: int + """ + + def __init__(self, host: str, username: str, password: str = "xena", port: int = 22606, *, enable_logging: bool = False, custom_logger: CustomLogger | None = None, session_timeout: int = 130) -> None: self.__host = host self.__port = port self._conn = TransportationHandler( @@ -52,6 +71,7 @@ def __init__(self, host: str, username: str, password: str = "xena", port: int = self._conn, username, password=password, + timeout_seconds=session_timeout, keepalive=True, ) """ diff --git a/xoa_driver/internals/hli_v2/testers/l23_tester.py b/xoa_driver/internals/hli_v2/testers/l23_tester.py index 082b81cb..552d83e1 100644 --- a/xoa_driver/internals/hli_v2/testers/l23_tester.py +++ b/xoa_driver/internals/hli_v2/testers/l23_tester.py @@ -55,17 +55,35 @@ def get_module_type(revision: str) -> Type: class L23Tester(BaseTester["testers_state.GenuineTesterLocalState"]): """ - Representation of a physical Xena Valkyrie Tester. + This is a conceptual class of Xena Valkyrie Tester. + It is essentially an extended :class:`BaseTester`. + + + :param host: tester's address/hostname + :type host: str + :param username: username of the user + :type username: str + :param password: login password of the tester, defaults to "xena" + :type password: str, optional + :param port: the port number for connection establishment, default to 22606 + :type port: int, optional + :param enable_logging: `True` if debug log output from the tester is needed, and `False` otherwise + :type enable_logging: bool + :param custom_logger: `None` allow to specify logger with custom configurations + :type enable_logging: CustomLogger | None + :param session_timeout: `130` Session timeout in seconds + :type session_timeout: int """ - def __init__(self, host: str, username: str, password: str = "xena", port: int = 22606, *, enable_logging: bool = False, custom_logger: CustomLogger | None = None) -> None: + def __init__(self, host: str, username: str, password: str = "xena", port: int = 22606, *, enable_logging: bool = False, custom_logger: CustomLogger | None = None, session_timeout: int = 130) -> None: super().__init__( host=host, username=username, password=password, port=port, enable_logging=enable_logging, - custom_logger=custom_logger + custom_logger=custom_logger, + session_timeout=session_timeout ) self._local_states = testers_state.GenuineTesterLocalState(host, port) diff --git a/xoa_driver/internals/hli_v2/testers/l23ve_tester.py b/xoa_driver/internals/hli_v2/testers/l23ve_tester.py index 3e7af826..01afcb3f 100644 --- a/xoa_driver/internals/hli_v2/testers/l23ve_tester.py +++ b/xoa_driver/internals/hli_v2/testers/l23ve_tester.py @@ -25,17 +25,35 @@ def get_module_type(revision: str) -> Type: class L23VeTester(BaseTester["testers_state.TesterLocalState"]): """ - Representation of a virtual Xena Valkyrie Tester. + This is a conceptual class of Xena ValkyrieVE Tester. + It is essentially an extended :class:`BaseTester`. + + + :param host: tester's address/hostname + :type host: str + :param username: username of the user + :type username: str + :param password: login password of the tester, defaults to "xena" + :type password: str, optional + :param port: the port number for connection establishment, default to 22606 + :type port: int, optional + :param enable_logging: `True` if debug log output from the tester is needed, and `False` otherwise + :type enable_logging: bool + :param custom_logger: `None` allow to specify logger with custom configurations + :type enable_logging: CustomLogger | None + :param session_timeout: `130` Session timeout in seconds + :type session_timeout: int """ - def __init__(self, host: str, username: str, password: str = "xena", port: int = 22606, *, enable_logging: bool = False, custom_logger: CustomLogger | None = None) -> None: + def __init__(self, host: str, username: str, password: str = "xena", port: int = 22606, *, enable_logging: bool = False, custom_logger: CustomLogger | None = None, session_timeout: int = 130) -> None: super().__init__( host=host, username=username, password=password, port=port, enable_logging=enable_logging, - custom_logger=custom_logger + custom_logger=custom_logger, + session_timeout=session_timeout ) self._local_states = testers_state.TesterLocalState(host, port) diff --git a/xoa_driver/internals/hli_v2/testers/l47_tester.py b/xoa_driver/internals/hli_v2/testers/l47_tester.py index 63868131..ce3a204c 100644 --- a/xoa_driver/internals/hli_v2/testers/l47_tester.py +++ b/xoa_driver/internals/hli_v2/testers/l47_tester.py @@ -32,17 +32,35 @@ def get_module_type(revision: str) -> "Type": class L47Tester(BaseTester["testers_state.GenuineTesterLocalState"]): """ - Representation of a physical Xena Vulcan Tester. + This is a conceptual class of Xena Vulcan Tester. + It is essentially an extended :class:`BaseTester`. + + + :param host: tester's address/hostname + :type host: str + :param username: username of the user + :type username: str + :param password: login password of the tester, defaults to "xena" + :type password: str, optional + :param port: the port number for connection establishment, default to 22606 + :type port: int, optional + :param enable_logging: `True` if debug log output from the tester is needed, and `False` otherwise + :type enable_logging: bool + :param custom_logger: `None` allow to specify logger with custom configurations + :type enable_logging: CustomLogger | None + :param session_timeout: `130` Session timeout in seconds + :type session_timeout: int """ - def __init__(self, host: str, username: str, password: str = "xena", port: int = 22606, *, enable_logging: bool = False, custom_logger: CustomLogger | None = None) -> None: + def __init__(self, host: str, username: str, password: str = "xena", port: int = 22606, *, enable_logging: bool = False, custom_logger: CustomLogger | None = None, session_timeout: int = 130) -> None: super().__init__( host=host, username=username, password=password, port=port, enable_logging=enable_logging, - custom_logger=custom_logger + custom_logger=custom_logger, + session_timeout=session_timeout ) self._local_states = testers_state.GenuineTesterLocalState(host, port) diff --git a/xoa_driver/internals/hli_v2/testers/l47ve_tester.py b/xoa_driver/internals/hli_v2/testers/l47ve_tester.py index ef8f1872..a2325be1 100644 --- a/xoa_driver/internals/hli_v2/testers/l47ve_tester.py +++ b/xoa_driver/internals/hli_v2/testers/l47ve_tester.py @@ -9,17 +9,35 @@ class L47VeTester(L47Tester): """ - Representation of a virtual Xena Vulcan Tester. + This is a conceptual class of Xena VulcanVE Tester. + It is essentially an extended :class:`BaseTester`. + + + :param host: tester's address/hostname + :type host: str + :param username: username of the user + :type username: str + :param password: login password of the tester, defaults to "xena" + :type password: str, optional + :param port: the port number for connection establishment, default to 22606 + :type port: int, optional + :param enable_logging: `True` if debug log output from the tester is needed, and `False` otherwise + :type enable_logging: bool + :param custom_logger: `None` allow to specify logger with custom configurations + :type enable_logging: CustomLogger | None + :param session_timeout: `130` Session timeout in seconds + :type session_timeout: int """ - def __init__(self, host: str, username: str, password: str = "xena", port: int = 22606, *, enable_logging: bool = False, custom_logger: CustomLogger | None = None) -> None: + def __init__(self, host: str, username: str, password: str = "xena", port: int = 22606, *, enable_logging: bool = False, custom_logger: CustomLogger | None = None, session_timeout: int = 130) -> None: super().__init__( host=host, username=username, password=password, port=port, enable_logging=enable_logging, - custom_logger=custom_logger + custom_logger=custom_logger, + session_timeout=session_timeout ) self.version_no_minor = C_VERSIONNO_MINOR(self._conn) """ diff --git a/xoa_driver/internals/utils/session.py b/xoa_driver/internals/utils/session.py index 044587da..2e4ebc3f 100644 --- a/xoa_driver/internals/utils/session.py +++ b/xoa_driver/internals/utils/session.py @@ -1,4 +1,5 @@ import asyncio +from contextlib import suppress from typing import ( TYPE_CHECKING, Tuple @@ -61,6 +62,13 @@ async def logon(self) -> "TesterSession": ) return self + async def chang_timeout(self, seconds: int = 130) -> None: + """Modify session timeout, """ + if not self.is_online: + raise RuntimeError("Timeout can be changet only after connection is established.") + self.timeout = seconds + await C_TIMEOUT(self._conn).set(self.timeout) + def __handle_exceptions(self, fut: asyncio.Future) -> None: if fut.cancelled(): return None @@ -69,7 +77,8 @@ def __handle_exceptions(self, fut: asyncio.Future) -> None: async def __do_keepalive(self) -> None: while self._conn.is_connected: - await C_KEEPALIVE(self._conn).get() + with suppress(Exception): + await C_KEEPALIVE(self._conn).get() await asyncio.sleep(max(0, self.timeout - 5)) @property From 5630c0bc7042d24b38c1dbbc979a2bdea3c6c8ca Mon Sep 17 00:00:00 2001 From: fpfeng Date: Tue, 15 Aug 2023 16:01:57 +0800 Subject: [PATCH 5/7] feat: expose types for chimera core --- xoa_driver/v2/misc.py | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/xoa_driver/v2/misc.py b/xoa_driver/v2/misc.py index 853fa9a7..6367b6ec 100644 --- a/xoa_driver/v2/misc.py +++ b/xoa_driver/v2/misc.py @@ -17,9 +17,30 @@ from xoa_driver.internals.hli_v2.indices.port_dataset import PortDatasetIdx as PortDataset from xoa_driver.internals.hli_v2.indices.streams.base_stream import BaseStreamIdx as BaseStream from xoa_driver.internals.hli_v2.indices.streams.genuine_stream import GenuineStreamIdx as GenuineStream -from xoa_driver.internals.hli_v2.ports.port_l23.chimera.port_emulation import CFlow as ImpairmentFlow +from xoa_driver.internals.hli_v2.ports.port_l23.chimera.filter_definition.general import ProtocolSegment +from xoa_driver.internals.hli_v2.ports.port_l23.chimera.port_emulation import ( + CFlow as ImpairmentFlow, + StatisticsTotals, + CPerFlowStats as PerImpairmentFlowStats, + CLatencyJitterImpairment, + CDropImpairment, + CMisorderingImpairment, + CDuplicationImpairment, + CCorruptionImpairment, + CPolicerImpairment, + CShaperImpairment, +) from xoa_driver.internals.hli_v2.ports.port_l23.chimera.filter_definition.general import ModeBasic as BasicImpairmentFlowFilter from xoa_driver.internals.hli_v2.ports.port_l23.chimera.filter_definition.general import ModeExtended as ExtendedImpairmentFlowFilter +from xoa_driver.internals.hli_v2.ports.port_l23.chimera.pe_custom_distribution import ( + CustomDistributions, + CustomDistribution, +) +from xoa_driver.internals.hli_v2.ports.port_l23.chimera.filter_definition.shadow import ( + FilterDefinitionShadow, + ModeExtendedS, +) +from xoa_driver.internals.hli_v2.ports.port_l23.chimera.filter_definition.general import ModeBasic __all__ = ( @@ -38,4 +59,19 @@ "ImpairmentFlow", "BasicImpairmentFlowFilter", "ExtendedImpairmentFlowFilter", + "StatisticsTotals", + "CustomDistributions", + "CustomDistribution", + "PerImpairmentFlowStats", + "CLatencyJitterImpairment", + "CDropImpairment", + "CMisorderingImpairment", + "CDuplicationImpairment", + "CCorruptionImpairment", + "CPolicerImpairment", + "CShaperImpairment", + "FilterDefinitionShadow", + "ModeExtendedS", + "ModeBasic", + "ProtocolSegment", ) From 7c10ddb63ac785c3985a2b66fb7531a197ddc39d Mon Sep 17 00:00:00 2001 From: Leonard Yu Date: Fri, 18 Aug 2023 13:27:57 +0200 Subject: [PATCH 6/7] Fix doc build error --- docs/requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 1c09cd1e..5a7817b0 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -2,7 +2,6 @@ # Defining the exact version will make sure things don't break sphinx -sphinx_rtd_theme readthedocs-sphinx-search sphinx-inline-tabs loguru From bceed81424ff782dd2d2ee06dd21130f2e691da4 Mon Sep 17 00:00:00 2001 From: Leonard Yu Date: Fri, 18 Aug 2023 13:34:16 +0200 Subject: [PATCH 7/7] Update version to 2.1.4 --- xoa_driver/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xoa_driver/__init__.py b/xoa_driver/__init__.py index 277dde4e..87dde94a 100644 --- a/xoa_driver/__init__.py +++ b/xoa_driver/__init__.py @@ -1,2 +1,2 @@ -__version__ = "2.1.3" +__version__ = "2.1.4" __short_version__ = "2.0"