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.
- bmcgo/__init__.py +12 -0
- bmcgo/bmcgo.py +22 -0
- bmcgo/bmcgo_config.py +176 -0
- bmcgo/cli/__init__.py +10 -0
- bmcgo/cli/cli.py +584 -0
- bmcgo/codegen/__init__.py +14 -0
- bmcgo/codegen/c/__init__.py +9 -0
- bmcgo/codegen/c/annotation.py +52 -0
- bmcgo/codegen/c/argument.py +42 -0
- bmcgo/codegen/c/codegen.py +153 -0
- bmcgo/codegen/c/comment.py +22 -0
- bmcgo/codegen/c/ctype_defination.py +353 -0
- bmcgo/codegen/c/helper.py +87 -0
- bmcgo/codegen/c/interface.py +63 -0
- bmcgo/codegen/c/method.py +82 -0
- bmcgo/codegen/c/property.py +180 -0
- bmcgo/codegen/c/renderer.py +21 -0
- bmcgo/codegen/c/signal.py +64 -0
- bmcgo/codegen/c/template/client.c.mako +145 -0
- bmcgo/codegen/c/template/client.h.mako +36 -0
- bmcgo/codegen/c/template/interface.c.mako +0 -0
- bmcgo/codegen/c/template/interface.introspect.xml.mako +99 -0
- bmcgo/codegen/c/template/micro_component.c.mako +32 -0
- bmcgo/codegen/c/template/public.c.mako +228 -0
- bmcgo/codegen/c/template/public.h.mako +128 -0
- bmcgo/codegen/c/template/server.c.mako +104 -0
- bmcgo/codegen/c/template/server.h.mako +36 -0
- bmcgo/codegen/lua/.lua-format +7 -0
- bmcgo/codegen/lua/Makefile +101 -0
- bmcgo/codegen/lua/__init__.py +9 -0
- bmcgo/codegen/lua/codegen.py +171 -0
- bmcgo/codegen/lua/proto/Makefile +87 -0
- bmcgo/codegen/lua/proto/ipmi_types.proto +17 -0
- bmcgo/codegen/lua/proto/types.proto +52 -0
- bmcgo/codegen/lua/script/check_intfs.py +161 -0
- bmcgo/codegen/lua/script/dto/__init__.py +11 -0
- bmcgo/codegen/lua/script/dto/exception.py +53 -0
- bmcgo/codegen/lua/script/dto/kepler_abstract.py +47 -0
- bmcgo/codegen/lua/script/dto/options.py +33 -0
- bmcgo/codegen/lua/script/dto/print_simple.py +19 -0
- bmcgo/codegen/lua/script/dto/redfish_api.py +241 -0
- bmcgo/codegen/lua/script/dto/url_route.py +195 -0
- bmcgo/codegen/lua/script/gen_db_json.py +444 -0
- bmcgo/codegen/lua/script/gen_depends.py +89 -0
- bmcgo/codegen/lua/script/gen_entry.py +263 -0
- bmcgo/codegen/lua/script/gen_feature_json.py +156 -0
- bmcgo/codegen/lua/script/gen_historical_local_db_json.py +88 -0
- bmcgo/codegen/lua/script/gen_intf_json.py +261 -0
- bmcgo/codegen/lua/script/gen_intf_rpc_json.py +575 -0
- bmcgo/codegen/lua/script/gen_ipmi_json.py +485 -0
- bmcgo/codegen/lua/script/gen_mdb_json.py +117 -0
- bmcgo/codegen/lua/script/gen_rpc_msg_json.py +487 -0
- bmcgo/codegen/lua/script/gen_schema.py +302 -0
- bmcgo/codegen/lua/script/ipmi_types_pb2.py +135 -0
- bmcgo/codegen/lua/script/loader/__init__.py +11 -0
- bmcgo/codegen/lua/script/loader/file_utils.py +33 -0
- bmcgo/codegen/lua/script/loader/kepler_abstract_collect.py +79 -0
- bmcgo/codegen/lua/script/loader/kepler_abstract_loader.py +47 -0
- bmcgo/codegen/lua/script/loader/redfish_loader.py +127 -0
- bmcgo/codegen/lua/script/lua_format.py +62 -0
- bmcgo/codegen/lua/script/mds_util.py +385 -0
- bmcgo/codegen/lua/script/merge_model.py +330 -0
- bmcgo/codegen/lua/script/merge_proto_algo.py +85 -0
- bmcgo/codegen/lua/script/proto_loader.py +47 -0
- bmcgo/codegen/lua/script/proto_plugin.py +140 -0
- bmcgo/codegen/lua/script/redfish_source_tree.py +118 -0
- bmcgo/codegen/lua/script/render_utils/__init__.py +38 -0
- bmcgo/codegen/lua/script/render_utils/base.py +25 -0
- bmcgo/codegen/lua/script/render_utils/client_lua.py +98 -0
- bmcgo/codegen/lua/script/render_utils/controller_lua.py +71 -0
- bmcgo/codegen/lua/script/render_utils/db_lua.py +224 -0
- bmcgo/codegen/lua/script/render_utils/error_lua.py +185 -0
- bmcgo/codegen/lua/script/render_utils/factory.py +52 -0
- bmcgo/codegen/lua/script/render_utils/ipmi_lua.py +159 -0
- bmcgo/codegen/lua/script/render_utils/ipmi_message_lua.py +24 -0
- bmcgo/codegen/lua/script/render_utils/mdb_lua.py +177 -0
- bmcgo/codegen/lua/script/render_utils/mdb_register.py +215 -0
- bmcgo/codegen/lua/script/render_utils/message_lua.py +26 -0
- bmcgo/codegen/lua/script/render_utils/messages_lua.py +156 -0
- bmcgo/codegen/lua/script/render_utils/model_lua.py +485 -0
- bmcgo/codegen/lua/script/render_utils/old_model_lua.py +429 -0
- bmcgo/codegen/lua/script/render_utils/plugin_lua.py +38 -0
- bmcgo/codegen/lua/script/render_utils/redfish_proto.py +86 -0
- bmcgo/codegen/lua/script/render_utils/request_lua.py +76 -0
- bmcgo/codegen/lua/script/render_utils/service_lua.py +130 -0
- bmcgo/codegen/lua/script/render_utils/utils_message_lua.py +125 -0
- bmcgo/codegen/lua/script/render_utils/validate_lua.py +221 -0
- bmcgo/codegen/lua/script/sep_ipmi_message_cmds.py +217 -0
- bmcgo/codegen/lua/script/template.py +166 -0
- bmcgo/codegen/lua/script/types_pb2.py +516 -0
- bmcgo/codegen/lua/script/utils.py +663 -0
- bmcgo/codegen/lua/script/validate.py +80 -0
- bmcgo/codegen/lua/script/yaml_to_json.py +73 -0
- bmcgo/codegen/lua/templates/Makefile +114 -0
- bmcgo/codegen/lua/templates/apps/Makefile +261 -0
- bmcgo/codegen/lua/templates/apps/Makefile.mdb.mk +64 -0
- bmcgo/codegen/lua/templates/apps/app.lua.mako +19 -0
- bmcgo/codegen/lua/templates/apps/class.lua.mako +35 -0
- bmcgo/codegen/lua/templates/apps/client.lua.mako +429 -0
- bmcgo/codegen/lua/templates/apps/controller.lua.mako +276 -0
- bmcgo/codegen/lua/templates/apps/datas.lua.mako +8 -0
- bmcgo/codegen/lua/templates/apps/db.lua.mako +89 -0
- bmcgo/codegen/lua/templates/apps/entry.lua.mako +128 -0
- bmcgo/codegen/lua/templates/apps/feature.lua.mako +37 -0
- bmcgo/codegen/lua/templates/apps/generate_route.mako +25 -0
- bmcgo/codegen/lua/templates/apps/impl_feature.lua.mako +72 -0
- bmcgo/codegen/lua/templates/apps/ipmi.lua.mako +97 -0
- bmcgo/codegen/lua/templates/apps/ipmi_cmd.lua.mako +18 -0
- bmcgo/codegen/lua/templates/apps/ipmi_message.lua.mako +36 -0
- bmcgo/codegen/lua/templates/apps/local_db.lua.mako +263 -0
- bmcgo/codegen/lua/templates/apps/main.lua.mako +25 -0
- bmcgo/codegen/lua/templates/apps/mc.lua.mako +77 -0
- bmcgo/codegen/lua/templates/apps/mdb.lua.mako +45 -0
- bmcgo/codegen/lua/templates/apps/mdb_interface.lua.mako +73 -0
- bmcgo/codegen/lua/templates/apps/message.lua.mako +38 -0
- bmcgo/codegen/lua/templates/apps/model.lua.mako +239 -0
- bmcgo/codegen/lua/templates/apps/orm_classes.lua.mako +16 -0
- bmcgo/codegen/lua/templates/apps/plugin.lua.mako +8 -0
- bmcgo/codegen/lua/templates/apps/redfish.proto.mako +47 -0
- bmcgo/codegen/lua/templates/apps/service.lua.mako +440 -0
- bmcgo/codegen/lua/templates/apps/signal_listen.lua.mako +19 -0
- bmcgo/codegen/lua/templates/apps/utils/default_intf.lua.mako +41 -0
- bmcgo/codegen/lua/templates/apps/utils/enum.mako +10 -0
- bmcgo/codegen/lua/templates/apps/utils/imports.mako +13 -0
- bmcgo/codegen/lua/templates/apps/utils/mdb_intf.lua.mako +25 -0
- bmcgo/codegen/lua/templates/apps/utils/mdb_obj.lua.mako +23 -0
- bmcgo/codegen/lua/templates/apps/utils/message.mako +160 -0
- bmcgo/codegen/lua/templates/apps/utils/request.lua.mako +59 -0
- bmcgo/codegen/lua/templates/apps/utils/validate.mako +83 -0
- bmcgo/codegen/lua/templates/errors.lua.mako +36 -0
- bmcgo/codegen/lua/templates/messages.lua.mako +32 -0
- bmcgo/codegen/lua/templates/new_app/.clang-format.mako +170 -0
- bmcgo/codegen/lua/templates/new_app/.gitignore.mako +26 -0
- bmcgo/codegen/lua/templates/new_app/CHANGELOG.md.mako +0 -0
- bmcgo/codegen/lua/templates/new_app/CMakeLists.txt.mako +29 -0
- bmcgo/codegen/lua/templates/new_app/Makefile.mako +25 -0
- bmcgo/codegen/lua/templates/new_app/README.md.mako +0 -0
- bmcgo/codegen/lua/templates/new_app/conanfile.py.mako +7 -0
- bmcgo/codegen/lua/templates/new_app/config.cfg.mako +6 -0
- bmcgo/codegen/lua/templates/new_app/mds/model.json.mako +3 -0
- bmcgo/codegen/lua/templates/new_app/mds/service.json.mako +21 -0
- bmcgo/codegen/lua/templates/new_app/permissions.ini.mako +16 -0
- bmcgo/codegen/lua/templates/new_app/src/lualib/${project_name}_app.lua.mako +16 -0
- bmcgo/codegen/lua/templates/new_app/src/service/main.lua.mako +25 -0
- bmcgo/codegen/lua/templates/new_app/test/integration/test_${project_name}.conf.mako +9 -0
- bmcgo/codegen/lua/templates/new_app/test/integration/test_${project_name}.lua.mako +47 -0
- bmcgo/codegen/lua/templates/new_app/test/unit/test.lua.mako +23 -0
- bmcgo/codegen/lua/templates/new_app/user_conf/rootfs/etc/systemd/system/${project_name}.service.mako +18 -0
- bmcgo/codegen/lua/templates/new_app/user_conf/rootfs/etc/systemd/system/multi-user.target.wants/${project_name}.service.link +1 -0
- bmcgo/component/__init__.py +10 -0
- bmcgo/component/analysis/analysis.py +183 -0
- bmcgo/component/analysis/build_deps.py +165 -0
- bmcgo/component/analysis/data_deps.py +333 -0
- bmcgo/component/analysis/dep-rules.json +912 -0
- bmcgo/component/analysis/dep_node.py +110 -0
- bmcgo/component/analysis/intf_deps.py +163 -0
- bmcgo/component/analysis/intf_validation.py +254 -0
- bmcgo/component/analysis/rule.py +211 -0
- bmcgo/component/analysis/smc_dfx_whitelist.json +11 -0
- bmcgo/component/analysis/sr_validation.py +391 -0
- bmcgo/component/build.py +222 -0
- bmcgo/component/component_dt_version_parse.py +348 -0
- bmcgo/component/component_helper.py +114 -0
- bmcgo/component/coverage/__init__.py +11 -0
- bmcgo/component/coverage/c_incremental_cov_report.template +53 -0
- bmcgo/component/coverage/incremental_cov.py +464 -0
- bmcgo/component/deploy.py +110 -0
- bmcgo/component/gen.py +169 -0
- bmcgo/component/package_info.py +236 -0
- bmcgo/component/template/conanbase.py.mako +278 -0
- bmcgo/component/template/conanfile.deploy.py.mako +40 -0
- bmcgo/component/test.py +947 -0
- bmcgo/errors.py +119 -0
- bmcgo/frame.py +217 -0
- bmcgo/functional/__init__.py +10 -0
- bmcgo/functional/analysis.py +96 -0
- bmcgo/functional/bmc_studio_action.py +98 -0
- bmcgo/functional/check.py +185 -0
- bmcgo/functional/conan_index_build.py +251 -0
- bmcgo/functional/config.py +332 -0
- bmcgo/functional/csr_build.py +724 -0
- bmcgo/functional/deploy.py +263 -0
- bmcgo/functional/diff.py +235 -0
- bmcgo/functional/fetch.py +235 -0
- bmcgo/functional/full_component.py +391 -0
- bmcgo/functional/maintain.py +381 -0
- bmcgo/functional/new.py +166 -0
- bmcgo/functional/schema_valid.py +111 -0
- bmcgo/functional/simple_sign.py +104 -0
- bmcgo/functional/upgrade.py +78 -0
- bmcgo/ipmigen/__init__.py +13 -0
- bmcgo/ipmigen/ctype_defination.py +82 -0
- bmcgo/ipmigen/ipmigen.py +309 -0
- bmcgo/ipmigen/template/cmd.c.mako +366 -0
- bmcgo/ipmigen/template/ipmi.c.mako +25 -0
- bmcgo/ipmigen/template/ipmi.h.mako +51 -0
- bmcgo/logger.py +176 -0
- bmcgo/misc.py +117 -0
- bmcgo/target/app.yml +17 -0
- bmcgo/target/install_sdk.yml +15 -0
- bmcgo/target/personal.yml +53 -0
- bmcgo/target/publish.yml +45 -0
- bmcgo/tasks/__init__.py +11 -0
- bmcgo/tasks/download_buildtools_hm.py +124 -0
- bmcgo/tasks/misc.py +15 -0
- bmcgo/tasks/task.py +354 -0
- bmcgo/tasks/task_build_conan.py +714 -0
- bmcgo/tasks/task_build_rootfs_img.py +595 -0
- bmcgo/tasks/task_buildgppbin.py +88 -0
- bmcgo/tasks/task_buildhpm_ext4.py +82 -0
- bmcgo/tasks/task_create_interface_config.py +122 -0
- bmcgo/tasks/task_download_buildtools.py +99 -0
- bmcgo/tasks/task_download_dependency.py +72 -0
- bmcgo/tasks/task_hpm_envir_prepare.py +112 -0
- bmcgo/tasks/task_packet_to_supporte.py +87 -0
- bmcgo/tasks/task_prepare.py +105 -0
- bmcgo/tasks/task_sign_and_pack_hpm.py +42 -0
- bmcgo/utils/__init__.py +10 -0
- bmcgo/utils/buffer.py +128 -0
- bmcgo/utils/combine_json_schemas.py +170 -0
- bmcgo/utils/component_post.py +54 -0
- bmcgo/utils/component_version_check.py +86 -0
- bmcgo/utils/config.py +1067 -0
- bmcgo/utils/fetch_component_code.py +232 -0
- bmcgo/utils/install_manager.py +61 -0
- bmcgo/utils/installations/__init__.py +10 -0
- bmcgo/utils/installations/base_installer.py +70 -0
- bmcgo/utils/installations/install_consts.py +30 -0
- bmcgo/utils/installations/install_plans/bingo.yml +11 -0
- bmcgo/utils/installations/install_workflow.py +50 -0
- bmcgo/utils/installations/installers/apt_installer.py +177 -0
- bmcgo/utils/installations/installers/pip_installer.py +46 -0
- bmcgo/utils/installations/version_util.py +100 -0
- bmcgo/utils/mapping_config_patch.py +443 -0
- bmcgo/utils/perf_analysis.py +114 -0
- bmcgo/utils/tools.py +704 -0
- bmcgo/worker.py +417 -0
- openubmc_bingo-0.5.240.dist-info/METADATA +30 -0
- openubmc_bingo-0.5.240.dist-info/RECORD +242 -0
- openubmc_bingo-0.5.240.dist-info/WHEEL +5 -0
- openubmc_bingo-0.5.240.dist-info/entry_points.txt +2 -0
- 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,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
|