openubmc-bingo 0.5.240__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.

Potentially problematic release.


This version of openubmc-bingo might be problematic. Click here for more details.

Files changed (242) hide show
  1. bmcgo/__init__.py +12 -0
  2. bmcgo/bmcgo.py +22 -0
  3. bmcgo/bmcgo_config.py +176 -0
  4. bmcgo/cli/__init__.py +10 -0
  5. bmcgo/cli/cli.py +584 -0
  6. bmcgo/codegen/__init__.py +14 -0
  7. bmcgo/codegen/c/__init__.py +9 -0
  8. bmcgo/codegen/c/annotation.py +52 -0
  9. bmcgo/codegen/c/argument.py +42 -0
  10. bmcgo/codegen/c/codegen.py +153 -0
  11. bmcgo/codegen/c/comment.py +22 -0
  12. bmcgo/codegen/c/ctype_defination.py +353 -0
  13. bmcgo/codegen/c/helper.py +87 -0
  14. bmcgo/codegen/c/interface.py +63 -0
  15. bmcgo/codegen/c/method.py +82 -0
  16. bmcgo/codegen/c/property.py +180 -0
  17. bmcgo/codegen/c/renderer.py +21 -0
  18. bmcgo/codegen/c/signal.py +64 -0
  19. bmcgo/codegen/c/template/client.c.mako +145 -0
  20. bmcgo/codegen/c/template/client.h.mako +36 -0
  21. bmcgo/codegen/c/template/interface.c.mako +0 -0
  22. bmcgo/codegen/c/template/interface.introspect.xml.mako +99 -0
  23. bmcgo/codegen/c/template/micro_component.c.mako +32 -0
  24. bmcgo/codegen/c/template/public.c.mako +228 -0
  25. bmcgo/codegen/c/template/public.h.mako +128 -0
  26. bmcgo/codegen/c/template/server.c.mako +104 -0
  27. bmcgo/codegen/c/template/server.h.mako +36 -0
  28. bmcgo/codegen/lua/.lua-format +7 -0
  29. bmcgo/codegen/lua/Makefile +101 -0
  30. bmcgo/codegen/lua/__init__.py +9 -0
  31. bmcgo/codegen/lua/codegen.py +171 -0
  32. bmcgo/codegen/lua/proto/Makefile +87 -0
  33. bmcgo/codegen/lua/proto/ipmi_types.proto +17 -0
  34. bmcgo/codegen/lua/proto/types.proto +52 -0
  35. bmcgo/codegen/lua/script/check_intfs.py +161 -0
  36. bmcgo/codegen/lua/script/dto/__init__.py +11 -0
  37. bmcgo/codegen/lua/script/dto/exception.py +53 -0
  38. bmcgo/codegen/lua/script/dto/kepler_abstract.py +47 -0
  39. bmcgo/codegen/lua/script/dto/options.py +33 -0
  40. bmcgo/codegen/lua/script/dto/print_simple.py +19 -0
  41. bmcgo/codegen/lua/script/dto/redfish_api.py +241 -0
  42. bmcgo/codegen/lua/script/dto/url_route.py +195 -0
  43. bmcgo/codegen/lua/script/gen_db_json.py +444 -0
  44. bmcgo/codegen/lua/script/gen_depends.py +89 -0
  45. bmcgo/codegen/lua/script/gen_entry.py +263 -0
  46. bmcgo/codegen/lua/script/gen_feature_json.py +156 -0
  47. bmcgo/codegen/lua/script/gen_historical_local_db_json.py +88 -0
  48. bmcgo/codegen/lua/script/gen_intf_json.py +261 -0
  49. bmcgo/codegen/lua/script/gen_intf_rpc_json.py +575 -0
  50. bmcgo/codegen/lua/script/gen_ipmi_json.py +485 -0
  51. bmcgo/codegen/lua/script/gen_mdb_json.py +117 -0
  52. bmcgo/codegen/lua/script/gen_rpc_msg_json.py +487 -0
  53. bmcgo/codegen/lua/script/gen_schema.py +302 -0
  54. bmcgo/codegen/lua/script/ipmi_types_pb2.py +135 -0
  55. bmcgo/codegen/lua/script/loader/__init__.py +11 -0
  56. bmcgo/codegen/lua/script/loader/file_utils.py +33 -0
  57. bmcgo/codegen/lua/script/loader/kepler_abstract_collect.py +79 -0
  58. bmcgo/codegen/lua/script/loader/kepler_abstract_loader.py +47 -0
  59. bmcgo/codegen/lua/script/loader/redfish_loader.py +127 -0
  60. bmcgo/codegen/lua/script/lua_format.py +62 -0
  61. bmcgo/codegen/lua/script/mds_util.py +385 -0
  62. bmcgo/codegen/lua/script/merge_model.py +330 -0
  63. bmcgo/codegen/lua/script/merge_proto_algo.py +85 -0
  64. bmcgo/codegen/lua/script/proto_loader.py +47 -0
  65. bmcgo/codegen/lua/script/proto_plugin.py +140 -0
  66. bmcgo/codegen/lua/script/redfish_source_tree.py +118 -0
  67. bmcgo/codegen/lua/script/render_utils/__init__.py +38 -0
  68. bmcgo/codegen/lua/script/render_utils/base.py +25 -0
  69. bmcgo/codegen/lua/script/render_utils/client_lua.py +98 -0
  70. bmcgo/codegen/lua/script/render_utils/controller_lua.py +71 -0
  71. bmcgo/codegen/lua/script/render_utils/db_lua.py +224 -0
  72. bmcgo/codegen/lua/script/render_utils/error_lua.py +185 -0
  73. bmcgo/codegen/lua/script/render_utils/factory.py +52 -0
  74. bmcgo/codegen/lua/script/render_utils/ipmi_lua.py +159 -0
  75. bmcgo/codegen/lua/script/render_utils/ipmi_message_lua.py +24 -0
  76. bmcgo/codegen/lua/script/render_utils/mdb_lua.py +177 -0
  77. bmcgo/codegen/lua/script/render_utils/mdb_register.py +215 -0
  78. bmcgo/codegen/lua/script/render_utils/message_lua.py +26 -0
  79. bmcgo/codegen/lua/script/render_utils/messages_lua.py +156 -0
  80. bmcgo/codegen/lua/script/render_utils/model_lua.py +485 -0
  81. bmcgo/codegen/lua/script/render_utils/old_model_lua.py +429 -0
  82. bmcgo/codegen/lua/script/render_utils/plugin_lua.py +38 -0
  83. bmcgo/codegen/lua/script/render_utils/redfish_proto.py +86 -0
  84. bmcgo/codegen/lua/script/render_utils/request_lua.py +76 -0
  85. bmcgo/codegen/lua/script/render_utils/service_lua.py +130 -0
  86. bmcgo/codegen/lua/script/render_utils/utils_message_lua.py +125 -0
  87. bmcgo/codegen/lua/script/render_utils/validate_lua.py +221 -0
  88. bmcgo/codegen/lua/script/sep_ipmi_message_cmds.py +217 -0
  89. bmcgo/codegen/lua/script/template.py +166 -0
  90. bmcgo/codegen/lua/script/types_pb2.py +516 -0
  91. bmcgo/codegen/lua/script/utils.py +663 -0
  92. bmcgo/codegen/lua/script/validate.py +80 -0
  93. bmcgo/codegen/lua/script/yaml_to_json.py +73 -0
  94. bmcgo/codegen/lua/templates/Makefile +114 -0
  95. bmcgo/codegen/lua/templates/apps/Makefile +261 -0
  96. bmcgo/codegen/lua/templates/apps/Makefile.mdb.mk +64 -0
  97. bmcgo/codegen/lua/templates/apps/app.lua.mako +19 -0
  98. bmcgo/codegen/lua/templates/apps/class.lua.mako +35 -0
  99. bmcgo/codegen/lua/templates/apps/client.lua.mako +429 -0
  100. bmcgo/codegen/lua/templates/apps/controller.lua.mako +276 -0
  101. bmcgo/codegen/lua/templates/apps/datas.lua.mako +8 -0
  102. bmcgo/codegen/lua/templates/apps/db.lua.mako +89 -0
  103. bmcgo/codegen/lua/templates/apps/entry.lua.mako +128 -0
  104. bmcgo/codegen/lua/templates/apps/feature.lua.mako +37 -0
  105. bmcgo/codegen/lua/templates/apps/generate_route.mako +25 -0
  106. bmcgo/codegen/lua/templates/apps/impl_feature.lua.mako +72 -0
  107. bmcgo/codegen/lua/templates/apps/ipmi.lua.mako +97 -0
  108. bmcgo/codegen/lua/templates/apps/ipmi_cmd.lua.mako +18 -0
  109. bmcgo/codegen/lua/templates/apps/ipmi_message.lua.mako +36 -0
  110. bmcgo/codegen/lua/templates/apps/local_db.lua.mako +263 -0
  111. bmcgo/codegen/lua/templates/apps/main.lua.mako +25 -0
  112. bmcgo/codegen/lua/templates/apps/mc.lua.mako +77 -0
  113. bmcgo/codegen/lua/templates/apps/mdb.lua.mako +45 -0
  114. bmcgo/codegen/lua/templates/apps/mdb_interface.lua.mako +73 -0
  115. bmcgo/codegen/lua/templates/apps/message.lua.mako +38 -0
  116. bmcgo/codegen/lua/templates/apps/model.lua.mako +239 -0
  117. bmcgo/codegen/lua/templates/apps/orm_classes.lua.mako +16 -0
  118. bmcgo/codegen/lua/templates/apps/plugin.lua.mako +8 -0
  119. bmcgo/codegen/lua/templates/apps/redfish.proto.mako +47 -0
  120. bmcgo/codegen/lua/templates/apps/service.lua.mako +440 -0
  121. bmcgo/codegen/lua/templates/apps/signal_listen.lua.mako +19 -0
  122. bmcgo/codegen/lua/templates/apps/utils/default_intf.lua.mako +41 -0
  123. bmcgo/codegen/lua/templates/apps/utils/enum.mako +10 -0
  124. bmcgo/codegen/lua/templates/apps/utils/imports.mako +13 -0
  125. bmcgo/codegen/lua/templates/apps/utils/mdb_intf.lua.mako +25 -0
  126. bmcgo/codegen/lua/templates/apps/utils/mdb_obj.lua.mako +23 -0
  127. bmcgo/codegen/lua/templates/apps/utils/message.mako +160 -0
  128. bmcgo/codegen/lua/templates/apps/utils/request.lua.mako +59 -0
  129. bmcgo/codegen/lua/templates/apps/utils/validate.mako +83 -0
  130. bmcgo/codegen/lua/templates/errors.lua.mako +36 -0
  131. bmcgo/codegen/lua/templates/messages.lua.mako +32 -0
  132. bmcgo/codegen/lua/templates/new_app/.clang-format.mako +170 -0
  133. bmcgo/codegen/lua/templates/new_app/.gitignore.mako +26 -0
  134. bmcgo/codegen/lua/templates/new_app/CHANGELOG.md.mako +0 -0
  135. bmcgo/codegen/lua/templates/new_app/CMakeLists.txt.mako +29 -0
  136. bmcgo/codegen/lua/templates/new_app/Makefile.mako +25 -0
  137. bmcgo/codegen/lua/templates/new_app/README.md.mako +0 -0
  138. bmcgo/codegen/lua/templates/new_app/conanfile.py.mako +7 -0
  139. bmcgo/codegen/lua/templates/new_app/config.cfg.mako +6 -0
  140. bmcgo/codegen/lua/templates/new_app/mds/model.json.mako +3 -0
  141. bmcgo/codegen/lua/templates/new_app/mds/service.json.mako +21 -0
  142. bmcgo/codegen/lua/templates/new_app/permissions.ini.mako +16 -0
  143. bmcgo/codegen/lua/templates/new_app/src/lualib/${project_name}_app.lua.mako +16 -0
  144. bmcgo/codegen/lua/templates/new_app/src/service/main.lua.mako +25 -0
  145. bmcgo/codegen/lua/templates/new_app/test/integration/test_${project_name}.conf.mako +9 -0
  146. bmcgo/codegen/lua/templates/new_app/test/integration/test_${project_name}.lua.mako +47 -0
  147. bmcgo/codegen/lua/templates/new_app/test/unit/test.lua.mako +23 -0
  148. bmcgo/codegen/lua/templates/new_app/user_conf/rootfs/etc/systemd/system/${project_name}.service.mako +18 -0
  149. bmcgo/codegen/lua/templates/new_app/user_conf/rootfs/etc/systemd/system/multi-user.target.wants/${project_name}.service.link +1 -0
  150. bmcgo/component/__init__.py +10 -0
  151. bmcgo/component/analysis/analysis.py +183 -0
  152. bmcgo/component/analysis/build_deps.py +165 -0
  153. bmcgo/component/analysis/data_deps.py +333 -0
  154. bmcgo/component/analysis/dep-rules.json +912 -0
  155. bmcgo/component/analysis/dep_node.py +110 -0
  156. bmcgo/component/analysis/intf_deps.py +163 -0
  157. bmcgo/component/analysis/intf_validation.py +254 -0
  158. bmcgo/component/analysis/rule.py +211 -0
  159. bmcgo/component/analysis/smc_dfx_whitelist.json +11 -0
  160. bmcgo/component/analysis/sr_validation.py +391 -0
  161. bmcgo/component/build.py +222 -0
  162. bmcgo/component/component_dt_version_parse.py +348 -0
  163. bmcgo/component/component_helper.py +114 -0
  164. bmcgo/component/coverage/__init__.py +11 -0
  165. bmcgo/component/coverage/c_incremental_cov_report.template +53 -0
  166. bmcgo/component/coverage/incremental_cov.py +464 -0
  167. bmcgo/component/deploy.py +110 -0
  168. bmcgo/component/gen.py +169 -0
  169. bmcgo/component/package_info.py +236 -0
  170. bmcgo/component/template/conanbase.py.mako +278 -0
  171. bmcgo/component/template/conanfile.deploy.py.mako +40 -0
  172. bmcgo/component/test.py +947 -0
  173. bmcgo/errors.py +119 -0
  174. bmcgo/frame.py +217 -0
  175. bmcgo/functional/__init__.py +10 -0
  176. bmcgo/functional/analysis.py +96 -0
  177. bmcgo/functional/bmc_studio_action.py +98 -0
  178. bmcgo/functional/check.py +185 -0
  179. bmcgo/functional/conan_index_build.py +251 -0
  180. bmcgo/functional/config.py +332 -0
  181. bmcgo/functional/csr_build.py +724 -0
  182. bmcgo/functional/deploy.py +263 -0
  183. bmcgo/functional/diff.py +235 -0
  184. bmcgo/functional/fetch.py +235 -0
  185. bmcgo/functional/full_component.py +391 -0
  186. bmcgo/functional/maintain.py +381 -0
  187. bmcgo/functional/new.py +166 -0
  188. bmcgo/functional/schema_valid.py +111 -0
  189. bmcgo/functional/simple_sign.py +104 -0
  190. bmcgo/functional/upgrade.py +78 -0
  191. bmcgo/ipmigen/__init__.py +13 -0
  192. bmcgo/ipmigen/ctype_defination.py +82 -0
  193. bmcgo/ipmigen/ipmigen.py +309 -0
  194. bmcgo/ipmigen/template/cmd.c.mako +366 -0
  195. bmcgo/ipmigen/template/ipmi.c.mako +25 -0
  196. bmcgo/ipmigen/template/ipmi.h.mako +51 -0
  197. bmcgo/logger.py +176 -0
  198. bmcgo/misc.py +117 -0
  199. bmcgo/target/app.yml +17 -0
  200. bmcgo/target/install_sdk.yml +15 -0
  201. bmcgo/target/personal.yml +53 -0
  202. bmcgo/target/publish.yml +45 -0
  203. bmcgo/tasks/__init__.py +11 -0
  204. bmcgo/tasks/download_buildtools_hm.py +124 -0
  205. bmcgo/tasks/misc.py +15 -0
  206. bmcgo/tasks/task.py +354 -0
  207. bmcgo/tasks/task_build_conan.py +714 -0
  208. bmcgo/tasks/task_build_rootfs_img.py +595 -0
  209. bmcgo/tasks/task_buildgppbin.py +88 -0
  210. bmcgo/tasks/task_buildhpm_ext4.py +82 -0
  211. bmcgo/tasks/task_create_interface_config.py +122 -0
  212. bmcgo/tasks/task_download_buildtools.py +99 -0
  213. bmcgo/tasks/task_download_dependency.py +72 -0
  214. bmcgo/tasks/task_hpm_envir_prepare.py +112 -0
  215. bmcgo/tasks/task_packet_to_supporte.py +87 -0
  216. bmcgo/tasks/task_prepare.py +105 -0
  217. bmcgo/tasks/task_sign_and_pack_hpm.py +42 -0
  218. bmcgo/utils/__init__.py +10 -0
  219. bmcgo/utils/buffer.py +128 -0
  220. bmcgo/utils/combine_json_schemas.py +170 -0
  221. bmcgo/utils/component_post.py +54 -0
  222. bmcgo/utils/component_version_check.py +86 -0
  223. bmcgo/utils/config.py +1067 -0
  224. bmcgo/utils/fetch_component_code.py +232 -0
  225. bmcgo/utils/install_manager.py +61 -0
  226. bmcgo/utils/installations/__init__.py +10 -0
  227. bmcgo/utils/installations/base_installer.py +70 -0
  228. bmcgo/utils/installations/install_consts.py +30 -0
  229. bmcgo/utils/installations/install_plans/bingo.yml +11 -0
  230. bmcgo/utils/installations/install_workflow.py +50 -0
  231. bmcgo/utils/installations/installers/apt_installer.py +177 -0
  232. bmcgo/utils/installations/installers/pip_installer.py +46 -0
  233. bmcgo/utils/installations/version_util.py +100 -0
  234. bmcgo/utils/mapping_config_patch.py +443 -0
  235. bmcgo/utils/perf_analysis.py +114 -0
  236. bmcgo/utils/tools.py +704 -0
  237. bmcgo/worker.py +417 -0
  238. openubmc_bingo-0.5.240.dist-info/METADATA +30 -0
  239. openubmc_bingo-0.5.240.dist-info/RECORD +242 -0
  240. openubmc_bingo-0.5.240.dist-info/WHEEL +5 -0
  241. openubmc_bingo-0.5.240.dist-info/entry_points.txt +2 -0
  242. openubmc_bingo-0.5.240.dist-info/top_level.txt +1 -0
@@ -0,0 +1,440 @@
1
+ % if version >= 4:
2
+ ${make_header('lua')}
3
+ <%namespace name="imports" file="utils/imports.mako"/>
4
+ <%namespace name="default_intf" file="utils/default_intf.lua.mako"/>
5
+ <%namespace name="mdb_obj" file= "utils/mdb_obj.lua.mako"/>
6
+ <% has_signal = root['signals']%>
7
+ <% has_mdb = any('path' in cls_data for cls, cls_data in root['class_require'].items())%>
8
+ <% has_default = any((rpc['default'] != '' and not rpc['override']) for rpc in root['methods'])%>
9
+ <% ClassName = root['package'] + '_service' %>
10
+
11
+ % if root['has_ipmi_cmd']:
12
+ local ipmi = require 'ipmi'
13
+ % endif
14
+ % if has_default or has_mdb:
15
+ local mdb = require 'mc.mdb'
16
+ % endif
17
+ % if utils_py.check_local_reset_db(root) or utils_py.check_local_temporary_db(root):
18
+ local skynet = require 'skynet'
19
+ % endif
20
+ local class = require 'mc.class'
21
+ % if has_signal:
22
+ local context = require 'mc.context'
23
+ % endif
24
+ % if utils_py.check_need_mem_db(root):
25
+ local open_db = require '${project_name}.db'
26
+ % endif
27
+ % if root['path_level'] == 2:
28
+ local app_base = require 'mc.service_app_base'
29
+ % endif
30
+ % if utils_py.check_local_poweroff_db(root) or utils_py.check_local_reset_db(root) or utils_py.check_local_temporary_db(root):
31
+ local open_local_db = require '${project_name}.local_db'
32
+ % endif
33
+ % if (root['path_level'] == 2 and utils_py.check_db_open(root['package']) and utils_py.check_remote_per(root)) or root['class_require']:
34
+ local object_manage = require 'mc.mdb.object_manage'
35
+ % endif
36
+ % if root['path_level'] == 2 and utils_py.check_db_open(root['package']) and utils_py.check_remote_per(root):
37
+ local persist_client = require 'persistence.persist_client_lib'
38
+ % endif
39
+ % if utils_py.check_need_mem_db(root):
40
+ local orm_classes = require '${project_name}.orm_classes'
41
+ % endif
42
+ % if utils_py.check_need_mem_db(root) or utils_py.check_need_local_db(root):
43
+ local ok, datas = pcall(require, '${project_name}.datas')
44
+ if not ok then
45
+ datas = nil -- 如果没有datas配置,证明当前组件不需要datas,仅打开数据库
46
+ end
47
+ % endif
48
+
49
+ % for intf, intf_data in root['intf_imports'].items():
50
+ local ${intf}Types = require '${project_name}.json_types.${intf}'
51
+ % endfor
52
+
53
+ % for cls, cls_data in root['class_require'].items():
54
+ ${mdb_obj.render(cls, cls_data['data'], root['class_require'])}
55
+ % endfor
56
+
57
+ % if root['path_level'] == 2:
58
+ local model = require 'class.model'
59
+ % else:
60
+ local model = require '${project_name}.class.model'
61
+ % endif
62
+
63
+ ## 如果是子目录下的扩展,则不启动服务
64
+ % if root['path_level'] == 2:
65
+ local ${ClassName} = class(app_base.Service)
66
+ % else:
67
+ local ${ClassName} = class()
68
+ % endif
69
+
70
+ % if has_default:
71
+ ${default_intf.add_subs(ClassName)}
72
+ % endif
73
+ ${ClassName}.package = '${root['package']}'
74
+
75
+ % for rpc in root['methods']:
76
+ %if rpc['default'] != '' and not rpc['override']:
77
+ <% default_path = ClassName +'.'+ rpc['intf_class'] + 'Default' %>
78
+ require '${project_name}.json_types.${rpc['intf_class']}Default'
79
+ ${default_intf.render(default_path, ClassName, rpc['intf_class'] + "Default", rpc['interface'] + ".Default")}
80
+ %endif
81
+ % endfor
82
+ ## 动态对象生成创建接口,以便非CSR场景创建对象时使用
83
+ % for cls, cls_data in root['class_require'].items():
84
+ % if render_utils.is_dynamic_obj(cls_data['path']):
85
+
86
+ function ${ClassName}:Create${cls}(${", ".join(render_utils.get_path_params(render_utils.get_path(cls, root['class_require'])))}, prop_setting_cb)
87
+ local path = ${render_utils.make_path(render_utils.get_path(cls, root['class_require']))}
88
+ return object_manage.create_object("${cls}", path, path, prop_setting_cb)
89
+ end
90
+ % else:
91
+ % if version >= 15:
92
+
93
+ function ${ClassName}:Create${cls}(prop_setting_cb)
94
+ return object_manage.create_object("${cls}", '${cls}_0', ${render_utils.make_path(render_utils.get_path(cls, root['class_require']))}, prop_setting_cb)
95
+ end
96
+ % endif
97
+ % endif
98
+ %endfor
99
+
100
+ ## 生成注册回调的接口,增加参数校验
101
+ % for rpc in root['methods']:
102
+ <% class_intf = rpc['class'] + '_' + rpc['intf_class'] %>
103
+ function ${ClassName}:Impl${rpc['name']}(cb)
104
+ model.Impl${rpc['name']}(cb)
105
+ end
106
+ % endfor
107
+
108
+ % if version >= 9:
109
+ % for method, _ in root.get('private_class_require', {}).get('private', {}).get('data', {}).get('methods', {}).items():
110
+ function ${ClassName}:Impl${method}(cb)
111
+ model.Impl${method}(cb)
112
+ end
113
+
114
+ function ${ClassName}:${method}(...)
115
+ return model.${method}(...)
116
+ end
117
+
118
+ % endfor
119
+ % endif
120
+ ## 生成发送信号的接口
121
+ % for signal in root['signals']:
122
+ <% params = render_utils.params(signal['signature'])%>
123
+ % if ':' in signal['path']:
124
+ ---@param mdb_object object
125
+ % endif
126
+ % for p in render_utils.props(signal['signature']): ## 生成参数注释
127
+ ---@param ${p['name']} ${utils_py.do_type_to_lua(p['type'], p['repeated'])}
128
+ % endfor
129
+ function ${ClassName}:${signal['name']}(${'mdb_object,' if (':' in signal['path']) else ''}${params})
130
+ self.bus:signal(${'mdb_object.path' if (':' in signal['path']) else ('"'+signal['path']+'"')}, '${signal['interface']}', '${signal['signal_name']}', 'a{ss}${utils_py.do_service_types_to_dbus(root, signal['signature'][1:])}', context.get_context() or {}${"" if params == '' else ", "}${params})
131
+ end
132
+
133
+ % endfor
134
+
135
+ ## 适配订阅的片段复用
136
+ function ${ClassName}:get_bus()
137
+ return self.bus
138
+ end
139
+
140
+ % if root['has_ipmi_cmd']:
141
+ function ${ClassName}:register_ipmi_cmd(ipmi_cmd, cb)
142
+ self.ipmi_cmds[ipmi_cmd.name] = ipmi.register_ipmi_cmd(self.bus, self.service_name, ipmi_cmd, cb or self[ipmi_cmd.name])
143
+ end
144
+
145
+ function ${ClassName}:unregister_ipmi_cmd(ipmi_cmd)
146
+ local cmd_obj = self.ipmi_cmds[ipmi_cmd.name]
147
+ if not cmd_obj then
148
+ return
149
+ end
150
+
151
+ cmd_obj:unregister()
152
+ self.ipmi_cmds[ipmi_cmd.name] = nil
153
+ end
154
+ % endif
155
+
156
+ % if root['path_level'] == 2:
157
+ function ${ClassName}:ctor()
158
+ % else:
159
+ function ${ClassName}:ctor(bus)
160
+ self.bus = bus
161
+ % endif
162
+ % if root['has_ipmi_cmd']:
163
+ self.ipmi_cmds = {}
164
+ % endif
165
+ self.signal_slots = {}
166
+ self.name = self.name or ${ClassName}.package
167
+ % if utils_py.check_need_mem_db(root):
168
+ self.db = open_db(':memory:', datas)
169
+ % endif
170
+ % if root['path_level'] == 2:
171
+ % if utils_py.check_local_poweroff_db(root):
172
+ self.local_db = open_local_db(app_base.Service:get_local_db_path(self.name) .. '/${project_name}.db', datas, 'poweroff')
173
+ % endif
174
+ % endif
175
+ % if utils_py.check_local_reset_db(root) or utils_py.check_local_temporary_db(root):
176
+ if skynet.getenv('TEST_DATA_DIR') then
177
+ % if utils_py.check_local_reset_db(root):
178
+ self.reset_local_db = open_local_db(skynet.getenv('TEST_DATA_DIR')..'/${project_name}_reset.db', datas, "reset")
179
+ % endif
180
+ % if utils_py.check_local_temporary_db(root):
181
+ self.temporary_local_db = open_local_db(skynet.getenv('TEST_DATA_DIR')..'/${project_name}_temp.db', datas, "temporary")
182
+ % endif
183
+ else
184
+ % if utils_py.check_local_reset_db(root):
185
+ self.reset_local_db = open_local_db('/opt/bmc/pram/persistence.local/${project_name}.db', datas, "reset")
186
+ % endif
187
+ % if utils_py.check_local_temporary_db(root):
188
+ self.temporary_local_db = open_local_db('/dev/shm/persistence.local/${project_name}.db', datas, "temporary")
189
+ % endif
190
+ end
191
+ % endif
192
+
193
+ % if utils_py.check_need_mem_db(root):
194
+ orm_classes.init(self.db)
195
+ % endif
196
+ % if root['path_level'] == 2:
197
+ self.bus:request_name(app_base.Service.get_service_name(self.name))
198
+ % endif
199
+ model.init(self.bus)
200
+ ${ClassName}.bus = self.bus
201
+ end
202
+
203
+ % if root['path_level'] == 2:
204
+ function ${ClassName}:pre_init()
205
+ ${ClassName}.super.pre_init(self)
206
+ % if utils_py.check_remote_per(root):
207
+ self.persist = persist_client.new(self.bus, self.db, self, ${render_utils.get_not_recover_tables(root)})
208
+ object_manage.set_persist_client(self.persist)
209
+ % endif
210
+ end
211
+ % endif
212
+
213
+ ## servie初始化
214
+ function ${ClassName}:init()
215
+ % if root['path_level'] == 2:
216
+ ${ClassName}.super.init(self)
217
+ %endif
218
+ % if has_default:
219
+ self:SubscribeAll()
220
+ %endif
221
+ % if version < 15:
222
+ % for cls, cls_data in root['class_require'].items():## 非动态的对象初始化时就可以上树
223
+ % if not render_utils.is_dynamic_obj(cls_data['path']):
224
+ object_manage.create_object("${cls}", ${render_utils.make_path(render_utils.get_path(cls, root['class_require']))}, ${render_utils.make_path(render_utils.get_path(cls, root['class_require']))}, function(obj)
225
+ obj.ObjectName = '${cls}_0'
226
+ end)
227
+ % endif
228
+ %endfor
229
+ % endif
230
+ % for rpc in root['methods']:
231
+ %if not rpc['override'] :
232
+ self:Impl${rpc['name']}(function(obj, ctx, ...)
233
+ return self:Get${rpc['default']}Object():${rpc['func_name']}_PACKED(ctx, obj.path,...):unpack()
234
+ end)
235
+ %endif
236
+ % endfor
237
+ end
238
+
239
+ return ${ClassName}
240
+ % else:
241
+ ${make_header('lua')}
242
+ <%namespace name="imports" file="utils/imports.mako"/>
243
+ <%namespace name="default_intf" file="utils/default_intf.lua.mako"/>
244
+ <%namespace name="mdb_obj" file= "utils/mdb_obj.lua.mako"/>
245
+ <% ClassName = root['package'] + '_service' %>
246
+
247
+ % if root['path_level'] == 2:
248
+ local app_base = require 'mc.service_app_base'
249
+ % endif
250
+ local class = require 'mc.class'
251
+ local mdb = require 'mc.mdb'
252
+ % if utils_py.check_remote_per(root):
253
+ local object_manage = require 'mc.mdb.object_manage'
254
+ local persist_client = require 'persistence.persist_client_lib'
255
+ % endif
256
+ local context = require 'mc.context'
257
+
258
+ % for intf, intf_data in root['intf_imports'].items():
259
+ local ${intf}Types = require '${project_name}.json_types.${intf}'
260
+ % endfor
261
+
262
+ % for cls, cls_data in root['class_require'].items():
263
+ ${mdb_obj.render(cls, cls_data['data'], root['class_require'])}
264
+ % endfor
265
+
266
+ local cls_mng = require 'mc.class_mgnt'
267
+ % if root['path_level'] == 2:
268
+ local model = require 'class.model'
269
+ % else:
270
+ local model = require '${project_name}.class.model'
271
+ % endif
272
+
273
+ % if utils_py.check_local_poweroff_db(root) or utils_py.check_local_reset_db(root) or utils_py.check_local_temporary_db(root):
274
+ local open_local_db = require '${project_name}.local_db'
275
+ % endif
276
+ % if utils_py.check_db_open(root['package']):
277
+ local open_db = require '${project_name}.db'
278
+ local orm_classes = require '${project_name}.orm_classes'
279
+ local ok, datas = pcall(require, '${project_name}.datas')
280
+ if not ok then
281
+ -- 如果没有datas配置,证明当前组件不需要datas,仅打开数据库
282
+ datas = nil
283
+ end
284
+ % endif
285
+
286
+ ## 如果是子目录下的扩展,则不启动服务
287
+ % if root['path_level'] == 2:
288
+ local ${ClassName} = class(app_base.Service)
289
+ % else:
290
+ local ${ClassName} = class()
291
+ % endif
292
+
293
+ ${default_intf.add_subs(ClassName)}
294
+ ${ClassName}.package = '${root['package']}'
295
+
296
+ % for rpc in root['methods']:
297
+ %if rpc['default'] != '' and not rpc['override']:
298
+ <% default_path = ClassName +'.'+ rpc['intf_class'] + 'Default' %>
299
+ require '${project_name}.json_types.${rpc['intf_class']}Default'
300
+ ${default_intf.render(default_path, ClassName, rpc['intf_class'] + "Default", rpc['interface'] + ".Default")}
301
+ %endif
302
+ % endfor
303
+ ## 动态对象生成创建接口,以便非CSR场景创建对象时使用
304
+ % for cls, cls_data in root['class_require'].items():
305
+ % if render_utils.is_dynamic_obj(cls_data['path']):
306
+ function ${ClassName}:Create${cls}(${", ".join(render_utils.get_path_params(render_utils.get_path(cls, root['class_require'])))}, prop_setting_cb)
307
+ local path = ${render_utils.make_path(render_utils.get_path(cls, root['class_require']))}
308
+ local object = cls_mng("${cls}").new(path)
309
+ object:create_mdb_objects(path)
310
+ if prop_setting_cb then
311
+ prop_setting_cb(object)
312
+ end
313
+ % if root['path_level'] == 2 and utils_py.check_remote_per(root):
314
+ object:assign_persistence_props(self.persist)
315
+ % endif
316
+ object:register_mdb_objects()
317
+ return object
318
+ end
319
+ % endif
320
+ %endfor
321
+
322
+ ## 生成注册回调的接口,增加参数校验
323
+ % for rpc in root['methods']:
324
+ <% class_intf = rpc['class'] + '_' + rpc['intf_class'] %>
325
+ function ${ClassName}:Impl${rpc['name']}(cb)
326
+ model.Impl${rpc['name']}(cb)
327
+ end
328
+ % endfor
329
+
330
+ ## 生成发送信号的接口
331
+ % for signal in root['signals']:
332
+ <% params = render_utils.params(signal['signature'])%>
333
+ % if ':' in signal['path']:
334
+ ---@param mdb_object object
335
+ % endif
336
+ % for p in render_utils.props(signal['signature']): ## 生成参数注释
337
+ ---@param ${p['name']} ${utils_py.do_type_to_lua(p['type'], p['repeated'])}
338
+ % endfor
339
+ function ${ClassName}:${signal['name']}(${'mdb_object,' if (':' in signal['path']) else ''}${params})
340
+ self.bus:signal(${'mdb_object.path' if (':' in signal['path']) else ('"'+signal['path']+'"')}, '${signal['interface']}', '${signal['signal_name']}', 'a{ss}${utils_py.do_service_types_to_dbus(root, signal['signature'][1:])}', context.get_context() or {}${"" if params == '' else ", "}${params})
341
+ end
342
+
343
+ % endfor
344
+
345
+ ## 适配订阅的片段复用
346
+ function ${ClassName}:get_bus()
347
+ return self.bus
348
+ end
349
+
350
+ % if root['path_level'] == 2:
351
+ function ${ClassName}:ctor()
352
+ % else:
353
+ function ${ClassName}:ctor(bus)
354
+ self.bus = bus
355
+ % endif
356
+ if not self.name then
357
+ self.name = ${ClassName}.package
358
+ end
359
+ self.signal_slots = {}
360
+ % if 'Security' in root['package']:
361
+ local skynet = require 'skynet'
362
+ self.db = open_db(skynet.getenv('SECURITY_DB'), datas)
363
+ % elif utils_py.check_db_open(root['package']):
364
+ % if root['path_level'] == 2:
365
+ % if utils_py.check_local_poweroff_db(root):
366
+ self.local_db = open_local_db(app_base.Service:get_local_db_path(self.name) .. '/${project_name}.db', datas, 'poweroff')
367
+ % endif
368
+ % endif
369
+ % if utils_py.check_local_reset_db(root):
370
+ local skynet = require 'skynet'
371
+ if skynet.getenv('TEST_DATA_DIR') then
372
+ self.reset_local_db = open_local_db(skynet.getenv('TEST_DATA_DIR')..'/${project_name}_reset.db', datas, "reset")
373
+ else
374
+ self.reset_local_db = open_local_db('/opt/bmc/pram/persistence.local/${project_name}.db', datas, "reset")
375
+ end
376
+ % endif
377
+ % if utils_py.check_local_temporary_db(root):
378
+ local skynet = require 'skynet'
379
+ if skynet.getenv('TEST_DATA_DIR') then
380
+ self.temporary_local_db = open_local_db(skynet.getenv('TEST_DATA_DIR')..'/${project_name}_temp.db', datas, "temporary")
381
+ else
382
+ self.temporary_local_db = open_local_db('/dev/shm/persistence.local/${project_name}.db', datas, "temporary")
383
+ end
384
+ % endif
385
+ self.db = open_db(':memory:', datas)
386
+ orm_classes.init(self.db)
387
+ % if root['path_level'] == 2:
388
+ self.bus:request_name(app_base.Service.get_service_name(self.name))
389
+ % endif
390
+ % endif
391
+
392
+ model.init(self.bus)
393
+
394
+ ${ClassName}.bus = self.bus
395
+ end
396
+
397
+ % if root['path_level'] == 2:
398
+ % if utils_py.check_db_open(root['package']):
399
+ function ${ClassName}:pre_init()
400
+ if ${ClassName}.super.pre_init then
401
+ ${ClassName}.super.pre_init(self)
402
+ end
403
+ % if utils_py.check_remote_per(root):
404
+ self.persist = persist_client.new(self.bus, self.db, self, ${render_utils.get_not_recover_tables(root)})
405
+ object_manage.set_persist_client(self.persist)
406
+ % endif
407
+ end
408
+ % endif
409
+ % endif
410
+
411
+ ## servie初始化
412
+ function ${ClassName}:init()
413
+ % if root['path_level'] == 2:
414
+ ${ClassName}.super.init(self)
415
+ %endif
416
+ self:SubscribeAll()
417
+ % for cls, cls_data in root['class_require'].items():## 非动态的对象初始化时就可以上树
418
+ % if not render_utils.is_dynamic_obj(cls_data['path']):
419
+ local object = cls_mng("${cls}").new(${render_utils.make_path(cls_data['path'])})
420
+ object:create_mdb_objects(${render_utils.make_path(cls_data['path'])})
421
+ object.ObjectName = '${cls}_0'
422
+ % if root['path_level'] == 2 and utils_py.check_remote_per(root):
423
+ object:assign_persistence_props(self.persist)
424
+ % endif
425
+ object:register_mdb_objects()
426
+ % endif
427
+ %endfor
428
+
429
+ % for rpc in root['methods']:
430
+ %if not rpc['override'] :
431
+ self:Impl${rpc['name']}(function(obj, ctx, ...)
432
+ return self:Get${rpc['default']}Object():${rpc['func_name']}_PACKED(ctx, obj.path,...):unpack()
433
+ end)
434
+ %endif
435
+ % endfor
436
+
437
+ end
438
+
439
+ return ${ClassName}
440
+ %endif
@@ -0,0 +1,19 @@
1
+ ${make_header('lua')}
2
+
3
+ local org_freedesktop_dbus = require 'sd_bus.org_freedesktop_dbus'
4
+ local app_service = require '${project_name}.service'
5
+ local class = require 'mc.class'
6
+
7
+ -- 继承service
8
+ local sig = class(app_service)
9
+ local MatchRule = org_freedesktop_dbus.MatchRule
10
+
11
+ function sig:SubscriptionSigNotify(cb)
12
+ local slots = {}
13
+ local sig_properties_changed = MatchRule.signal('PropertiesChanged',
14
+ 'org.freedesktop.DBus.Properties')
15
+ slots[#slots + 1] = self.bus:match(sig_properties_changed, cb) -- cb的参数是msg,由组件解析
16
+ self.match_slots = slots
17
+ end
18
+
19
+ return sig
@@ -0,0 +1,41 @@
1
+ <%def name="render(default_path, ClassName, intf_cls, interface)">
2
+ ## 生成默认对象的订阅和访问接口
3
+ ${default_path} = ""
4
+ function ${ClassName}:Subscribe${intf_cls}()
5
+ local org_freedesktop_dbus = require 'sd_bus.org_freedesktop_dbus'
6
+ local MatchRule = org_freedesktop_dbus.MatchRule
7
+ local sig = MatchRule.signal('InterfacesAdded'):with_path_namespace('/bmc')
8
+ self.signal_slots[#self.signal_slots+1] = self:get_bus():match(sig, function(msg)
9
+ local path, interfaces = msg:read()
10
+ if interfaces['${interface}'] then
11
+ ${default_path} = path
12
+ end
13
+ end)
14
+ local mdb_service = require 'mc.mdb.mdb_service'
15
+ local path_list = mdb_service.get_sub_paths(self:get_bus(), "/bmc", 10, {"${interface}"}).SubPaths
16
+ for _, path in pairs(path_list) do
17
+ ${default_path} = path
18
+ end
19
+ end
20
+ table.insert(${ClassName}.subscriptions, 1, ${ClassName}.Subscribe${intf_cls})
21
+
22
+ function ${ClassName}:Get${intf_cls}Object()
23
+ return mdb.get_object(self:get_bus(), ${default_path}, '${interface}')
24
+ end
25
+ </%def>
26
+
27
+ <%def name="add_subs(ClassName)">
28
+ ## 生成默认对象的订阅和访问接口
29
+ ${ClassName}.subscriptions = {}
30
+ function ${ClassName}:SubscribeAll()
31
+ if self.has_subscribe_all then
32
+ return
33
+ end
34
+
35
+ for i = 1, #self.subscriptions do
36
+ self.subscriptions[i](self)
37
+ end
38
+
39
+ self.has_subscribe_all = true
40
+ end
41
+ </%def>
@@ -0,0 +1,10 @@
1
+ <%def name="render(msg, create_enum_type)">---@class ${msg['package']}.${msg['name']}: Enum
2
+ local E${msg['name']} = ${create_enum_type}('${msg['name']}')
3
+ % if 'default' in msg:
4
+ E${msg['name']}.default = E${msg['name']}.new(${msg['default']})
5
+ E${msg['name']}.struct = nil
6
+ % endif
7
+ % for prop in msg['values']:
8
+ E${msg['name']}.${utils_py.enum_value_name(msg['name'], prop['name'])} = E${msg['name']}.new(${("'" + prop['value'] + "'") if type(prop['value']) == str else prop['value']})
9
+ % endfor
10
+ </%def>
@@ -0,0 +1,13 @@
1
+ <%def name="render_import(pkg, path)">local ${pkg} = require "${path.replace('.proto', "").replace("/", ".")}"</%def>
2
+
3
+ <%def name="render(root)">
4
+ % if 'dependency' in root:
5
+ % for (pkg, data) in root['dependency'].items():
6
+ % if "require_path" in data:
7
+ local ${pkg} = require "${data["require_path"]}"
8
+ % else:
9
+ ${render_import(pkg, f"{project_name}.{data['filename']}")}
10
+ % endif
11
+ % endfor
12
+ % endif
13
+ </%def>
@@ -0,0 +1,25 @@
1
+ <%def name="render(intf)">
2
+ mdb.register_interface('${intf['name']}', {
3
+ % if 'properties' in intf['data'] :
4
+ % for p,p_data in intf['data']['properties'].items():
5
+ ${p} = {'${render_utils.do_type_to_dbus_json(intf['data'], p_data)}', ${render_utils.options_json(p_data)}, ${render_utils.readonly_json(p_data)}, ${render_utils.default_json(p_data)}, false},
6
+ % endfor
7
+ % endif
8
+ }, {
9
+ % if 'methods' in intf['data'] :
10
+ % for method, method_data in intf['data']['methods'].items():
11
+ % if version >= 16:
12
+ ${method} = {'a{ss}${render_utils.do_types_to_dbus_json(intf['data'], method_data, 'req')}', '${render_utils.do_types_to_dbus_json(intf['data'], method_data,'rsp')}', T${method}Req, T${method}Rsp${render_utils.get_method_description(intf['name'], method_data)}},
13
+ % else:
14
+ ${method} = {'a{ss}${render_utils.do_types_to_dbus_json(intf['data'], method_data, 'req')}', '${render_utils.do_types_to_dbus_json(intf['data'], method_data,'rsp')}', T${method}Req, T${method}Rsp},
15
+ %endif
16
+ % endfor
17
+ % endif
18
+ }, {
19
+ % if 'signals' in intf['data'] :
20
+ % for s,s_data in intf['data']['signals'].items():
21
+ ${s} = 'a{ss}${render_utils.do_types_to_dbus_json(intf['data'], intf['data']['signals'], s)}',
22
+ % endfor
23
+ % endif
24
+ })
25
+ </%def>
@@ -0,0 +1,23 @@
1
+
2
+
3
+ <%def name="render_sig(class_name, class_data, class_require)">
4
+ % if 'path' in class_data:
5
+ local ${class_name} = mdb.register_object('${render_utils.get_path(class_name, class_require)}', {
6
+ % if 'interfaces' in class_data:
7
+ % for intf in class_data['interfaces']:
8
+ {name = '${intf}', interface = ${utils_py.get_unique_intf_name(intf)}Types.interface},
9
+ % endfor
10
+ % endif
11
+ })
12
+ % endif
13
+ </%def>
14
+
15
+ <%def name="render(class_name, class_data, class_require)">
16
+ ${render_sig(class_name, class_data, class_require)}
17
+
18
+ % if 'path' in class_data:
19
+ function ${class_name}:ctor(${", ".join(render_utils.get_path_params(render_utils.get_path(class_name, class_require)))})
20
+ self.path = ${render_utils.make_path(render_utils.get_path(class_name, class_require))}
21
+ end
22
+ % endif
23
+ </%def>