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,276 @@
1
+ ${make_header('lua')}
2
+ <%
3
+ methods = ['get', 'post', 'patch', 'delete']
4
+ package_name = root['package'] != 'Root'
5
+ controllers = [msg for msg in root['data'] if "url" in msg["options"]]
6
+ messages = [msg for msg in root['data'] if "url" not in msg["options"] and msg['type'] != 'Enum']
7
+ enums = [msg for msg in root['data'] if msg['type'] == 'Enum']
8
+ %>
9
+ local Controller = require 'http.controller'
10
+ % if package_name:
11
+ local validate = require 'mc.validate'
12
+ local error = require 'mc.error'
13
+ local http = require 'http'
14
+ local safe_call = error.safe_call
15
+ local reply_bad_request = http.reply_bad_request
16
+ local utils = require 'mc.utils'
17
+ % endif
18
+ % if project_name == 'redfish':
19
+ local redfish_utils = require 'redfish_utils'
20
+ % endif
21
+ % if len(enums) > 0:
22
+ local create_enum_type = require 'mc.enum'
23
+ % endif
24
+ <%namespace name="message" file="utils/message.mako"/>
25
+ <%namespace name="validate" file="utils/validate.mako"/>
26
+ <%namespace name="enum" file="utils/enum.mako"/>
27
+ <%namespace name="imports" file="utils/imports.mako"/>
28
+ ${imports.render(root)}
29
+ local ${root['package']} = {}
30
+
31
+ <%def name="get_auth(method, controller, req)">
32
+ local reply = self:auth(ctx)
33
+ if not reply:isOk() then
34
+ return reply
35
+ end
36
+ </%def>
37
+
38
+ <%def name="try_render_patch_methods(method, controller, body)">
39
+ % if body and method == 'patch':
40
+ ${message.group(utils_py.make_get_message(body['type']),controller)}
41
+ % endif
42
+ </%def>
43
+ <%def name="http_patch(method, controller, req)">
44
+ local errs = {}
45
+ local body = ${render_utils.get_body(req)['type']}.from_obj(validate.Json(ctx.req.body)):validate('', errs)
46
+ ${render_utils.get_body(req)['type']}:remove_error_props(errs, body)
47
+ local result = {}
48
+ if next(errs) then
49
+ result = http.reply(http.HTTP_BAD_REQUEST, {error = errs})
50
+ else
51
+ result = http.reply_ok()
52
+ end
53
+ ${message.join_group(utils_py.make_get_message(render_utils.get_body(req)['type']))}
54
+ local req = {user = ctx.user, params = ctx.req.params, path = ctx.req.path, body = body, result = result}
55
+ </%def>
56
+ <%def name="http_post(method, controller, req)">
57
+ % if render_utils.get_body(req):
58
+ local err, body = safe_call(function()
59
+ return ${render_utils.get_body(req)['type']}.from_obj(validate.Json(ctx.req.body)):validate()
60
+ end)
61
+ if err then
62
+ return reply_bad_request(err.name, err.message)
63
+ end
64
+ % if render_utils.get_header(req) and project_name == 'web_backend':
65
+ local req = {user = ctx.user, params = ctx.req.params, path = ctx.req.path, body = body, header = header}
66
+ % else:
67
+ local req = {user = ctx.user, params = ctx.req.params, path = ctx.req.path, body = body}
68
+ % endif
69
+ % endif
70
+ % if render_utils.get_formdata_body(req):
71
+ ${http_formdata_post(method, controller, req)}
72
+ % endif
73
+ </%def>
74
+ <%def name="http_formdata_post(method, controller, req)">
75
+ local req_body
76
+ local form_data = require 'http.form_data'
77
+ local form_data_flag, boundary = form_data.is_form_data_req(ctx.req.header)
78
+ if form_data_flag then
79
+ req_body = form_data.decode_form_data(ctx.req.body, boundary)
80
+ else
81
+ req_body = ctx.req.body
82
+ end
83
+ local req = {user = ctx.user, params = ctx.req.params, path = ctx.req.path, body = req_body}
84
+ </%def>
85
+ <%def name="http_delete(method, controller, req)">
86
+ % if render_utils.get_body(req):
87
+ local err, body = safe_call(function()
88
+ return ${render_utils.get_body(req)['type']}.from_obj(validate.Json(ctx.req.body)):validate()
89
+ end)
90
+ if err then
91
+ return reply_bad_request(err.name, err.message)
92
+ end
93
+ local req = {user = ctx.user, params = ctx.req.params, path = ctx.req.path, body = body}
94
+ % else:
95
+ local req = {user = ctx.user, params = ctx.req.params, path = ctx.req.path}
96
+ % endif
97
+ </%def>
98
+ <%def name="render_http_method(method, controller, req)">
99
+ ${try_render_patch_methods(method, controller, render_utils.get_body(req))}
100
+ function C${controller['name']}:${method}(ctx)
101
+ % if 'auth' in controller["options"]:
102
+ ${get_auth(method, controller, req)}
103
+ % endif
104
+ % if render_utils.get_header(req) and project_name == 'redfish':
105
+ local err_header_check = safe_call(function()
106
+ return ${render_utils.get_header(req)['type']}.from_obj(ctx.req.header):validate()
107
+ end)
108
+ if err_header_check and not validate.IsUnknowPropertyErr(err_header_check) then
109
+ return reply_bad_request(err_header_check.name, err_header_check.message)
110
+ end
111
+ % endif
112
+ % if render_utils.get_header(req) and project_name == 'web_backend':
113
+ local header_errs = {}
114
+ local webrest_utils = require 'webrest_utils'
115
+ local header = ${render_utils.get_header(req)['type']}.from_obj(ctx.req.header)
116
+ webrest_utils.remove_unknow_property(header, header.proto_property)
117
+ header:validate('', header_errs)
118
+ if next(header_errs) then
119
+ return webrest_utils.parse_req_result(http.reply(http.HTTP_BAD_REQUEST, {error = header_errs}))
120
+ end
121
+ % endif
122
+ % if method != 'get' and project_name == 'web_backend':
123
+ % if 'system_lockdown' not in req["options"] or req["options"]['system_lockdown'] != 'allow':
124
+ local webrest_utils = require 'webrest_utils'
125
+ if ctx.unit_test ~= true and webrest_utils.get_system_lockdown_state() == true then
126
+ return reply_bad_request('SystemLockdownForbid')
127
+ end
128
+ % endif
129
+ % endif
130
+ % if method == 'post':
131
+ ${http_post(method, controller, req)}
132
+ % endif
133
+ % if method == 'delete':
134
+ ${http_delete(method, controller, req)}
135
+ % endif
136
+ % if render_utils.get_body(req) and method == 'patch':
137
+ ${http_patch(method, controller, req)}
138
+ % endif
139
+ % if method == "get" and render_utils.get_header(req) and not 'auth' in controller["options"]:
140
+ local req = {user = {UserName = '<su>'}, params = ctx.req.params, path = ctx.req.path, header = header}
141
+ % elif method == "get" and render_utils.get_header(req):
142
+ local req = {user = ctx.user, params = ctx.req.params, path = ctx.req.path, header = header}
143
+ % elif method == "get" and not 'auth' in controller["options"]:
144
+ local req = {user = {UserName = '<su>'}, params = ctx.req.params, path = ctx.req.path}
145
+ % elif method == "get":
146
+ local req = {user = ctx.user, params = ctx.req.params, path = ctx.req.path}
147
+ % endif
148
+ % if project_name == 'redfish' or method == "get" and 'query' in controller["options"]:
149
+ local query = require 'http.query'
150
+ req.query = query.parse_query(ctx.req.query)
151
+ % endif
152
+ % if render_utils.get_response(req):
153
+ local rsp_body = ${render_utils.get_response(req)['type']}.new()
154
+ % else:
155
+ local rsp_body = {}
156
+ % endif
157
+ local rsp_header = {}
158
+ local rsp = {body = rsp_body, header = rsp_header}
159
+ % if method == "patch" and project_name == 'redfish':
160
+ local get_req = {path = ctx.req.path}
161
+ local get_rsp = {header = {}}
162
+ local reply = self:process_get(get_req, get_rsp)
163
+ if reply:isOk() == false then
164
+ return reply
165
+ end
166
+
167
+ if ctx.req.header['if-match'] == nil or ctx.req.header['if-match'] ~= reply:headers()['ETag'] then
168
+ return http.reply(http.HTTP_PRECONDITION_FAILED, '', reply:headers())
169
+ end
170
+
171
+ % endif
172
+ % if method == "get" and project_name == 'redfish':
173
+ local reply = self:process_get(req, rsp)
174
+ if redfish_utils.is_need_reply_modified(ctx.req.header or {}, rsp.header) == true then
175
+ return http.reply(http.HTTP_NOT_MODIFIED, '', reply:headers())
176
+ end
177
+
178
+ return reply
179
+ % else:
180
+ return self:process_${method}(req, rsp)
181
+ % endif
182
+ end
183
+
184
+ % if project_name == 'web_backend':
185
+ function C${controller['name']}:on_${method}(req, rsp)
186
+ local err
187
+ % if method == 'post':
188
+ local task_info
189
+ err, rsp.body, _, task_info = self.worker_ctrl:process(req.path, '${method}', {body = req.body, query = req.query, user = req.user})
190
+ % else:
191
+ err, rsp.body = self.worker_ctrl:process(req.path, '${method}', {body = req.body, query = req.query, user = req.user})
192
+ % endif
193
+ if err and #err ~= 0 then
194
+ local webrest_utils = require 'webrest_utils'
195
+ return webrest_utils.parse_route_mapper_error(err)
196
+ end
197
+ % if method == 'patch':
198
+ _, rsp.body = self.worker_ctrl:process(req.path, 'get', {body = req.body, query = req.query, user = req.user})
199
+ % endif
200
+ % if method == 'post':
201
+ if task_info then
202
+ rsp.task = true
203
+ local task_mgnt = require 'task_mgnt'
204
+ task_mgnt.get_instance():create_new_task(self.app.bus, task_info.Path, task_info.TaskId)
205
+ end
206
+ % endif
207
+ end
208
+ % endif
209
+ % if project_name == 'redfish':
210
+ function C${controller['name']}:on_${method}(req, rsp)
211
+ % if method == 'get':
212
+ local err
213
+ err, rsp.body = redfish_utils.get_rsp_body(self, req)
214
+ % else:
215
+ local err, extra_info
216
+ err, rsp.body, extra_info = self.worker_ctrl:process(req.path, '${method}', {body = req.body, query = req.query, user = req.user})
217
+ % endif
218
+ % if method == 'post' or method == 'delete' or method == 'get':
219
+ if err and #err ~= 0 then
220
+ return redfish_utils.parse_route_mapper_error(err)
221
+ end
222
+ % endif
223
+ % if method == 'patch':
224
+ if err and #err ~= 0 then
225
+ local result = redfish_utils.parse_route_mapper_error(err, '${method}', req.body, extra_info and extra_info.SuccessfulExecute)
226
+ if result:isOk() then
227
+ local extend_info = result:body()['error']['@Message.ExtendedInfo']
228
+ _, rsp.body = redfish_utils.get_rsp_body(self, req)
229
+ rsp.body['@Message.ExtendedInfo'] = extend_info
230
+ return
231
+ end
232
+ return result
233
+ end
234
+ _, rsp.body = redfish_utils.get_rsp_body(self, req)
235
+ % endif
236
+ % if method == 'post' or method == 'delete':
237
+ if extra_info and extra_info.TaskInfo then
238
+ rsp.task = true
239
+ local task_mgnt = require 'redfish.protocol.task_mgnt'
240
+ task_mgnt.get_instance():create_new_task(self.app.bus, extra_info.TaskInfo.Path, extra_info.TaskInfo.TaskId)
241
+ end
242
+ % endif
243
+ end
244
+ % endif
245
+ </%def>
246
+
247
+ <%def name="render_controller(msg)">
248
+ local C${msg['name']} = Controller.new('${msg["options"]['url']}')
249
+ %if 'require_auth' in msg["options"]:
250
+ local auth = '${msg["options"]['require_auth']}'
251
+ % endif
252
+ % for p in msg['properties']:
253
+ C${msg['name']}:add_child(${p['type']})
254
+ %endfor
255
+
256
+ % for method, method_prop in render_utils.get_controller_methods(msg).items():
257
+ ${render_http_method(method, msg, method_prop)}
258
+ % endfor
259
+
260
+ ${root['package']}.${msg['name']} = C${msg['name']}
261
+ </%def>
262
+ % for msg in enums:
263
+ ${enum.render(msg, 'create_enum_type')}
264
+ ${root['package']}.${msg['name']} = E${msg['name']}
265
+ % endfor
266
+
267
+ % for msg in messages:
268
+ ${message.render(msg)}
269
+ ${root['package']}.${msg['name']} = T${msg['name']}
270
+ % endfor
271
+
272
+ % for msg in controllers:
273
+ ${render_controller(msg)}
274
+ % endfor
275
+
276
+ return ${root['package']}
@@ -0,0 +1,8 @@
1
+ ${make_header('lua')}
2
+ local M = {}
3
+
4
+ % for name, rows in root.items():
5
+ M.${name} = ${utils_py.format_value(rows, '')}
6
+ % endfor
7
+
8
+ return M
@@ -0,0 +1,89 @@
1
+ ${make_header('lua')}
2
+ local Databases = require 'database'
3
+ local Col = require 'database.column'
4
+ <%namespace name="imports" file="utils/imports.mako"/>
5
+ ${imports.render(root)}
6
+ <%
7
+ ClassName = root['package'] + 'Database'
8
+ %>
9
+
10
+ % for msg in root['data']:
11
+ % if render_utils.table_name(msg):
12
+ ---@class ${msg['name']}Table: Table
13
+ % for prop in msg['properties']:
14
+ ---@field ${prop['name']} FieldBase
15
+ % endfor
16
+ % endif
17
+
18
+ % endfor
19
+
20
+ ---@class ${ClassName}
21
+ ---@field db DataBase
22
+ ---@field select fun(db:DataBase, table: any, ...): SelectStatement
23
+ ---@field update fun(db:DataBase, table: any, ...): UpdateStatement
24
+ ---@field insert fun(db:DataBase, table: any, ...): InsertStatement
25
+ % for msg in root['data']:
26
+ % if render_utils.table_name(msg):
27
+ ---@field ${msg['name']} ${msg['name']}Table
28
+ % endif
29
+ % endfor
30
+ local ${ClassName} = {}
31
+ ${ClassName}.__index = ${ClassName}
32
+
33
+ function ${ClassName}.new(path, datas)
34
+ local db = Databases(path)
35
+ local obj = {db = db}
36
+
37
+ % for msg in root['data']:
38
+ % if render_utils.table_name(msg):
39
+ obj.${msg['name']} = db:Table('${render_utils.table_name(msg)}', {
40
+ % for prop in msg['properties']:
41
+ ${prop['name']} = Col.${render_utils.column_type(prop)}:cid(${prop['id']})${render_utils.primary_key(prop)}${render_utils.persistence_key(prop)}${render_utils.unique(prop)}${render_utils.allow_null(prop)}${render_utils.max_len(prop)}${render_utils.default(msg['name'], prop)}${render_utils.critical(prop)},
42
+ % endfor
43
+ % if render_utils.all_persistence(msg) != 'nil':
44
+ }, "${render_utils.all_persistence(msg)}"):create_if_not_exist(datas and datas['${render_utils.table_name(msg)}'])
45
+ % else:
46
+ }):create_if_not_exist(datas and datas['${render_utils.table_name(msg)}'])
47
+ % endif
48
+ % if render_utils.table_max_rows(msg) and render_utils.get_lua_codegen_version() >= 11:
49
+ obj.${msg['name']}.table_max_rows = ${msg['options']['table_max_rows']}
50
+ %endif
51
+ % endif
52
+ % endfor
53
+
54
+ obj.tables = db.tables
55
+ return setmetatable(obj, ${ClassName})
56
+ end
57
+
58
+ function ${ClassName}:select(table, ...)
59
+ return self.db:select(table, ...)
60
+ end
61
+
62
+ function ${ClassName}:update(table, ...)
63
+ return self.db:update(table, ...)
64
+ end
65
+
66
+ function ${ClassName}:insert(table, ...)
67
+ return self.db:insert(table, ...)
68
+ end
69
+
70
+ function ${ClassName}:delete(table, ...)
71
+ return self.db:delete(table, ...)
72
+ end
73
+
74
+ function ${ClassName}:exec(...)
75
+ return self.db:exec(...)
76
+ end
77
+
78
+ % for msg in root['data']:
79
+ % if render_utils.table_name(msg):
80
+ % if render_utils.table_max_rows(msg) and render_utils.get_lua_codegen_version() >= 11:
81
+
82
+ function ${ClassName}:Register${msg['name']}TableMaxRowsCallback(cb)
83
+ self.${msg['name']}.table_max_rows_cb = cb
84
+ end
85
+ % endif
86
+ % endif
87
+ % endfor
88
+
89
+ return ${ClassName}.new
@@ -0,0 +1,128 @@
1
+ ${make_header('lua')}
2
+
3
+ require 'app'
4
+ require 'callbacks/mc'
5
+ % if ipmi:
6
+ require 'callbacks/ipmi_cmd'
7
+ % endif
8
+ % for class_name in model:
9
+ require 'callbacks/classes/${class_name.lower()}'
10
+ % endfor
11
+ local utils_core = require 'utils.core'
12
+ local class = require 'mc.class'
13
+ local mc_admin = require 'mc.mc_admin'
14
+ local object_manage = require 'mc.mdb.object_manage'
15
+ local debug_manage = require 'mc.mdb.micro_component.debug'
16
+ local reboot_manage = require 'mc.mdb.micro_component.reboot'
17
+ % if ipmi:
18
+ local ipmi = require '${project_name}.ipmi.ipmi'
19
+ % endif
20
+ local factory = require '${project_name}.factory'
21
+ local app_service = require '${project_name}.service'
22
+
23
+ -- 继承service
24
+ local AppEntry = class(app_service)
25
+
26
+ function AppEntry:ctor()
27
+ end
28
+
29
+ function AppEntry:init()
30
+ -- 1.注册回调
31
+ -- 1) libmc公共接口实现
32
+ -- 2) mds方法接口
33
+ -- 3) ipmi回调
34
+ -- 4) 属性信号监听回调
35
+ self:ObjectMgmtCallbackRegister()
36
+ self:ConfigMgmtCallbackRegister()
37
+ self:RecoveryCallbackRegister()
38
+ self:RebootCallbackRegister()
39
+ self:DebugCallbackRegister()
40
+
41
+ self:IpmiRegister()
42
+ self:MethodRegister()
43
+
44
+ -- 2.资源上树
45
+ -- 在基类service中init将单例的资源上树
46
+ self.super.init(self)
47
+
48
+ -- 3.依赖检查
49
+ self:check_dependencies()
50
+
51
+ -- 4.用户初始化
52
+ -- 调用用户代码初始化
53
+ self:user_init()
54
+ end
55
+
56
+ function AppEntry:IpmiRegister()
57
+ % if ipmi:
58
+ % for ipmi_method in ipmi.get('cmds', []):
59
+ self:register_ipmi_cmd(ipmi.${ipmi_method}, factory.get_obj_cb('ipmi_cmd', '${ipmi_method}'))
60
+ % endfor
61
+ % endif
62
+ end
63
+
64
+ function AppEntry:MethodRegister()
65
+ % if model:
66
+ % for class_name in model:
67
+ % for interface in model[class_name].get('interfaces', []):
68
+ % for method in model[class_name]['interfaces'][interface].get('methods', []):
69
+ <% interface_name = interface.split('.')[-1] %>
70
+ % if interface_name == 'Default':
71
+ <% pre_intf_name = interface.split('.')[-2] %>
72
+ self:Impl${class_name}${pre_intf_name}${interface_name}${method}(factory.get_obj_cb('${class_name}', '${class_name}${pre_intf_name}${interface_name}${method}'))
73
+ % else:
74
+ <% unique_intf_name = render_utils.get_unique_intf_name(interface) %>
75
+ self:Impl${class_name}${unique_intf_name}${method}(factory.get_obj_cb('${class_name}', '${class_name}${interface_name}${method}'))
76
+ %endif
77
+ % endfor
78
+ % endfor
79
+ % endfor
80
+ % endif
81
+ end
82
+
83
+ function AppEntry:ObjectMgmtCallbackRegister()
84
+ object_manage.on_add_object(self.bus, function (class_name, object, position)
85
+ return factory.get_obj_cb(class_name, 'on_add_object')(class_name, object, position)
86
+ end)
87
+ object_manage.on_delete_object(self.bus, function (class_name, object, position)
88
+ return factory.get_obj_cb(class_name, 'on_del_object')(class_name, object, position)
89
+ end)
90
+ object_manage.on_add_object_complete(self.bus, function (position)
91
+ return factory.get_obj_cb('mc_callback', 'on_add_object_complete')(position)
92
+ end)
93
+ object_manage.on_delete_object_complete(self.bus, function (position)
94
+ return factory.get_obj_cb('mc_callback', 'on_delete_object_complete')(position)
95
+ end)
96
+ end
97
+
98
+ function AppEntry:ConfigMgmtCallbackRegister()
99
+ end
100
+
101
+ function AppEntry:RecoveryCallbackRegister()
102
+ end
103
+
104
+ function AppEntry:RebootCallbackRegister()
105
+ reboot_manage.on_prepare(factory.get_obj_cb('mc_callback', 'on_reboot_prepare'))
106
+ reboot_manage.on_action(factory.get_obj_cb('mc_callback', 'on_reboot_action'))
107
+ reboot_manage.on_cancel(factory.get_obj_cb('mc_callback', 'on_reboot_cancel'))
108
+ end
109
+
110
+ function AppEntry:DebugCallbackRegister()
111
+ debug_manage.on_dump(self.bus, factory.get_obj_cb('mc_callback', 'on_debug_dump'))
112
+ end
113
+
114
+ -- 依赖检查
115
+ function AppEntry:check_dependencies()
116
+ local admin = mc_admin.new()
117
+ admin:parse_dependency(utils_core.getcwd() .. '/mds/service.json')
118
+ admin:check_dependency(self.bus)
119
+ end
120
+
121
+ -- 调用用户初始化
122
+ function AppEntry:user_init()
123
+ factory.get_obj_cb('app', 'init')(self)
124
+
125
+ factory.get_obj_cb('app', 'start')()
126
+ end
127
+
128
+ return AppEntry
@@ -0,0 +1,37 @@
1
+ ${make_header('lua')}
2
+ local class = require 'mc.class'
3
+ local singleton = require 'mc.singleton'
4
+ local feature = require 'mc.plugin.feature'
5
+
6
+ local ${root['feature']} = class(feature)
7
+
8
+ function ${root['feature']}:ctor()
9
+
10
+ end
11
+
12
+ % for class_name, class_data in root.get('public', {}).items():
13
+ % for intf_name, methods in class_data.items():
14
+ % for method in methods:
15
+ function ${root['feature']}:${class_name}${intf_name}${method}(...)
16
+ return self:call('${class_name}${intf_name}${method}', ...)
17
+ end
18
+
19
+ function ${root['feature']}:Impl${class_name}${intf_name}${method}(preprocess_cb, process_cb, postprocess_cb)
20
+ self:implement('${class_name}${intf_name}${method}', preprocess_cb, process_cb, postprocess_cb)
21
+ end
22
+
23
+ % endfor
24
+ % endfor
25
+ % endfor
26
+ % for method in root.get('private', []):
27
+ function ${root['feature']}:${method}(...)
28
+ return self:call('${method}', ...)
29
+ end
30
+
31
+ function ${root['feature']}:Impl${method}(preprocess_cb, process_cb, postprocess_cb)
32
+ self:implement('${method}', preprocess_cb, process_cb, postprocess_cb)
33
+ end
34
+
35
+ % endfor
36
+ return singleton(${root['feature']})
37
+
@@ -0,0 +1,25 @@
1
+ syntax = "proto3";
2
+ import "types.proto";
3
+ import "apps/redfish/resource/schema/${filename}.proto";
4
+ import "apps/redfish/types/header.proto";
5
+ package ${filename}_${i};
6
+
7
+ message Route {
8
+ option (url) = "/redfish/v1/${url}";
9
+ option (auth) = true;
10
+ message Get {
11
+ ${filename}.${filename} Response = 1;
12
+ }
13
+ message Post {
14
+ option (auth) = true;
15
+ Header.RequestHeader header = 1;
16
+ ${filename}.${filename} Body = 2;
17
+ ${filename}.${filename} Response = 3;
18
+ }
19
+ message Patch {
20
+ option (auth) = true;
21
+ Header.RequestHeader header = 1;
22
+ ${filename}.${filename} Body = 2;
23
+ ${filename}.${filename} Response = 3;
24
+ }
25
+ }
@@ -0,0 +1,72 @@
1
+ ${make_header('lua')}
2
+ local ${root['feature']} = require '${project_name}.features.${root['feature']}'.get_instance()
3
+
4
+ % for class_name, class_data in root.get('public', {}).items():
5
+ % for intf_name, methods in class_data.items():
6
+ % for method in methods:
7
+ -- 实现资源树方法的插件预处理方法
8
+ ---@param obj Object
9
+ ---@param ctx Context
10
+ ---@param ... 资源树方法的入参
11
+ ---@return Object 返回插件处理方法的入参,支持对插件预处理方法的入参做一些处理后传入插件处理方法
12
+ ---@return Context 返回插件处理方法的入参,支持对插件预处理方法的入参做一些处理后传入插件处理方法
13
+ ---@return ... 返回插件处理方法的入参,支持对插件预处理方法的入参做一些处理后传入插件处理方法
14
+ local function ${class_name}${intf_name}${method}Preprocess(obj, ctx, ...)
15
+
16
+ return obj, ctx, ...
17
+ end
18
+
19
+ -- 实现资源树方法的插件处理方法
20
+ ---@param obj Object
21
+ ---@param ctx Context
22
+ ---@param ... 资源树方法的入参
23
+ ---@return response 资源树方法的出参,作为插件后置处理方法的入参传入插件后置处理方法
24
+ local function ${class_name}${intf_name}${method}Process(obj, ctx, ...)
25
+
26
+ end
27
+
28
+ -- 实现资源树方法的插件后置处理方法
29
+ ---@param ... 1、如果实现了插件处理方法,则使用插件处理方法的出参 2、未实现插件处理方法时,使用资源树方法默认实现的出参
30
+ ---@return ... 资源树方法的出参
31
+ local function ${class_name}${intf_name}${method}Postprocess(...)
32
+
33
+ return ...
34
+ end
35
+
36
+ -- 入参分别为插件预处理、插件处理、插件后置处理方法的回调,实现相关回调后请将方法名填入,nil表示不进行相应处理
37
+ -- e.g. ${root['feature']}:Impl${class_name}${intf_name}${method}(${class_name}${intf_name}${method}Preprocess, ${class_name}${intf_name}${method}Process, ${class_name}${intf_name}${method}Postprocess)
38
+ ${root['feature']}:Impl${class_name}${intf_name}${method}(nil, nil, nil)
39
+
40
+ % endfor
41
+ % endfor
42
+ % endfor
43
+
44
+ % for method in root.get('private', []):
45
+ -- 实现私有方法的插件预处理方法
46
+ ---@param ... 私有方法的入参
47
+ ---@return ... 返回插件处理方法的入参,支持对插件预处理方法的入参做一些处理后传入插件处理方法
48
+ local function ${method}Preprocess(...)
49
+
50
+ return ...
51
+ end
52
+
53
+ -- 实现私有方法的插件处理方法
54
+ ---@param ... 私有方法的入参
55
+ ---@return response 私有方法的出参,作为插件后置处理方法的入参传入插件后置处理方法
56
+ local function ${method}Process(...)
57
+
58
+ end
59
+
60
+ -- 实现私有方法的插件后置处理方法
61
+ ---@param ... 1、如果实现了插件处理方法,则使用插件处理方法的出参 2、未实现插件处理方法时,使用私有方法默认实现的出参
62
+ ---@return ... 私有方法的出参
63
+ local function ${method}Postprocess(...)
64
+
65
+ return ...
66
+ end
67
+
68
+ -- 入参分别为插件预处理、插件处理、插件后置处理方法的回调,实现相关回调后请将方法名填入,nil表示不进行相应处理
69
+ -- e.g. ${root['feature']}:Impl${method}(${method}Preprocess, ${method}Process, ${method}Postprocess)
70
+ ${root['feature']}:Impl${method}(nil, nil, nil)
71
+
72
+ % endfor