tdl-xoa-driver 1.4.0__py3-none-any.whl → 1.5.0b1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. {tdl_xoa_driver-1.4.0.dist-info → tdl_xoa_driver-1.5.0b1.dist-info}/METADATA +2 -2
  2. {tdl_xoa_driver-1.4.0.dist-info → tdl_xoa_driver-1.5.0b1.dist-info}/RECORD +45 -33
  3. xoa_driver/__init__.py +2 -2
  4. xoa_driver/enums.py +2 -0
  5. xoa_driver/exceptions.py +2 -0
  6. xoa_driver/functions/anlt.py +2 -0
  7. xoa_driver/functions/anlt_ll_debug.py +2 -0
  8. xoa_driver/functions/cli/__init__.py +21 -0
  9. xoa_driver/functions/cli/_cli_manager.py +541 -0
  10. xoa_driver/functions/cli/_config_block.py +334 -0
  11. xoa_driver/functions/cli/_socket_driver.py +111 -0
  12. xoa_driver/functions/cli/port_config.py +107 -0
  13. xoa_driver/functions/cli/test_case_config.py +172 -0
  14. xoa_driver/functions/cmis/__init__.py +8 -0
  15. xoa_driver/functions/cmis/_constants.py +25 -0
  16. xoa_driver/functions/cmis/_replies.py +600 -0
  17. xoa_driver/functions/cmis/_utils.py +49 -0
  18. xoa_driver/functions/cmis/cdb.py +1266 -0
  19. xoa_driver/functions/exceptions.py +2 -0
  20. xoa_driver/functions/headers.py +2 -0
  21. xoa_driver/functions/mgmt.py +42 -19
  22. xoa_driver/functions/tools.py +9 -3
  23. xoa_driver/hlfuncs.py +6 -2
  24. xoa_driver/internals/commands/c_commands.py +6 -10
  25. xoa_driver/internals/commands/enums.py +25 -1
  26. xoa_driver/internals/commands/pr_commands.py +17 -16
  27. xoa_driver/internals/commands/px_commands.py +54 -54
  28. xoa_driver/internals/core/transporter/logger/__state_on_user.py +1 -1
  29. xoa_driver/internals/exceptions/modules.py +4 -3
  30. xoa_driver/internals/hli/modules/modules_l23/family_edun.py +82 -0
  31. xoa_driver/internals/hli/modules/modules_l23/family_g.py +1 -1
  32. xoa_driver/internals/hli/modules/modules_l23/family_l1.py +19 -0
  33. xoa_driver/internals/hli/ports/port_l23/family_edun.py +82 -0
  34. xoa_driver/internals/hli/ports/port_l23/family_l1.py +6 -0
  35. xoa_driver/internals/state_storage/modules_state.py +20 -0
  36. xoa_driver/internals/state_storage/testers_state.py +10 -0
  37. xoa_driver/lli.py +1 -0
  38. xoa_driver/misc.py +1 -0
  39. xoa_driver/modules.py +22 -0
  40. xoa_driver/ports.py +22 -0
  41. xoa_driver/testers.py +2 -0
  42. xoa_driver/utils.py +2 -0
  43. xoa_driver/functions/cli.py +0 -581
  44. {tdl_xoa_driver-1.4.0.dist-info → tdl_xoa_driver-1.5.0b1.dist-info}/WHEEL +0 -0
  45. {tdl_xoa_driver-1.4.0.dist-info → tdl_xoa_driver-1.5.0b1.dist-info}/licenses/LICENSE +0 -0
  46. {tdl_xoa_driver-1.4.0.dist-info → tdl_xoa_driver-1.5.0b1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,172 @@
1
+ import asyncio
2
+ from xoa_driver import testers, modules, ports
3
+ from ._cli_manager import XOACLIManager
4
+ from typing import List
5
+ from ..mgmt import *
6
+ from ._config_block import *
7
+
8
+ async def save_test_case_config(tester: testers.L23Tester, ports: List[ports.GenericL23Port], path: str, testbed_name: str = "<testbed>", with_module_config: bool = True, debug=False, halt_on_error=False) -> str:
9
+ """Save module configuration to the specifiied filepath
10
+
11
+ :param tester: Chassis object
12
+ :type tester: testers.L23Tester
13
+ :param ports: List of port objects to save configuration from
14
+ :type ports: typing.List[ports.GenericL23Port]
15
+ :param path: File path to save the test case configuration
16
+ :type path: str
17
+ :param testbed_name: Name of the testbed
18
+ :type testbed_name: str
19
+ :param with_module_config: Whether to include module configuration in the saved test case configuration
20
+ :type with_module_config: bool
21
+ :return: Test case configuration string
22
+ :rtype: str
23
+ """
24
+
25
+ # Get a list of modules from the ports
26
+ modules_list: List[modules.GenericL23Module] = []
27
+ if with_module_config:
28
+ for port in ports:
29
+ module = tester.modules.obtain(port.kind.module_id)
30
+ if module not in modules_list:
31
+ if not isinstance(module, modules.ModuleChimera):
32
+ modules_list.append(module)
33
+
34
+ tester_ip = tester.info.host
35
+ resp = await tester.password.get()
36
+ tester_password = resp.password
37
+
38
+ # Connect to the tester on tcp port 22611
39
+ xm = XOACLIManager(host=tester_ip, debug=debug, halt_on_error=halt_on_error)
40
+
41
+ # Log on and set username
42
+ xm.logon_set_owner(tester_password)
43
+
44
+ # Save configuration to file
45
+ result = ""
46
+ # Create testbed metadata block
47
+ testcase_metadata_block = ConfigBlock()
48
+ testcase_metadata_block.type = ConfigMetadataType.TESTCASE
49
+ testcase_metadata_block.testbed_name = testbed_name
50
+ result += testcase_metadata_block.config_block_str
51
+
52
+ for module in modules_list:
53
+ module_index = f"{module.module_id}"
54
+ raw_resp = xm.get_module_full_config_raw(module_index)
55
+
56
+ # Create config block
57
+ module_config_block = ConfigBlock()
58
+ # Fill in metadata
59
+ module_config_block.type = ConfigMetadataType.MODULE
60
+ module_config_block.chassis_name = tester.info.name
61
+ module_config_block.chassis_sn = str(tester.info.serial_number)
62
+ module_config_block.chassis_version_str = tester.info.version_string
63
+ module_config_block.module_name = module.info.model_name
64
+ module_config_block.module_model = module.info.model
65
+ module_config_block.module_sn = module.info.serial_number
66
+ module_config_block.module_version_str = module.info.version_string
67
+ module_config_block.module_revision = module.info.revision
68
+ module_config_block.module_id = module_index
69
+ module_config_block.commands = raw_resp[0]
70
+ result += "\n" + ";\n" + module_config_block.config_block_str
71
+
72
+ for port in ports:
73
+ port_index = f"{port.kind.module_id}/{port.kind.port_id}"
74
+ module = tester.modules.obtain(port.kind.module_id)
75
+ raw_resp = xm.get_port_full_config_raw(port_index)
76
+
77
+ # Create config block
78
+ port_config_block = ConfigBlock()
79
+ # Fill in metadata
80
+ port_config_block.type = ConfigMetadataType.PORT
81
+ port_config_block.chassis_name = tester.info.name
82
+ port_config_block.chassis_sn = str(tester.info.serial_number)
83
+ port_config_block.chassis_version_str = tester.info.version_string
84
+ port_config_block.module_name = module.info.model_name
85
+ port_config_block.module_model = module.info.model
86
+ port_config_block.module_sn = module.info.serial_number
87
+ port_config_block.module_version_str = module.info.version_string
88
+ port_config_block.module_revision = module.info.revision
89
+ port_config_block.port_id = port_index
90
+ port_config_block.commands = raw_resp[0]
91
+ result += "\n" + ";\n" + port_config_block.config_block_str
92
+
93
+ with open(path, 'w+', newline='') as xtcfile:
94
+ xtcfile.write(result)
95
+
96
+ return result
97
+
98
+ async def load_test_case_config(tester: testers.L23Tester, path: str, mode: str = "default", delay_after_module_config: int = 5, debug=False, halt_on_error=False) -> None:
99
+ """Load module configuration from the specifiied filepath
100
+
101
+ :param tester: Chassis object
102
+ :type tester: testers.L23Tester
103
+ :param path: File path to load the module configuration from
104
+ :type path: str
105
+ :param mode: Load mode, "default | port | module". "default" loads both module and port configurations, "port" loads only port configurations, "module" loads only module configurations.
106
+ :type mode: str
107
+ :param delay_after_module_config: Delay in seconds after configuring each module to ensure proper configuration
108
+ :type delay_after_module_config: int
109
+ """
110
+
111
+ tester_ip = tester.info.host
112
+ resp = await tester.password.get()
113
+ tester_password = resp.password
114
+
115
+ # Connect to the tester on tcp port 22611
116
+ xm = XOACLIManager(host=tester_ip, debug=debug, halt_on_error=halt_on_error)
117
+
118
+ # Log on and set username
119
+ xm.logon_set_owner(tester_password)
120
+
121
+ # Read configuration from file
122
+ with open(path, 'r', newline='') as xpcfile:
123
+ config_data = xpcfile.read()
124
+
125
+ # Parse the config data to configure modules and ports block by block
126
+ config_datas = config_data.split(f";\n")
127
+ for block in config_datas:
128
+ if config_block_type(config_block_str=block) == ConfigMetadataType.MODULE and mode in ["default", "module"]:
129
+ module_block = ConfigBlock()
130
+ module_block.config_block_str = block
131
+ module_index = module_block.module_id
132
+
133
+ # Free the module before applying configuration
134
+ module = tester.modules.obtain(int(module_index))
135
+ await release_module(module=module, should_release_ports=True)
136
+ # Reserve the module before applying configuration
137
+ xm.reserve_module(module_index)
138
+
139
+ # Send each command to the tester
140
+ for cmd in module_block.commands:
141
+ if cmd.strip(): # Ensure the command is not empty
142
+ print(f"Applying command: {module_index} {cmd}")
143
+ xm.send(cmd=f"{module_index} {cmd}", sync_on=False)
144
+ # Free the module after applying configuration
145
+ xm.free_module(module_index)
146
+ await asyncio.sleep(delay_after_module_config) # Small delay to ensure proper module configuration
147
+
148
+ elif config_block_type(config_block_str=block) == ConfigMetadataType.PORT and mode in ["default", "port"]:
149
+ port_block = ConfigBlock()
150
+ port_block.config_block_str = block
151
+ port_index = port_block.port_id
152
+
153
+ # Reserve the port before applying configuration
154
+ xm.reserve_port(port_index)
155
+
156
+ # Send each command to the tester
157
+ for cmd in port_block.commands:
158
+ if cmd.strip(): # Ensure the command is not empty
159
+ print(f"Applying command: {port_index} {cmd}")
160
+ xm.send(cmd=f"{port_index} {cmd}", sync_on=False)
161
+ # Free the port after applying configuration
162
+ xm.free_port(port_index)
163
+
164
+ async def module_config_from_file(tester: testers.L23Tester, path: str, debug=False, halt_on_error=False) -> None:
165
+ """Load module configuration from the specifiied filepath. This function is a wrapper around load_module_config to provide backward compatibility.
166
+
167
+ :param tester: Chassis object
168
+ :type tester: testers.L23Tester
169
+ :param path: File path to load the module configuration from
170
+ :type path: str
171
+ """
172
+ await load_test_case_config(tester, path, mode="module", debug=debug, halt_on_error=halt_on_error)
@@ -0,0 +1,8 @@
1
+ """The cmis high-level function module."""
2
+
3
+ # importing all commands
4
+ from . import cdb
5
+
6
+ __all__ = (
7
+ "cdb",
8
+ )
@@ -0,0 +1,25 @@
1
+ from enum import IntEnum
2
+
3
+ class WriteMechanism(IntEnum):
4
+ """Firmware update supported mechanism."""
5
+ NONE_SUPPORTED = 0
6
+ LPL_ONLY = 1
7
+ EPL_ONLY = 2
8
+ BOTH_SUPPORTED = 3
9
+
10
+ class ReadMechanism(IntEnum):
11
+ """Firmware update supported mechanism."""
12
+ NONE_SUPPORTED = 0
13
+ LPL_ONLY = 1
14
+ EPL_ONLY = 2
15
+ BOTH_SUPPORTED = 3
16
+
17
+ class CdbCommandCoarseStatus(IntEnum):
18
+ """The status of the most recently triggered CDB command.
19
+
20
+ Coarse query results that are encoded by the pair of bit 7 (CdbIsBusy) and bit 6 (CdbHasFailed).
21
+ """
22
+ NA = 0x00
23
+ SUCCESS = 0x01
24
+ IN_PROGRESS = 0x80
25
+ FAILED = 0x40