tdl-xoa-driver 1.0.0__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 (325) hide show
  1. tdl_xoa_driver-1.0.0.dist-info/LICENSE +202 -0
  2. tdl_xoa_driver-1.0.0.dist-info/METADATA +177 -0
  3. tdl_xoa_driver-1.0.0.dist-info/RECORD +325 -0
  4. tdl_xoa_driver-1.0.0.dist-info/WHEEL +5 -0
  5. tdl_xoa_driver-1.0.0.dist-info/top_level.txt +1 -0
  6. xoa_driver/__init__.py +2 -0
  7. xoa_driver/enums.py +399 -0
  8. xoa_driver/exceptions.py +77 -0
  9. xoa_driver/functions/__init__.py +0 -0
  10. xoa_driver/functions/anlt.py +744 -0
  11. xoa_driver/functions/anlt_ll_debug.py +429 -0
  12. xoa_driver/functions/cli.py +581 -0
  13. xoa_driver/functions/exceptions.py +72 -0
  14. xoa_driver/functions/headers.py +608 -0
  15. xoa_driver/functions/mgmt.py +515 -0
  16. xoa_driver/functions/tools.py +256 -0
  17. xoa_driver/hlfuncs.py +18 -0
  18. xoa_driver/internals/__init__.py +0 -0
  19. xoa_driver/internals/commands/__init__.py +31 -0
  20. xoa_driver/internals/commands/c_commands.py +2041 -0
  21. xoa_driver/internals/commands/enums.py +3289 -0
  22. xoa_driver/internals/commands/m4_commands.py +700 -0
  23. xoa_driver/internals/commands/m4e_commands.py +107 -0
  24. xoa_driver/internals/commands/m_commands.py +1875 -0
  25. xoa_driver/internals/commands/p4_commands.py +2221 -0
  26. xoa_driver/internals/commands/p4e_commands.py +160 -0
  27. xoa_driver/internals/commands/p4g_commands.py +7253 -0
  28. xoa_driver/internals/commands/p_commands.py +6000 -0
  29. xoa_driver/internals/commands/pc_commands.py +335 -0
  30. xoa_driver/internals/commands/pd_commands.py +355 -0
  31. xoa_driver/internals/commands/pe_commands.py +1018 -0
  32. xoa_driver/internals/commands/pec_commands.py +265 -0
  33. xoa_driver/internals/commands/ped_commands.py +1034 -0
  34. xoa_driver/internals/commands/pef_commands.py +2216 -0
  35. xoa_driver/internals/commands/pf_commands.py +379 -0
  36. xoa_driver/internals/commands/pl1_commands.py +1588 -0
  37. xoa_driver/internals/commands/pl_commands.py +178 -0
  38. xoa_driver/internals/commands/pm_commands.py +256 -0
  39. xoa_driver/internals/commands/pp_commands.py +2341 -0
  40. xoa_driver/internals/commands/pr_commands.py +812 -0
  41. xoa_driver/internals/commands/ps_commands.py +2311 -0
  42. xoa_driver/internals/commands/pt_commands.py +370 -0
  43. xoa_driver/internals/commands/px_commands.py +303 -0
  44. xoa_driver/internals/commands/subtypes.py +86 -0
  45. xoa_driver/internals/core/__init__.py +0 -0
  46. xoa_driver/internals/core/builders.py +39 -0
  47. xoa_driver/internals/core/exceptions.py +69 -0
  48. xoa_driver/internals/core/funcs.py +81 -0
  49. xoa_driver/internals/core/funcs.pyi +1072 -0
  50. xoa_driver/internals/core/interfaces.py +47 -0
  51. xoa_driver/internals/core/token.py +44 -0
  52. xoa_driver/internals/core/transporter/__init__.py +0 -0
  53. xoa_driver/internals/core/transporter/_processor.py +83 -0
  54. xoa_driver/internals/core/transporter/_publisher.py +101 -0
  55. xoa_driver/internals/core/transporter/_request_id_counter.py +28 -0
  56. xoa_driver/internals/core/transporter/_stream.py +99 -0
  57. xoa_driver/internals/core/transporter/_typings.py +43 -0
  58. xoa_driver/internals/core/transporter/exceptions.py +44 -0
  59. xoa_driver/internals/core/transporter/handler.py +127 -0
  60. xoa_driver/internals/core/transporter/logger/__init__.py +10 -0
  61. xoa_driver/internals/core/transporter/logger/__logger.py +94 -0
  62. xoa_driver/internals/core/transporter/logger/__state_off.py +32 -0
  63. xoa_driver/internals/core/transporter/logger/__state_on_default.py +70 -0
  64. xoa_driver/internals/core/transporter/logger/__state_on_loguru.py +51 -0
  65. xoa_driver/internals/core/transporter/logger/__state_on_user.py +48 -0
  66. xoa_driver/internals/core/transporter/protocol/__init__.py +0 -0
  67. xoa_driver/internals/core/transporter/protocol/_constants.py +77 -0
  68. xoa_driver/internals/core/transporter/protocol/_utils.py +59 -0
  69. xoa_driver/internals/core/transporter/protocol/exceptions.py +271 -0
  70. xoa_driver/internals/core/transporter/protocol/payload/__init__.py +70 -0
  71. xoa_driver/internals/core/transporter/protocol/payload/base_struct.py +283 -0
  72. xoa_driver/internals/core/transporter/protocol/payload/descriptor.py +119 -0
  73. xoa_driver/internals/core/transporter/protocol/payload/exceptions.py +20 -0
  74. xoa_driver/internals/core/transporter/protocol/payload/field.py +296 -0
  75. xoa_driver/internals/core/transporter/protocol/payload/types.py +173 -0
  76. xoa_driver/internals/core/transporter/protocol/payload/utils.py +53 -0
  77. xoa_driver/internals/core/transporter/protocol/struct_header.py +123 -0
  78. xoa_driver/internals/core/transporter/protocol/struct_request.py +65 -0
  79. xoa_driver/internals/core/transporter/protocol/struct_response.py +89 -0
  80. xoa_driver/internals/core/transporter/registry.py +43 -0
  81. xoa_driver/internals/exceptions/__init__.py +9 -0
  82. xoa_driver/internals/exceptions/modules.py +13 -0
  83. xoa_driver/internals/exceptions/testers.py +21 -0
  84. xoa_driver/internals/hli_v1/__init__.py +0 -0
  85. xoa_driver/internals/hli_v1/indices/__init__.py +0 -0
  86. xoa_driver/internals/hli_v1/indices/base_index.py +39 -0
  87. xoa_driver/internals/hli_v1/indices/connection_group/__init__.py +0 -0
  88. xoa_driver/internals/hli_v1/indices/connection_group/cg.py +186 -0
  89. xoa_driver/internals/hli_v1/indices/connection_group/histogram.py +78 -0
  90. xoa_driver/internals/hli_v1/indices/connection_group/l2.py +94 -0
  91. xoa_driver/internals/hli_v1/indices/connection_group/l3.py +130 -0
  92. xoa_driver/internals/hli_v1/indices/connection_group/raw.py +200 -0
  93. xoa_driver/internals/hli_v1/indices/connection_group/replay.py +109 -0
  94. xoa_driver/internals/hli_v1/indices/connection_group/tcp.py +314 -0
  95. xoa_driver/internals/hli_v1/indices/connection_group/tls.py +198 -0
  96. xoa_driver/internals/hli_v1/indices/connection_group/udp.py +133 -0
  97. xoa_driver/internals/hli_v1/indices/connection_group/user_state.py +28 -0
  98. xoa_driver/internals/hli_v1/indices/filter/__init__.py +0 -0
  99. xoa_driver/internals/hli_v1/indices/filter/base_filter.py +65 -0
  100. xoa_driver/internals/hli_v1/indices/filter/genuine_filter.py +20 -0
  101. xoa_driver/internals/hli_v1/indices/length_term.py +49 -0
  102. xoa_driver/internals/hli_v1/indices/macsecscs/__init__.py +0 -0
  103. xoa_driver/internals/hli_v1/indices/macsecscs/base_macsecsc.py +224 -0
  104. xoa_driver/internals/hli_v1/indices/macsecscs/genuine_macsecsc.py +72 -0
  105. xoa_driver/internals/hli_v1/indices/match_term.py +64 -0
  106. xoa_driver/internals/hli_v1/indices/port_dataset.py +72 -0
  107. xoa_driver/internals/hli_v1/indices/streams/__init__.py +0 -0
  108. xoa_driver/internals/hli_v1/indices/streams/base_stream.py +405 -0
  109. xoa_driver/internals/hli_v1/indices/streams/genuine_stream.py +64 -0
  110. xoa_driver/internals/hli_v1/modules/__init__.py +0 -0
  111. xoa_driver/internals/hli_v1/modules/__interfaces.py +21 -0
  112. xoa_driver/internals/hli_v1/modules/base_module.py +138 -0
  113. xoa_driver/internals/hli_v1/modules/module_chimera.py +366 -0
  114. xoa_driver/internals/hli_v1/modules/module_l23ve.py +73 -0
  115. xoa_driver/internals/hli_v1/modules/module_l47.py +397 -0
  116. xoa_driver/internals/hli_v1/modules/module_l47ve.py +9 -0
  117. xoa_driver/internals/hli_v1/modules/modules_l23/__init__.py +0 -0
  118. xoa_driver/internals/hli_v1/modules/modules_l23/family_combi.py +83 -0
  119. xoa_driver/internals/hli_v1/modules/modules_l23/family_d.py +75 -0
  120. xoa_driver/internals/hli_v1/modules/modules_l23/family_e.py +85 -0
  121. xoa_driver/internals/hli_v1/modules/modules_l23/family_f.py +145 -0
  122. xoa_driver/internals/hli_v1/modules/modules_l23/family_g.py +84 -0
  123. xoa_driver/internals/hli_v1/modules/modules_l23/family_h.py +40 -0
  124. xoa_driver/internals/hli_v1/modules/modules_l23/family_i.py +25 -0
  125. xoa_driver/internals/hli_v1/modules/modules_l23/family_j.py +25 -0
  126. xoa_driver/internals/hli_v1/modules/modules_l23/family_k.py +39 -0
  127. xoa_driver/internals/hli_v1/modules/modules_l23/family_l.py +55 -0
  128. xoa_driver/internals/hli_v1/modules/modules_l23/family_l1.py +800 -0
  129. xoa_driver/internals/hli_v1/modules/modules_l23/family_m.py +25 -0
  130. xoa_driver/internals/hli_v1/modules/modules_l23/family_n.py +40 -0
  131. xoa_driver/internals/hli_v1/modules/modules_l23/module_l23_base.py +383 -0
  132. xoa_driver/internals/hli_v1/ports/__init__.py +0 -0
  133. xoa_driver/internals/hli_v1/ports/base_port.py +125 -0
  134. xoa_driver/internals/hli_v1/ports/port_l23/__init__.py +0 -0
  135. xoa_driver/internals/hli_v1/ports/port_l23/bases/__init__.py +0 -0
  136. xoa_driver/internals/hli_v1/ports/port_l23/bases/port_capture.py +70 -0
  137. xoa_driver/internals/hli_v1/ports/port_l23/bases/port_l23.py +527 -0
  138. xoa_driver/internals/hli_v1/ports/port_l23/bases/port_l23_genuine.py +229 -0
  139. xoa_driver/internals/hli_v1/ports/port_l23/bases/port_reception_statistics.py +231 -0
  140. xoa_driver/internals/hli_v1/ports/port_l23/bases/port_transceiver.py +117 -0
  141. xoa_driver/internals/hli_v1/ports/port_l23/bases/port_transmission_statistics.py +131 -0
  142. xoa_driver/internals/hli_v1/ports/port_l23/chimera/__init__.py +0 -0
  143. xoa_driver/internals/hli_v1/ports/port_l23/chimera/filter_definition/__init__.py +0 -0
  144. xoa_driver/internals/hli_v1/ports/port_l23/chimera/filter_definition/_utils.py +15 -0
  145. xoa_driver/internals/hli_v1/ports/port_l23/chimera/filter_definition/general.py +396 -0
  146. xoa_driver/internals/hli_v1/ports/port_l23/chimera/filter_definition/shadow.py +104 -0
  147. xoa_driver/internals/hli_v1/ports/port_l23/chimera/filter_definition/working.py +36 -0
  148. xoa_driver/internals/hli_v1/ports/port_l23/chimera/pe_custom_distribution.py +125 -0
  149. xoa_driver/internals/hli_v1/ports/port_l23/chimera/pe_distribution.py +174 -0
  150. xoa_driver/internals/hli_v1/ports/port_l23/chimera/port_chimera.py +119 -0
  151. xoa_driver/internals/hli_v1/ports/port_l23/chimera/port_emulation.py +244 -0
  152. xoa_driver/internals/hli_v1/ports/port_l23/chimera/reception_statistics.py +24 -0
  153. xoa_driver/internals/hli_v1/ports/port_l23/chimera/transmission_statistics.py +24 -0
  154. xoa_driver/internals/hli_v1/ports/port_l23/family_combi.py +37 -0
  155. xoa_driver/internals/hli_v1/ports/port_l23/family_d.py +51 -0
  156. xoa_driver/internals/hli_v1/ports/port_l23/family_e.py +107 -0
  157. xoa_driver/internals/hli_v1/ports/port_l23/family_f.py +151 -0
  158. xoa_driver/internals/hli_v1/ports/port_l23/family_g.py +77 -0
  159. xoa_driver/internals/hli_v1/ports/port_l23/family_h.py +67 -0
  160. xoa_driver/internals/hli_v1/ports/port_l23/family_i.py +84 -0
  161. xoa_driver/internals/hli_v1/ports/port_l23/family_j.py +68 -0
  162. xoa_driver/internals/hli_v1/ports/port_l23/family_k.py +73 -0
  163. xoa_driver/internals/hli_v1/ports/port_l23/family_l.py +82 -0
  164. xoa_driver/internals/hli_v1/ports/port_l23/family_l1.py +166 -0
  165. xoa_driver/internals/hli_v1/ports/port_l23/family_m.py +29 -0
  166. xoa_driver/internals/hli_v1/ports/port_l23/fault_jkl.py +24 -0
  167. xoa_driver/internals/hli_v1/ports/port_l23/freya_l1.py +722 -0
  168. xoa_driver/internals/hli_v1/ports/port_l23/pcs_pma_ghijkl.py +369 -0
  169. xoa_driver/internals/hli_v1/ports/port_l23/pcs_pma_ijkl_chimera.py +60 -0
  170. xoa_driver/internals/hli_v1/ports/port_l23/pcs_pma_l.py +78 -0
  171. xoa_driver/internals/hli_v1/ports/port_l23/port_l23ve.py +101 -0
  172. xoa_driver/internals/hli_v1/ports/port_l47/__init__.py +0 -0
  173. xoa_driver/internals/hli_v1/ports/port_l47/counters.py +174 -0
  174. xoa_driver/internals/hli_v1/ports/port_l47/main.py +228 -0
  175. xoa_driver/internals/hli_v1/ports/port_l47/packet_engine.py +31 -0
  176. xoa_driver/internals/hli_v1/revisions.py +11 -0
  177. xoa_driver/internals/hli_v1/testers/__init__.py +0 -0
  178. xoa_driver/internals/hli_v1/testers/_base_tester.py +259 -0
  179. xoa_driver/internals/hli_v1/testers/genuine/__init__.py +0 -0
  180. xoa_driver/internals/hli_v1/testers/genuine/l_23/__init__.py +0 -0
  181. xoa_driver/internals/hli_v1/testers/genuine/l_23/health.py +16 -0
  182. xoa_driver/internals/hli_v1/testers/genuine/l_23/rest_api.py +38 -0
  183. xoa_driver/internals/hli_v1/testers/genuine/l_23/time_keeper.py +57 -0
  184. xoa_driver/internals/hli_v1/testers/genuine/l_23/upload_file.py +29 -0
  185. xoa_driver/internals/hli_v1/testers/genuine/management_interface.py +42 -0
  186. xoa_driver/internals/hli_v1/testers/l23_tester.py +196 -0
  187. xoa_driver/internals/hli_v1/testers/l23ve_tester.py +114 -0
  188. xoa_driver/internals/hli_v1/testers/l47_tester.py +106 -0
  189. xoa_driver/internals/hli_v1/testers/l47ve_tester.py +54 -0
  190. xoa_driver/internals/hli_v2/__init__.py +0 -0
  191. xoa_driver/internals/hli_v2/indices/__init__.py +0 -0
  192. xoa_driver/internals/hli_v2/indices/base_index.py +39 -0
  193. xoa_driver/internals/hli_v2/indices/connection_group/__init__.py +0 -0
  194. xoa_driver/internals/hli_v2/indices/connection_group/cg.py +115 -0
  195. xoa_driver/internals/hli_v2/indices/connection_group/histogram.py +59 -0
  196. xoa_driver/internals/hli_v2/indices/connection_group/l2.py +71 -0
  197. xoa_driver/internals/hli_v2/indices/connection_group/l3.py +96 -0
  198. xoa_driver/internals/hli_v2/indices/connection_group/raw.py +148 -0
  199. xoa_driver/internals/hli_v2/indices/connection_group/replay.py +89 -0
  200. xoa_driver/internals/hli_v2/indices/connection_group/tcp.py +261 -0
  201. xoa_driver/internals/hli_v2/indices/connection_group/tls.py +166 -0
  202. xoa_driver/internals/hli_v2/indices/connection_group/udp.py +112 -0
  203. xoa_driver/internals/hli_v2/indices/connection_group/user_state.py +25 -0
  204. xoa_driver/internals/hli_v2/indices/filter/__init__.py +0 -0
  205. xoa_driver/internals/hli_v2/indices/filter/base_filter.py +50 -0
  206. xoa_driver/internals/hli_v2/indices/filter/genuine_filter.py +17 -0
  207. xoa_driver/internals/hli_v2/indices/length_term.py +44 -0
  208. xoa_driver/internals/hli_v2/indices/match_term.py +49 -0
  209. xoa_driver/internals/hli_v2/indices/port_dataset.py +53 -0
  210. xoa_driver/internals/hli_v2/indices/streams/__init__.py +0 -0
  211. xoa_driver/internals/hli_v2/indices/streams/base_stream.py +234 -0
  212. xoa_driver/internals/hli_v2/indices/streams/genuine_stream.py +32 -0
  213. xoa_driver/internals/hli_v2/modules/__init__.py +0 -0
  214. xoa_driver/internals/hli_v2/modules/__interfaces.py +21 -0
  215. xoa_driver/internals/hli_v2/modules/base_module.py +125 -0
  216. xoa_driver/internals/hli_v2/modules/module_chimera.py +358 -0
  217. xoa_driver/internals/hli_v2/modules/module_l23ve.py +58 -0
  218. xoa_driver/internals/hli_v2/modules/module_l47.py +230 -0
  219. xoa_driver/internals/hli_v2/modules/module_l47ve.py +8 -0
  220. xoa_driver/internals/hli_v2/modules/modules_l23/__init__.py +0 -0
  221. xoa_driver/internals/hli_v2/modules/modules_l23/family_combi.py +73 -0
  222. xoa_driver/internals/hli_v2/modules/modules_l23/family_d.py +75 -0
  223. xoa_driver/internals/hli_v2/modules/modules_l23/family_e.py +85 -0
  224. xoa_driver/internals/hli_v2/modules/modules_l23/family_f.py +144 -0
  225. xoa_driver/internals/hli_v2/modules/modules_l23/family_g.py +84 -0
  226. xoa_driver/internals/hli_v2/modules/modules_l23/family_h.py +40 -0
  227. xoa_driver/internals/hli_v2/modules/modules_l23/family_i.py +25 -0
  228. xoa_driver/internals/hli_v2/modules/modules_l23/family_j.py +25 -0
  229. xoa_driver/internals/hli_v2/modules/modules_l23/family_k.py +39 -0
  230. xoa_driver/internals/hli_v2/modules/modules_l23/family_l.py +55 -0
  231. xoa_driver/internals/hli_v2/modules/modules_l23/family_l1.py +797 -0
  232. xoa_driver/internals/hli_v2/modules/modules_l23/family_m.py +25 -0
  233. xoa_driver/internals/hli_v2/modules/modules_l23/family_n.py +40 -0
  234. xoa_driver/internals/hli_v2/modules/modules_l23/module_l23_base.py +339 -0
  235. xoa_driver/internals/hli_v2/ports/__init__.py +0 -0
  236. xoa_driver/internals/hli_v2/ports/base_port.py +105 -0
  237. xoa_driver/internals/hli_v2/ports/port_l23/__init__.py +0 -0
  238. xoa_driver/internals/hli_v2/ports/port_l23/bases/__init__.py +0 -0
  239. xoa_driver/internals/hli_v2/ports/port_l23/bases/port_capture.py +64 -0
  240. xoa_driver/internals/hli_v2/ports/port_l23/bases/port_l23.py +441 -0
  241. xoa_driver/internals/hli_v2/ports/port_l23/bases/port_l23_genuine.py +172 -0
  242. xoa_driver/internals/hli_v2/ports/port_l23/bases/port_reception_statistics.py +156 -0
  243. xoa_driver/internals/hli_v2/ports/port_l23/bases/port_transceiver.py +117 -0
  244. xoa_driver/internals/hli_v2/ports/port_l23/bases/port_transmission_statistics.py +59 -0
  245. xoa_driver/internals/hli_v2/ports/port_l23/chimera/__init__.py +0 -0
  246. xoa_driver/internals/hli_v2/ports/port_l23/chimera/filter_definition/__init__.py +0 -0
  247. xoa_driver/internals/hli_v2/ports/port_l23/chimera/filter_definition/_utils.py +15 -0
  248. xoa_driver/internals/hli_v2/ports/port_l23/chimera/filter_definition/general.py +340 -0
  249. xoa_driver/internals/hli_v2/ports/port_l23/chimera/filter_definition/shadow.py +99 -0
  250. xoa_driver/internals/hli_v2/ports/port_l23/chimera/filter_definition/working.py +36 -0
  251. xoa_driver/internals/hli_v2/ports/port_l23/chimera/pe_custom_distribution.py +116 -0
  252. xoa_driver/internals/hli_v2/ports/port_l23/chimera/pe_distribution.py +102 -0
  253. xoa_driver/internals/hli_v2/ports/port_l23/chimera/port_chimera.py +113 -0
  254. xoa_driver/internals/hli_v2/ports/port_l23/chimera/port_emulation.py +420 -0
  255. xoa_driver/internals/hli_v2/ports/port_l23/chimera/reception_statistics.py +22 -0
  256. xoa_driver/internals/hli_v2/ports/port_l23/chimera/transmission_statistics.py +22 -0
  257. xoa_driver/internals/hli_v2/ports/port_l23/family_combi.py +36 -0
  258. xoa_driver/internals/hli_v2/ports/port_l23/family_d.py +49 -0
  259. xoa_driver/internals/hli_v2/ports/port_l23/family_e.py +96 -0
  260. xoa_driver/internals/hli_v2/ports/port_l23/family_f.py +144 -0
  261. xoa_driver/internals/hli_v2/ports/port_l23/family_g.py +77 -0
  262. xoa_driver/internals/hli_v2/ports/port_l23/family_h.py +60 -0
  263. xoa_driver/internals/hli_v2/ports/port_l23/family_i.py +66 -0
  264. xoa_driver/internals/hli_v2/ports/port_l23/family_j.py +53 -0
  265. xoa_driver/internals/hli_v2/ports/port_l23/family_k.py +58 -0
  266. xoa_driver/internals/hli_v2/ports/port_l23/family_l.py +67 -0
  267. xoa_driver/internals/hli_v2/ports/port_l23/family_l1.py +149 -0
  268. xoa_driver/internals/hli_v2/ports/port_l23/family_m.py +28 -0
  269. xoa_driver/internals/hli_v2/ports/port_l23/fault_jkl.py +22 -0
  270. xoa_driver/internals/hli_v2/ports/port_l23/pcs_pma_ghijkl.py +342 -0
  271. xoa_driver/internals/hli_v2/ports/port_l23/pcs_pma_ijkl_chimera.py +50 -0
  272. xoa_driver/internals/hli_v2/ports/port_l23/pcs_pma_l.py +65 -0
  273. xoa_driver/internals/hli_v2/ports/port_l23/port_l23ve.py +81 -0
  274. xoa_driver/internals/hli_v2/ports/port_l47/__init__.py +0 -0
  275. xoa_driver/internals/hli_v2/ports/port_l47/counters.py +146 -0
  276. xoa_driver/internals/hli_v2/ports/port_l47/main.py +137 -0
  277. xoa_driver/internals/hli_v2/ports/port_l47/packet_engine.py +20 -0
  278. xoa_driver/internals/hli_v2/revisions.py +11 -0
  279. xoa_driver/internals/hli_v2/testers/__init__.py +0 -0
  280. xoa_driver/internals/hli_v2/testers/_base_tester.py +207 -0
  281. xoa_driver/internals/hli_v2/testers/genuine/__init__.py +0 -0
  282. xoa_driver/internals/hli_v2/testers/genuine/l_23/__init__.py +0 -0
  283. xoa_driver/internals/hli_v2/testers/genuine/l_23/health.py +16 -0
  284. xoa_driver/internals/hli_v2/testers/genuine/l_23/rest_api.py +34 -0
  285. xoa_driver/internals/hli_v2/testers/genuine/l_23/time_keeper.py +50 -0
  286. xoa_driver/internals/hli_v2/testers/genuine/l_23/upload_file.py +26 -0
  287. xoa_driver/internals/hli_v2/testers/genuine/management_interface.py +38 -0
  288. xoa_driver/internals/hli_v2/testers/l23_tester.py +159 -0
  289. xoa_driver/internals/hli_v2/testers/l23ve_tester.py +98 -0
  290. xoa_driver/internals/hli_v2/testers/l47_tester.py +95 -0
  291. xoa_driver/internals/hli_v2/testers/l47ve_tester.py +50 -0
  292. xoa_driver/internals/state_storage/__init__.py +0 -0
  293. xoa_driver/internals/state_storage/_speed_detector.py +121 -0
  294. xoa_driver/internals/state_storage/modules_state.py +128 -0
  295. xoa_driver/internals/state_storage/ports_state.py +154 -0
  296. xoa_driver/internals/state_storage/testers_state.py +104 -0
  297. xoa_driver/internals/utils/__init__.py +0 -0
  298. xoa_driver/internals/utils/attributes.py +33 -0
  299. xoa_driver/internals/utils/cap_id.py +63 -0
  300. xoa_driver/internals/utils/con_traffic_light.py +88 -0
  301. xoa_driver/internals/utils/indices/__init__.py +0 -0
  302. xoa_driver/internals/utils/indices/_interfaces.py +26 -0
  303. xoa_driver/internals/utils/indices/header_modifier_manager.py +56 -0
  304. xoa_driver/internals/utils/indices/index_manager.py +95 -0
  305. xoa_driver/internals/utils/indices/observer.py +17 -0
  306. xoa_driver/internals/utils/kind.py +19 -0
  307. xoa_driver/internals/utils/managers/__init__.py +0 -0
  308. xoa_driver/internals/utils/managers/abc.py +44 -0
  309. xoa_driver/internals/utils/managers/exceptions.py +22 -0
  310. xoa_driver/internals/utils/managers/modules_manager.py +118 -0
  311. xoa_driver/internals/utils/managers/ports_manager.py +116 -0
  312. xoa_driver/internals/utils/rev_tool.py +21 -0
  313. xoa_driver/internals/utils/session.py +117 -0
  314. xoa_driver/internals/warn.py +32 -0
  315. xoa_driver/lli.py +15 -0
  316. xoa_driver/misc.py +57 -0
  317. xoa_driver/modules.py +448 -0
  318. xoa_driver/ports.py +332 -0
  319. xoa_driver/testers.py +37 -0
  320. xoa_driver/utils.py +12 -0
  321. xoa_driver/v2/__init__.py +11 -0
  322. xoa_driver/v2/misc.py +77 -0
  323. xoa_driver/v2/modules.py +308 -0
  324. xoa_driver/v2/ports.py +232 -0
  325. xoa_driver/v2/testers.py +24 -0
@@ -0,0 +1,154 @@
1
+ import asyncio
2
+ from typing import List
3
+
4
+ from xoa_driver.internals.commands import (
5
+ P_CAPABILITIES,
6
+ P4_CAPABILITIES,
7
+ P_RECEIVESYNC,
8
+ P_RESERVEDBY,
9
+ P_RESERVATION,
10
+ P_INTERFACE,
11
+ P_TRAFFIC,
12
+ P4_STATE,
13
+ )
14
+ from xoa_driver.internals.core import funcs
15
+ from xoa_driver.internals.commands import enums
16
+
17
+ from xoa_driver.internals.utils import attributes as utils
18
+ from ._speed_detector import SpeedDetector
19
+
20
+
21
+ class PortLocalState:
22
+ """Port local state
23
+ """
24
+ __slots__ = (
25
+ "model",
26
+ "serial_number",
27
+ "interface",
28
+ "reservation",
29
+ "reserved_by",
30
+ "sync_status"
31
+ )
32
+
33
+ def __init__(self) -> None:
34
+ self.model: str = ""
35
+ self.serial_number: int = 0
36
+ self.interface: str = ""
37
+ self.reservation: "enums.ReservedStatus" = enums.ReservedStatus.RELEASED
38
+ self.reserved_by: str = ""
39
+ self.sync_status: "enums.SyncStatus" = enums.SyncStatus.NO_SYNC
40
+
41
+ async def initiate(self, port) -> None:
42
+ (
43
+ sync_status_r,
44
+ interface_r,
45
+ reservation_r,
46
+ reserved_by_r,
47
+ ) = await funcs.apply(
48
+ port.sync_status.get(),
49
+ port.interface.get(),
50
+ port.reservation.get(),
51
+ port.reserved_by.get(),
52
+ )
53
+ self.sync_status = enums.SyncStatus(sync_status_r.sync_status)
54
+ self.interface = interface_r.interface
55
+ self.reservation = enums.ReservedStatus(reservation_r.status)
56
+ self.reserved_by = reserved_by_r.username
57
+
58
+ def register_subscriptions(self, port) -> None:
59
+ port._conn.subscribe(P_RECEIVESYNC, utils.Update(self, "sync_status", "sync_status", port._check_identity))
60
+ port._conn.subscribe(P_RESERVEDBY, utils.Update(self, "reserved_by", "username", port._check_identity))
61
+ port._conn.subscribe(P_RESERVATION, utils.Update(self, "reservation", "status", port._check_identity))
62
+ port._conn.subscribe(P_INTERFACE, utils.Update(self, "interface", "interface", port._check_identity))
63
+
64
+
65
+ class PortChimeraLocalState(PortLocalState):
66
+ """Chimera port's local state
67
+ """
68
+ __slots__ = ("capabilities",)
69
+ capabilities: "P_CAPABILITIES.GetDataAttr"
70
+
71
+ async def initiate(self, port) -> None:
72
+ capabilities, _ = await asyncio.gather(
73
+ port.capabilities.get(),
74
+ super().initiate(port)
75
+ )
76
+ self.capabilities = capabilities
77
+
78
+
79
+ class PortL23LocalState(PortLocalState):
80
+ """L23 port's local state
81
+ """
82
+ __slots__ = (
83
+ "capabilities",
84
+ "traffic_state"
85
+ )
86
+ capabilities: "P_CAPABILITIES.GetDataAttr"
87
+
88
+ def __init__(self) -> None:
89
+ self.traffic_state: "enums.TrafficOnOff" = enums.TrafficOnOff.OFF
90
+
91
+ async def initiate(self, port) -> None:
92
+ capabilities, traffic_state_r, _ = await asyncio.gather(
93
+ port.capabilities.get(),
94
+ port.traffic.state.get(),
95
+ super().initiate(port)
96
+ )
97
+ self.capabilities = capabilities
98
+ self.traffic_state = enums.TrafficOnOff(traffic_state_r.on_off)
99
+
100
+ def register_subscriptions(self, port) -> None:
101
+ super().register_subscriptions(port)
102
+ port._conn.subscribe(P_TRAFFIC, utils.Update(self, "traffic_state", "on_off", port._check_identity))
103
+
104
+
105
+ class PortL23GenuineLocalState(PortL23LocalState):
106
+ """L23 port's local state
107
+ """
108
+ __slots__ = ("port_possible_speed_modes",)
109
+
110
+ def __init__(self) -> None:
111
+ self.port_possible_speed_modes: List["enums.PortSpeedMode"] = []
112
+
113
+ async def initiate(self, port) -> None:
114
+ await super().initiate(port)
115
+ speed_detector = SpeedDetector(
116
+ self.capabilities,
117
+ self.interface
118
+ )
119
+ self.port_possible_speed_modes = speed_detector.find_port_possible_speed()
120
+
121
+ @property
122
+ def is_brr_mode_supported(self) -> bool:
123
+ """Whether this L23 port supports BRR mode.
124
+
125
+ :return: whether this port supports BRR mode.
126
+ :rtype: bool
127
+ """
128
+ return "T1" in self.interface
129
+
130
+
131
+ class PortL47LocalState(PortLocalState):
132
+ """L47 port's local state
133
+ """
134
+ __slots__ = (
135
+ "capabilities",
136
+ "traffic_state",
137
+ )
138
+ capabilities: "P4_CAPABILITIES.GetDataAttr"
139
+
140
+ def __init__(self) -> None:
141
+ self.traffic_state: "enums.L47PortState" = enums.L47PortState.OFF
142
+
143
+ async def initiate(self, port) -> None:
144
+ capabilities, traffic_state_r, _ = await asyncio.gather(
145
+ port.capabilities.get(),
146
+ port.state.get(),
147
+ super().initiate(port)
148
+ )
149
+ self.capabilities = capabilities
150
+ self.traffic_state = enums.L47PortState(traffic_state_r.state)
151
+
152
+ def register_subscriptions(self, port) -> None:
153
+ super().register_subscriptions(port)
154
+ port._conn.subscribe(P4_STATE, utils.Update(self, "traffic_state", "state", port._check_identity))
@@ -0,0 +1,104 @@
1
+ import asyncio
2
+ from typing import (
3
+ Optional,
4
+ Final,
5
+ )
6
+ from xoa_driver.internals.core import funcs
7
+ from xoa_driver.internals.commands import enums
8
+ from xoa_driver.internals.commands import (
9
+ C_RESERVATION,
10
+ C_CAPABILITIES,
11
+ C_RESERVEDBY,
12
+ )
13
+ from xoa_driver.internals.utils import attributes as utils
14
+ from xoa_driver.internals.exceptions.testers import UnsupportedFirmwareError
15
+
16
+ MIN_SUPPORTED_VERSION = 446.5
17
+
18
+
19
+ class TesterLocalState:
20
+ """Tester local state
21
+
22
+ :param host: tester's address/hostname
23
+ :type host: str
24
+ :param port: the port number for connection establishment
25
+ :type port: int
26
+ """
27
+ __slots__ = (
28
+ "host",
29
+ "port",
30
+ "model",
31
+ "capabilities",
32
+ "serial_number",
33
+ "version_major",
34
+ "driver_version",
35
+ "reservation",
36
+ "reserved_by",
37
+ )
38
+
39
+ def __init__(self, host: str, port: int) -> None:
40
+ self.host: Final[str] = host
41
+ self.port: Final[int] = port
42
+ self.model: str = ""
43
+ self.capabilities: Optional["C_CAPABILITIES.GetDataAttr"] = None
44
+ self.serial_number: int = 0
45
+ self.version_major: int = 0
46
+ self.driver_version: int = 0
47
+ self.reservation: enums.ReservedStatus = enums.ReservedStatus.RELEASED
48
+ self.reserved_by: str = ""
49
+
50
+ async def initiate(self, tester) -> None:
51
+ (
52
+ capabilities_resp,
53
+ model_res,
54
+ v_major_res,
55
+ serial_res,
56
+ reserved_by_res,
57
+ reservation_resp,
58
+ ) = await funcs.apply(
59
+ tester.capabilities.get(),
60
+ tester.model.get(),
61
+ tester.version_no.get(),
62
+ tester.serial_no.get(),
63
+ tester.reserved_by.get(),
64
+ tester.reservation.get(),
65
+ )
66
+ self.reserved_by = reserved_by_res.username
67
+ self.model = model_res.model
68
+ self.driver_version = v_major_res.pci_driver_version
69
+ self.version_major = v_major_res.chassis_major_version
70
+ self.serial_number = serial_res.serial_number
71
+ self.reservation = reservation_resp.operation
72
+ self.capabilities = capabilities_resp
73
+
74
+ def register_subscriptions(self, tester) -> None:
75
+ tester._conn.subscribe(C_RESERVEDBY, utils.Update(self, "reserved_by", "username"))
76
+ tester._conn.subscribe(C_RESERVATION, utils.Update(self, "reservation", "operation"))
77
+
78
+
79
+ class GenuineTesterLocalState(TesterLocalState):
80
+ """Genuine Tester Local State
81
+
82
+ :param host: tester's address/hostname
83
+ :type host: str
84
+ :param port: the port number for connection establishment
85
+ :type port: int
86
+ """
87
+ __slots__ = ("build_string", "version_minor")
88
+
89
+ def __init__(self, host: str, port: int) -> None:
90
+ super().__init__(host, port)
91
+ self.build_string: str = ""
92
+ self.version_minor: int = 0
93
+
94
+ async def initiate(self, tester) -> None:
95
+ bs, v_minor, _ = await asyncio.gather(
96
+ tester.build_string.get(),
97
+ tester.version_no_minor.get(),
98
+ super().initiate(tester)
99
+ )
100
+ self.build_string = bs.build_string
101
+ self.version_minor = v_minor.chassis_minor_version
102
+ current_version = float(f"{self.version_major}.{self.version_minor}")
103
+ if current_version < MIN_SUPPORTED_VERSION:
104
+ raise UnsupportedFirmwareError(current_version)
File without changes
@@ -0,0 +1,33 @@
1
+ from dataclasses import dataclass
2
+ from typing import (
3
+ Callable,
4
+ Type,
5
+ TYPE_CHECKING,
6
+ )
7
+ if TYPE_CHECKING:
8
+ from xoa_driver.internals.core.transporter.protocol.struct_response import Response
9
+ from xoa_driver.internals.core.transporter._typings import XoaCommandType
10
+ from xoa_driver.internals.core import interfaces as itf
11
+
12
+
13
+ @dataclass
14
+ class Update:
15
+ inst: Type
16
+ property_name: str
17
+ response_key: str
18
+ condition: Callable[["Response"], bool] = lambda _: True
19
+
20
+ # keep it Async just for consistent interface of event_observer
21
+ async def __call__(self, response: "Response") -> None:
22
+ if not self.condition(response):
23
+ return None
24
+ v = getattr(response.values, self.response_key)
25
+ setattr(self.inst, self.property_name, v)
26
+
27
+
28
+ def on_event(self, evt: "XoaCommandType", callback: "itf.CallbackType") -> None:
29
+ async def _f(response: "Response", *args, **kwargs) -> None:
30
+ if not self._check_identity(response):
31
+ return None
32
+ await callback(self, response.values, *args, **kwargs)
33
+ self._conn.subscribe(evt, _f)
@@ -0,0 +1,63 @@
1
+ from typing import (
2
+ NamedTuple,
3
+ Type,
4
+ TypeVar,
5
+ )
6
+ from xoa_driver.internals.commands import P_CAPABILITIES
7
+
8
+ T = TypeVar("T", bound="CapID")
9
+
10
+
11
+ class CapID(NamedTuple):
12
+ """ID generated based on the port capability"""
13
+
14
+ can_set_autoneg: int
15
+ can_eee: int
16
+ can_hw_reg_access: int
17
+ can_tcvr_mii_reg_access: int
18
+ can_adv_phy_man: int
19
+ can_mdi_mdix: int
20
+ can_dyn_traffic_change: int
21
+ can_pcs_pma_config: int
22
+ can_fec: int
23
+ can_fec_stats: int
24
+ can_tx_eq: int
25
+ can_rx_retune: int
26
+ can_manipulate_preamble: int
27
+ can_set_link_train: int
28
+ can_link_flap: int
29
+ can_auto_neg_base_r: int
30
+ can_pma_error_pulse: int
31
+
32
+ @classmethod
33
+ def create_from_capabilities(cls: Type[T], cap: P_CAPABILITIES.GetDataAttr) -> T:
34
+ return cls(
35
+ cap.can_set_autoneg,
36
+ cap.can_eee,
37
+ cap.can_hw_reg_access,
38
+ cap.can_tcvr_mii_reg_access,
39
+ cap.can_adv_phy_man,
40
+ cap.can_mdi_mdix,
41
+ cap.can_dyn_traffic_change,
42
+ cap.can_pcs_pma_config,
43
+ cap.can_fec,
44
+ cap.can_fec_stats,
45
+ cap.can_tx_eq,
46
+ cap.can_rx_retune,
47
+ cap.can_manipulate_preamble,
48
+ cap.can_set_link_train,
49
+ cap.can_link_flap,
50
+ cap.can_auto_neg_base_r,
51
+ cap.can_pma_error_pulse,
52
+ )
53
+
54
+ def to_int(self) -> int:
55
+ return int("".join(str(ele) for ele in self), 2)
56
+
57
+ def __eq__(self, other: "CapID") -> bool:
58
+ if isinstance(other, CapID):
59
+ return self.to_int() == other.to_int()
60
+ return False
61
+
62
+ def __ne__(self, other: "CapID") -> bool:
63
+ return not self.__eq__(other)
@@ -0,0 +1,88 @@
1
+ from __future__ import annotations
2
+ import asyncio
3
+ import typing as t
4
+ from xoa_driver.internals.core import interfaces as itf
5
+ from xoa_driver.internals.core.transporter.protocol.struct_request import Request
6
+ from xoa_driver.internals.core.transporter._typings import ICommand
7
+
8
+
9
+ class Green:
10
+ @staticmethod
11
+ def is_connected(inst: itf.IConnection) -> bool:
12
+ return inst.is_connected
13
+
14
+ @staticmethod
15
+ def send(inst: itf.IConnection, data: bytes | bytearray | memoryview) -> None:
16
+ return inst.send(data)
17
+
18
+ @staticmethod
19
+ def close(inst: itf.IConnection) -> None:
20
+ return inst.close()
21
+
22
+ @staticmethod
23
+ async def prepare_data(inst: itf.IConnection, request: "Request") -> tuple[bytes, asyncio.Future]:
24
+ return await inst.prepare_data(request)
25
+
26
+ @staticmethod
27
+ def subscribe(inst: itf.IConnection, xmc_cls: "ICommand", callback: t.Callable) -> None:
28
+ return inst.subscribe(xmc_cls, callback)
29
+
30
+ @staticmethod
31
+ def on_disconnected(inst: itf.IConnection, callback: t.Callable) -> None:
32
+ return inst.on_disconnected(callback)
33
+
34
+
35
+ class Red:
36
+ @staticmethod
37
+ def is_connected(inst: itf.IConnection) -> bool:
38
+ return False
39
+
40
+ @staticmethod
41
+ def send(inst: itf.IConnection, data: bytes | bytearray | memoryview) -> None:
42
+ raise ConnectionRefusedError("The instance is not valid anymore, please obtain() a new one.")
43
+
44
+ @staticmethod
45
+ def close(inst) -> None:
46
+ raise ConnectionRefusedError("The instance is not valid anymore, please obtain() a new one.")
47
+
48
+ @staticmethod
49
+ async def prepare_data(inst, request: "Request") -> tuple[bytes, asyncio.Future]:
50
+ raise ConnectionRefusedError("The instance is not valid anymore, please obtain() a new one.")
51
+
52
+ @staticmethod
53
+ def subscribe(inst, xmc_cls: "ICommand", callback: t.Callable) -> None:
54
+ raise ConnectionRefusedError("The instance is not valid anymore, please obtain() a new one.")
55
+
56
+ @staticmethod
57
+ def on_disconnected(inst, callback: t.Callable) -> None:
58
+ raise ConnectionRefusedError("The instance is not valid anymore, please obtain() a new one.")
59
+
60
+
61
+ class ConnectionTrafficLight:
62
+ __slots__ = ("_conn", "state")
63
+
64
+ def __init__(self, connection: itf.IConnection) -> None:
65
+ self._conn = connection
66
+ self.state = Green
67
+
68
+ def set_outdated(self) -> None:
69
+ self.state = Red
70
+
71
+ @property
72
+ def is_connected(self) -> bool:
73
+ return self.state.is_connected(self._conn)
74
+
75
+ def send(self, data: bytes | bytearray | memoryview) -> None:
76
+ return self.state.send(self._conn, data)
77
+
78
+ def close(self) -> None:
79
+ return self.state.close(self._conn)
80
+
81
+ async def prepare_data(self, request: "Request") -> tuple[bytes, asyncio.Future]:
82
+ return await self.state.prepare_data(self._conn, request)
83
+
84
+ def subscribe(self, xmc_cls: "ICommand", callback: t.Callable) -> None:
85
+ return self.state.subscribe(self._conn, xmc_cls, callback)
86
+
87
+ def on_disconnected(self, callback: t.Callable) -> None:
88
+ return self.state.on_disconnected(self._conn, callback)
File without changes
@@ -0,0 +1,26 @@
1
+ from typing import (
2
+ Protocol,
3
+ List,
4
+ Type,
5
+ TYPE_CHECKING,
6
+ )
7
+
8
+ if TYPE_CHECKING:
9
+ from xoa_driver.internals.core import interfaces as itf
10
+ from .. import kind
11
+ from . import observer
12
+
13
+
14
+ class IIndexType(Protocol):
15
+ def __init__(self, conn: "itf.IConnection", kind: "kind.IndicesKind", observer: "observer.IndicesObserver") -> None: ... # noqa: E704
16
+
17
+ async def delete(self) -> None: ... # noqa: E704
18
+
19
+ @property
20
+ def idx(self) -> int: ... # noqa: E704
21
+
22
+ @classmethod
23
+ async def _fetch(cls, conn, module_id, port_id) -> List[int]: ... # noqa: E704
24
+
25
+ @classmethod
26
+ async def _new(cls, conn: "itf.IConnection", kind: "kind.IndicesKind", observer: "observer.IndicesObserver") -> Type: ... # noqa: E704
@@ -0,0 +1,56 @@
1
+ from typing import (
2
+ List,
3
+ Type,
4
+ Union,
5
+ Generic,
6
+ TypeVar,
7
+ TYPE_CHECKING,
8
+ )
9
+ if TYPE_CHECKING:
10
+ from xoa_driver.internals.core import interfaces as itf
11
+ from xoa_driver.internals.commands import (
12
+ PS_MODIFIERCOUNT,
13
+ PS_MODIFIEREXTCOUNT
14
+ )
15
+ CT = Union[Type[PS_MODIFIERCOUNT], Type[PS_MODIFIEREXTCOUNT]]
16
+
17
+ MT = TypeVar("MT")
18
+
19
+
20
+ class ModifiersManager(Generic[MT]):
21
+ def __init__(self, conn: "itf.IConnection", kind, count_type: "CT", modifier_type: Type[MT]) -> None:
22
+ self.__conn = conn
23
+ self.__kind = kind
24
+ self.__modifier_type = modifier_type
25
+
26
+ self._count = count_type(self.__conn, *kind)
27
+ self.__items: List[MT] = []
28
+
29
+ async def _populate(self) -> None:
30
+ count = (await self._count.get()).to_tuple()[0] # modifier_count or ext_modifier_count
31
+ self.__items = [
32
+ self.__modifier_type(
33
+ self.__conn,
34
+ *self.__kind,
35
+ idx
36
+ )
37
+ for idx in range(count)
38
+ ]
39
+
40
+ async def configure(self, number: int) -> None:
41
+ await self._count.set(number)
42
+ await self._populate()
43
+
44
+ async def clear(self) -> None:
45
+ await self._count.set(0)
46
+ self.__items.clear()
47
+
48
+ def __len__(self) -> int:
49
+ return len(self.__items)
50
+
51
+ def __iter__(self):
52
+ return iter(self.__items)
53
+
54
+ def obtain(self, idx: int) -> MT:
55
+ """Access modifier of the index value"""
56
+ return self.__items[idx]
@@ -0,0 +1,95 @@
1
+ import asyncio
2
+ from typing import (
3
+ List,
4
+ Type,
5
+ Generic,
6
+ TypeVar,
7
+ TYPE_CHECKING,
8
+ )
9
+ if TYPE_CHECKING:
10
+ from xoa_driver.internals.core import interfaces as itf
11
+ from ._interfaces import IIndexType
12
+
13
+ from . import observer
14
+ from .. import kind
15
+
16
+
17
+ IT = TypeVar("IT", bound="IIndexType")
18
+
19
+
20
+ class IndexManager(Generic[IT]):
21
+ __slots__ = ("_conn", "_idx_type", "_module_id", "_port_id", "_indices", "_lock", "_observer")
22
+
23
+ def __init__(self, conn: "itf.IConnection", idx_type: Type[IT], module_id: int, port_id: int) -> None:
24
+ self._conn = conn
25
+ self._idx_type = idx_type
26
+ self._module_id = module_id
27
+ self._port_id = port_id
28
+ self._indices: List[IT] = []
29
+ self._lock = asyncio.Lock()
30
+ self._observer: "observer.IndicesObserver" = observer.IndicesObserver()
31
+ self._observer.subscribe(
32
+ observer.IndexEvents.DEL,
33
+ self.__remove_from_slot
34
+ )
35
+
36
+ async def server_sync(self) -> None:
37
+ """Sync the indices with xenaserver"""
38
+ self._indices.clear()
39
+ idxs: List[int] = await self._idx_type._fetch(self._conn, self._module_id, self._port_id)
40
+ for idx_id in idxs:
41
+ index_kind = kind.IndicesKind(
42
+ self._module_id,
43
+ self._port_id,
44
+ idx_id
45
+ )
46
+ idx_instance = self._idx_type(self._conn, index_kind, self._observer)
47
+ self._indices.append(idx_instance)
48
+
49
+ def __str__(self) -> str:
50
+ return f"Iterable[{self._idx_type.__name__}]({self._indices!s})"
51
+
52
+ def __len__(self) -> int:
53
+ """Return the number of existing indices"""
54
+ return len(self._indices)
55
+
56
+ def __iter__(self):
57
+ return iter(self._indices)
58
+
59
+ def obtain(self, key: int):
60
+ return self._indices[key]
61
+
62
+ def obtain_multiple(self, *keys: int):
63
+ """Obtain multiple resources as a tuple of indices"""
64
+ return tuple(self._indices[k] for k in keys)
65
+
66
+ def __detect_empty_idx_slot(self) -> int:
67
+ if len(self._indices) == 0:
68
+ return 0
69
+ existing_indices = [i.idx for i in self._indices]
70
+ empties = [
71
+ ele
72
+ for ele in range(max(existing_indices) + 1)
73
+ if ele not in existing_indices
74
+ ]
75
+ return min(empties) if empties else len(existing_indices)
76
+
77
+ def __remove_from_slot(self, index_inst: Type) -> None:
78
+ # throws ValueError if element is not exists in list of indices
79
+ self._indices.remove(index_inst)
80
+
81
+ async def create(self):
82
+ async with self._lock:
83
+ index_kind = kind.IndicesKind(
84
+ self._module_id,
85
+ self._port_id,
86
+ self.__detect_empty_idx_slot()
87
+ )
88
+ index_inst: IT = await self._idx_type._new(self._conn, index_kind, self._observer)
89
+ assert index_inst, f"Failed to create Index: {len(self)}"
90
+ self._indices.append(index_inst)
91
+ return index_inst
92
+
93
+ async def remove(self, position_idx: int) -> None:
94
+ """Remove an index from the port"""
95
+ await self._indices[position_idx].delete()
@@ -0,0 +1,17 @@
1
+ from enum import IntEnum, auto
2
+
3
+
4
+ class IndexEvents(IntEnum):
5
+ DEL = auto()
6
+
7
+
8
+ class IndicesObserver:
9
+ def __init__(self) -> None:
10
+ self.__subscriptions = {}
11
+
12
+ def subscribe(self, evt, func) -> None:
13
+ assert evt not in self.__subscriptions, f"Event <{evt}> is already registered."
14
+ self.__subscriptions[evt] = func
15
+
16
+ def notify(self, evt, index_inst) -> None:
17
+ self.__subscriptions[evt](index_inst)
@@ -0,0 +1,19 @@
1
+ from typing import NamedTuple
2
+
3
+
4
+ class ModuleKind(NamedTuple):
5
+ """NamedTuple of id's of module."""
6
+ module_id: int
7
+
8
+
9
+ class PortKind(NamedTuple):
10
+ """NamedTuple of id's of module, port."""
11
+ module_id: int
12
+ port_id: int
13
+
14
+
15
+ class IndicesKind(NamedTuple):
16
+ """NamedTuple of id's of module, port, and xindex."""
17
+ module_id: int
18
+ port_id: int
19
+ index_id: int
File without changes