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,429 @@
|
|
|
1
|
+
## 生成所有rpc接口
|
|
2
|
+
<%def name="get_obj(rpc)">
|
|
3
|
+
% if rpc['path'] != '*': ## 非虚方法和收集类方法,直接远程调用
|
|
4
|
+
% if version >= 17 and 'paths' in rpc and not rpc['virtual']:
|
|
5
|
+
%if not rpc['retry']:
|
|
6
|
+
mdb.get_object(self:get_bus(), ${render_utils.make_path_with_params(rpc['full_path'])}, '${rpc['interface']}')
|
|
7
|
+
%else:
|
|
8
|
+
mdb.try_get_object(self:get_bus(), ${render_utils.get_object_path(rpc['full_path'])}, '${rpc['interface']}')
|
|
9
|
+
%endif
|
|
10
|
+
% else:
|
|
11
|
+
self:Get${rpc['class']}${rpc['intf_class']}Object(${render_utils.get_path_arg(rpc["full_path"], False)})
|
|
12
|
+
% endif
|
|
13
|
+
% elif not rpc['virtual']:
|
|
14
|
+
mdb.get_object(self:get_bus(), ${render_utils.make_path_with_params(rpc['full_path'])}, "${rpc['interface']}")
|
|
15
|
+
% else :
|
|
16
|
+
self:Get${rpc['intf_class']}Object()
|
|
17
|
+
% endif
|
|
18
|
+
</%def>
|
|
19
|
+
% if version >= 4:
|
|
20
|
+
${make_header('lua')}
|
|
21
|
+
<% has_signal = root['signals']%>
|
|
22
|
+
<% has_interface = root['interfaces']%>
|
|
23
|
+
<% has_definite_path = any((rpc['path'] != '*') for rpc in root['interfaces'])%>
|
|
24
|
+
<% has_virtual = any((rpc['path'] == '*' and rpc['virtual']) for rpc in root['interfaces'])%>
|
|
25
|
+
<% has_implement = any((rpc['implement'] != '') for rpc in root['interfaces'])%>
|
|
26
|
+
<% has_non_virtual = any(((rpc['path'] == '*' or (version >= 17 and (render_utils.get_path_params(rpc["full_path"]) or 'paths' in rpc))) and not rpc['virtual'] and rpc['implement'] == '') for rpc in root['interfaces'])%>
|
|
27
|
+
% if has_definite_path or has_implement:
|
|
28
|
+
local mdb = require 'mc.mdb'
|
|
29
|
+
% endif
|
|
30
|
+
local class = require 'mc.class'
|
|
31
|
+
local app_base = require 'mc.client_app_base'
|
|
32
|
+
% if has_signal or has_non_virtual:
|
|
33
|
+
local mdb_service = require 'mc.mdb.mdb_service'
|
|
34
|
+
% endif
|
|
35
|
+
% if has_interface:
|
|
36
|
+
local subscribe_signal = require 'mc.mdb.subscribe_signal'
|
|
37
|
+
% endif
|
|
38
|
+
% if has_signal:
|
|
39
|
+
local org_freedesktop_dbus = require 'sd_bus.org_freedesktop_dbus'
|
|
40
|
+
% endif
|
|
41
|
+
|
|
42
|
+
% if has_signal:
|
|
43
|
+
local match_rule = org_freedesktop_dbus.MatchRule
|
|
44
|
+
% endif
|
|
45
|
+
% if has_virtual:
|
|
46
|
+
local get_virtual_interface_object = mdb_service.get_virtual_interface_object
|
|
47
|
+
% endif
|
|
48
|
+
% if has_non_virtual:
|
|
49
|
+
local get_non_virtual_interface_objects = mdb_service.get_non_virtual_interface_objects
|
|
50
|
+
local foreach_non_virtual_interface_objects = mdb_service.foreach_non_virtual_interface_objects
|
|
51
|
+
% endif
|
|
52
|
+
|
|
53
|
+
## 生成对接口的依赖
|
|
54
|
+
% for intf, intf_data in root['intf_imports'].items():
|
|
55
|
+
% if intf_data['interface'].startswith('bmc.dev.'):
|
|
56
|
+
local ${intf} = require '${project_name}.device_types.${intf}'
|
|
57
|
+
%else:
|
|
58
|
+
local ${intf} = require '${project_name}.json_types.${intf}'
|
|
59
|
+
% endif
|
|
60
|
+
% endfor
|
|
61
|
+
|
|
62
|
+
<%namespace name="default_intf" file="utils/default_intf.lua.mako"/>
|
|
63
|
+
<%namespace name="imports" file="utils/imports.mako"/>
|
|
64
|
+
${imports.render(root)}
|
|
65
|
+
|
|
66
|
+
<%
|
|
67
|
+
ClassName = root['package'] + '_client'
|
|
68
|
+
%>
|
|
69
|
+
---@class ${ClassName}: BasicClient
|
|
70
|
+
local ${ClassName} = class(app_base.Client)
|
|
71
|
+
|
|
72
|
+
% if has_implement:
|
|
73
|
+
${default_intf.add_subs(ClassName)}
|
|
74
|
+
% endif
|
|
75
|
+
## 收集复写类方法订阅接口
|
|
76
|
+
% for rpc in root['interfaces']:
|
|
77
|
+
% if rpc['path'] == '*' and rpc['virtual']:
|
|
78
|
+
|
|
79
|
+
function ${ClassName}:Get${rpc['intf_class']}Object()
|
|
80
|
+
return get_virtual_interface_object(self:get_bus(), '${rpc['interface']}')
|
|
81
|
+
end
|
|
82
|
+
% endif
|
|
83
|
+
%endfor
|
|
84
|
+
## 生成收集类client订阅接口
|
|
85
|
+
% for rpc in root['interfaces']:
|
|
86
|
+
%if rpc['path'] == '*' and not rpc['virtual'] and rpc['implement'] == '':
|
|
87
|
+
|
|
88
|
+
function ${ClassName}:Get${rpc['intf_class']}Objects()
|
|
89
|
+
return get_non_virtual_interface_objects(self:get_bus(), '${rpc['interface']}', ${'true' if rpc['retry'] else 'false'})
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
function ${ClassName}:Foreach${rpc['intf_class']}Objects(cb)
|
|
93
|
+
return foreach_non_virtual_interface_objects(self:get_bus(), '${rpc['interface']}', cb, ${'true' if rpc['retry'] else 'false'})
|
|
94
|
+
end
|
|
95
|
+
% endif
|
|
96
|
+
%endfor
|
|
97
|
+
|
|
98
|
+
## 生成默认对象的订阅和访问接口
|
|
99
|
+
% for rpc in root['interfaces']:
|
|
100
|
+
%if rpc['implement'] != '' :
|
|
101
|
+
<% default_path = ClassName +'.'+ rpc['intf_class'] +"_default" %>
|
|
102
|
+
${default_intf.render(default_path, ClassName, rpc['intf_class'], rpc['interface'])}
|
|
103
|
+
% endif
|
|
104
|
+
%endfor
|
|
105
|
+
|
|
106
|
+
% for rpc in root['interfaces']:
|
|
107
|
+
% if version >= 17:
|
|
108
|
+
% if 'paths' in rpc and not rpc['virtual']:
|
|
109
|
+
function ${ClassName}:MutipleGet${rpc['intf_class']}Objects()
|
|
110
|
+
return get_non_virtual_interface_objects(self:get_bus(), '${rpc['interface']}', ${'true' if rpc['retry'] else 'false'}, ${render_utils.get_path_patterns(rpc["paths"])})
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
function ${ClassName}:MutipleForeach${rpc['intf_class']}Objects(cb)
|
|
114
|
+
return foreach_non_virtual_interface_objects(self:get_bus(), '${rpc['interface']}', cb, ${'true' if rpc['retry'] else 'false'}, ${render_utils.get_path_patterns(rpc["paths"])})
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
% if rpc['dep_properties']:
|
|
118
|
+
function ${ClassName}:MutipleOn${rpc['intf_class']}PropertiesChanged(cb)
|
|
119
|
+
self.signal_slots[#self.signal_slots + 1] = subscribe_signal.on_properties_changed(self:get_bus(), ${render_utils.get_path_patterns(rpc["paths"])}, cb, '${rpc['interface']}'${render_utils.get_dep_properties(rpc["dep_properties"])})
|
|
120
|
+
end
|
|
121
|
+
%endif
|
|
122
|
+
|
|
123
|
+
function ${ClassName}:MutipleOn${rpc['intf_class']}InterfacesAdded(cb)
|
|
124
|
+
self.signal_slots[#self.signal_slots + 1] = subscribe_signal.on_interfaces_added(self:get_bus(), ${render_utils.get_path_patterns(rpc["paths"])}, cb, '${rpc['interface']}')
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
function ${ClassName}:MutipleOn${rpc['intf_class']}InterfacesRemoved(cb)
|
|
128
|
+
self.signal_slots[#self.signal_slots + 1] = subscribe_signal.on_interfaces_removed(self:get_bus(), ${render_utils.get_path_patterns(rpc["paths"])}, cb, '${rpc['interface']}')
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
<% continue %>
|
|
132
|
+
% endif
|
|
133
|
+
% endif
|
|
134
|
+
% if rpc['path'] != '*':
|
|
135
|
+
function ${ClassName}:Get${rpc['name']}Object(${render_utils.get_path_arg(rpc["full_path"], False)})
|
|
136
|
+
%if not rpc['retry']:
|
|
137
|
+
return mdb.get_object(self:get_bus(), ${render_utils.make_path_with_params(rpc['full_path'])}, '${rpc['interface']}')
|
|
138
|
+
%else:
|
|
139
|
+
return mdb.try_get_object(self:get_bus(), ${render_utils.get_object_path(rpc['full_path'])}, '${rpc['interface']}')
|
|
140
|
+
%endif
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
% if version >= 17:
|
|
144
|
+
% if render_utils.get_path_params(rpc["full_path"]):
|
|
145
|
+
function ${ClassName}:Get${rpc['intf_class']}Objects()
|
|
146
|
+
return get_non_virtual_interface_objects(self:get_bus(), '${rpc['interface']}', ${'true' if rpc['retry'] else 'false'}, ${render_utils.get_path_patterns([rpc["full_path"]])})
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
function ${ClassName}:Foreach${rpc['intf_class']}Objects(cb)
|
|
150
|
+
return foreach_non_virtual_interface_objects(self:get_bus(), '${rpc['interface']}', cb, ${'true' if rpc['retry'] else 'false'}, ${render_utils.get_path_patterns([rpc["full_path"]])})
|
|
151
|
+
end
|
|
152
|
+
%endif
|
|
153
|
+
%endif
|
|
154
|
+
|
|
155
|
+
% if rpc['dep_properties']:
|
|
156
|
+
function ${ClassName}:On${rpc['intf_class']}PropertiesChanged(cb${render_utils.get_path_arg(rpc["full_path"])})
|
|
157
|
+
local path_namespace = ${render_utils.get_path_namespace(rpc['full_path'])}
|
|
158
|
+
self.signal_slots[#self.signal_slots + 1] = subscribe_signal.on_properties_changed(self:get_bus(), path_namespace, cb, '${rpc['interface']}'${render_utils.get_dep_properties(rpc["dep_properties"])})
|
|
159
|
+
end
|
|
160
|
+
%endif
|
|
161
|
+
|
|
162
|
+
function ${ClassName}:On${rpc['intf_class']}InterfacesAdded(cb${render_utils.get_path_arg(rpc["full_path"])})
|
|
163
|
+
local path_namespace = ${render_utils.get_path_namespace(rpc['full_path'])}
|
|
164
|
+
self.signal_slots[#self.signal_slots + 1] = subscribe_signal.on_interfaces_added(self:get_bus(), path_namespace, cb, '${rpc['interface']}')
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
function ${ClassName}:On${rpc['intf_class']}InterfacesRemoved(cb${render_utils.get_path_arg(rpc["full_path"])})
|
|
168
|
+
local path_namespace = ${render_utils.get_path_namespace(rpc['full_path'])}
|
|
169
|
+
self.signal_slots[#self.signal_slots + 1] = subscribe_signal.on_interfaces_removed(self:get_bus(), path_namespace, cb, '${rpc['interface']}')
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
% else :
|
|
173
|
+
% if rpc['dep_properties']:
|
|
174
|
+
function ${ClassName}:On${rpc['intf_class']}PropertiesChanged(cb)
|
|
175
|
+
self.signal_slots[#self.signal_slots + 1] = subscribe_signal.on_properties_changed(self:get_bus(), '/bmc', cb, '${rpc['interface']}'${render_utils.get_dep_properties(rpc["dep_properties"])})
|
|
176
|
+
end
|
|
177
|
+
%endif
|
|
178
|
+
|
|
179
|
+
function ${ClassName}:On${rpc['intf_class']}InterfacesAdded(cb)
|
|
180
|
+
self.signal_slots[#self.signal_slots + 1] = subscribe_signal.on_interfaces_added(self:get_bus(), '/bmc', cb, '${rpc['interface']}')
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
function ${ClassName}:On${rpc['intf_class']}InterfacesRemoved(cb)
|
|
184
|
+
self.signal_slots[#self.signal_slots + 1] = subscribe_signal.on_interfaces_removed(self:get_bus(), '/bmc', cb, '${rpc['interface']}')
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
% endif
|
|
188
|
+
%endfor
|
|
189
|
+
% for rpc in root['methods']:
|
|
190
|
+
%if rpc['path'] == '*' and not rpc['virtual']:
|
|
191
|
+
<% continue %>
|
|
192
|
+
% endif
|
|
193
|
+
% for p in render_utils.props(rpc['req']): ## 生成参数注释
|
|
194
|
+
---@param ${p['name']} ${utils_py.do_type_to_lua(p['type'], p['repeated'])}
|
|
195
|
+
% endfor
|
|
196
|
+
% if render_utils.rsp_message(rpc) != 'nil': ## 生成返回值注释
|
|
197
|
+
---@return ${render_utils.rsp_message(rpc)}
|
|
198
|
+
% endif
|
|
199
|
+
% if len(render_utils.params(rpc['req'])) == 0: ## 区分参数个数生成参数, 没有参数的b
|
|
200
|
+
function ${ClassName}:${rpc['name']}(ctx${render_utils.get_path_arg(rpc["full_path"])})
|
|
201
|
+
local obj = ${get_obj(rpc)}
|
|
202
|
+
return ${render_utils.rsp_message(rpc)}.new(obj:${rpc['func_name']}(ctx))
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
function ${ClassName}:P${rpc['name']}(ctx${render_utils.get_path_arg(rpc["full_path"])})
|
|
206
|
+
return pcall(function()
|
|
207
|
+
local obj = ${get_obj(rpc)}
|
|
208
|
+
return ${render_utils.rsp_message(rpc)}.new(obj:${rpc['func_name']}(ctx))
|
|
209
|
+
end)
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
% else: ## 有参数的
|
|
213
|
+
function ${ClassName}:${rpc['name']}(ctx${render_utils.get_path_arg(rpc["full_path"])}, ${render_utils.params(rpc['req'])})
|
|
214
|
+
local req = ${render_utils.req_message(rpc)}.new(${render_utils.params(rpc['req'])}):validate()
|
|
215
|
+
local obj = ${get_obj(rpc)}
|
|
216
|
+
return ${render_utils.rsp_message(rpc)}.new(obj:${rpc['func_name']}(ctx, req:unpack(true)))
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
function ${ClassName}:P${rpc['name']}(ctx${render_utils.get_path_arg(rpc["full_path"])}, ${render_utils.params(rpc['req'])})
|
|
220
|
+
return pcall(function()
|
|
221
|
+
local req = ${render_utils.req_message(rpc)}.new(${render_utils.params(rpc['req'])}):validate()
|
|
222
|
+
local obj = ${get_obj(rpc)}
|
|
223
|
+
return ${render_utils.rsp_message(rpc)}.new(obj:${rpc['func_name']}(ctx, req:unpack(true)))
|
|
224
|
+
end)
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
% endif
|
|
228
|
+
% endfor
|
|
229
|
+
## 生成信号订阅接口
|
|
230
|
+
% for signal in root['signals']:
|
|
231
|
+
function ${ClassName}:Subscribe${signal['name']}(cb)
|
|
232
|
+
local sig = match_rule.signal('${signal['signal_name']}', '${signal['interface']}')${'' if signal['path'] == '*' else (':with_path("' +signal['path']+'")')}
|
|
233
|
+
self.signal_slots[#self.signal_slots+1] = self:get_bus():match(sig, function(msg)
|
|
234
|
+
cb(msg:read())
|
|
235
|
+
end)
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
% endfor
|
|
239
|
+
function ${ClassName}:ctor()
|
|
240
|
+
self.signal_slots = {}
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
---@type ${ClassName}
|
|
244
|
+
return ${ClassName}.new('${root['package']}')
|
|
245
|
+
% else:
|
|
246
|
+
${make_header('lua')}
|
|
247
|
+
<%namespace name="mdb_obj" file= "utils/mdb_obj.lua.mako"/>
|
|
248
|
+
local app_base = require 'mc.client_app_base'
|
|
249
|
+
local log = require 'mc.logging'
|
|
250
|
+
local class = require 'mc.class'
|
|
251
|
+
local org_freedesktop_dbus = require 'sd_bus.org_freedesktop_dbus'
|
|
252
|
+
local MatchRule = org_freedesktop_dbus.MatchRule
|
|
253
|
+
local mdb = require 'mc.mdb'
|
|
254
|
+
local mdb_service = require 'mc.mdb.mdb_service'
|
|
255
|
+
local subscribe_signal = require 'mc.mdb.subscribe_signal'
|
|
256
|
+
|
|
257
|
+
local get_virtual_interface_object = mdb_service.get_virtual_interface_object
|
|
258
|
+
local get_non_virtual_interface_objects = mdb_service.get_non_virtual_interface_objects
|
|
259
|
+
local foreach_non_virtual_interface_objects = mdb_service.foreach_non_virtual_interface_objects
|
|
260
|
+
|
|
261
|
+
## 生成对接口的依赖
|
|
262
|
+
% for intf, intf_data in root['intf_imports'].items():
|
|
263
|
+
% if intf_data['interface'].startswith('bmc.dev.'):
|
|
264
|
+
local ${intf} = require '${project_name}.device_types.${intf}'
|
|
265
|
+
%else:
|
|
266
|
+
local ${intf} = require '${project_name}.json_types.${intf}'
|
|
267
|
+
% endif
|
|
268
|
+
% endfor
|
|
269
|
+
|
|
270
|
+
<%namespace name="default_intf" file="utils/default_intf.lua.mako"/>
|
|
271
|
+
<%namespace name="imports" file="utils/imports.mako"/>
|
|
272
|
+
${imports.render(root)}
|
|
273
|
+
% if any(rpc['retry'] for rpc in root['interfaces']):
|
|
274
|
+
% if any(rpc['path'] != '*' for rpc in root['interfaces']):
|
|
275
|
+
local base_messages = require 'messages.base'
|
|
276
|
+
% endif
|
|
277
|
+
local skynet = require 'skynet'
|
|
278
|
+
local MAX_RETRY_TIMES<const> = 10
|
|
279
|
+
% endif
|
|
280
|
+
|
|
281
|
+
<%
|
|
282
|
+
ClassName = root['package'] + '_client'
|
|
283
|
+
%>
|
|
284
|
+
---@class ${ClassName}: BasicClient
|
|
285
|
+
local ${ClassName} = class(app_base.Client)
|
|
286
|
+
|
|
287
|
+
${default_intf.add_subs(ClassName)}
|
|
288
|
+
## 收集复写类方法订阅接口
|
|
289
|
+
% for rpc in root['interfaces']:
|
|
290
|
+
% if rpc['path'] == '*' and rpc['virtual']:
|
|
291
|
+
|
|
292
|
+
function ${ClassName}:Get${rpc['intf_class']}Object()
|
|
293
|
+
return get_virtual_interface_object(self:get_bus(), '${rpc['interface']}')
|
|
294
|
+
end
|
|
295
|
+
% endif
|
|
296
|
+
%endfor
|
|
297
|
+
## 生成收集类client订阅接口
|
|
298
|
+
% for rpc in root['interfaces']:
|
|
299
|
+
%if rpc['path'] == '*' and not rpc['virtual'] and rpc['implement'] == '':
|
|
300
|
+
|
|
301
|
+
function ${ClassName}:Get${rpc['intf_class']}Objects()
|
|
302
|
+
return get_non_virtual_interface_objects(self:get_bus(), '${rpc['interface']}', ${'true' if rpc['retry'] else 'false'})
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
function ${ClassName}:Foreach${rpc['intf_class']}Objects(cb)
|
|
306
|
+
return foreach_non_virtual_interface_objects(self:get_bus(), '${rpc['interface']}', cb, ${'true' if rpc['retry'] else 'false'})
|
|
307
|
+
end
|
|
308
|
+
% endif
|
|
309
|
+
%endfor
|
|
310
|
+
|
|
311
|
+
## 生成默认对象的订阅和访问接口
|
|
312
|
+
% for rpc in root['interfaces']:
|
|
313
|
+
%if rpc['implement'] != '' :
|
|
314
|
+
<% default_path = ClassName +'.'+ rpc['intf_class'] +"_default" %>
|
|
315
|
+
${default_intf.render(default_path, ClassName, rpc['intf_class'], rpc['interface'])}
|
|
316
|
+
% endif
|
|
317
|
+
%endfor
|
|
318
|
+
|
|
319
|
+
% for rpc in root['interfaces']:
|
|
320
|
+
% if rpc['path'] != '*':
|
|
321
|
+
function ${ClassName}:Get${rpc['name']}Object(${render_utils.get_path_arg(rpc["full_path"], False)})
|
|
322
|
+
%if not rpc['retry']:
|
|
323
|
+
return mdb.get_object(self:get_bus(), ${render_utils.make_path_with_params(rpc['full_path'])}, '${rpc['interface']}')
|
|
324
|
+
%else:
|
|
325
|
+
local retry_times = 0
|
|
326
|
+
local path = ${render_utils.get_object_path(rpc['full_path'])}
|
|
327
|
+
while retry_times < MAX_RETRY_TIMES do
|
|
328
|
+
local ok, obj = pcall(mdb.get_object, self:get_bus(), path, '${rpc['interface']}')
|
|
329
|
+
if ok then
|
|
330
|
+
return obj
|
|
331
|
+
end
|
|
332
|
+
skynet.sleep(50)
|
|
333
|
+
retry_times = retry_times + 1
|
|
334
|
+
end
|
|
335
|
+
error(base_messages.InternalError())
|
|
336
|
+
%endif
|
|
337
|
+
end
|
|
338
|
+
|
|
339
|
+
% if rpc['dep_properties']:
|
|
340
|
+
function ${ClassName}:On${rpc['intf_class']}PropertiesChanged(cb${render_utils.get_path_arg(rpc["full_path"])})
|
|
341
|
+
local path_namespace = ${render_utils.get_path_namespace(rpc['full_path'])}
|
|
342
|
+
self.signal_slots[#self.signal_slots + 1] = subscribe_signal.on_properties_changed(self:get_bus(), path_namespace, cb, '${rpc['interface']}'${render_utils.get_dep_properties(rpc["dep_properties"])})
|
|
343
|
+
end
|
|
344
|
+
%endif
|
|
345
|
+
|
|
346
|
+
function ${ClassName}:On${rpc['intf_class']}InterfacesAdded(cb${render_utils.get_path_arg(rpc["full_path"])})
|
|
347
|
+
local path_namespace = ${render_utils.get_path_namespace(rpc['full_path'])}
|
|
348
|
+
self.signal_slots[#self.signal_slots + 1] = subscribe_signal.on_interfaces_added(self:get_bus(), path_namespace, cb, '${rpc['interface']}')
|
|
349
|
+
end
|
|
350
|
+
|
|
351
|
+
function ${ClassName}:On${rpc['intf_class']}InterfacesRemoved(cb${render_utils.get_path_arg(rpc["full_path"])})
|
|
352
|
+
local path_namespace = ${render_utils.get_path_namespace(rpc['full_path'])}
|
|
353
|
+
self.signal_slots[#self.signal_slots + 1] = subscribe_signal.on_interfaces_removed(self:get_bus(), path_namespace, cb, '${rpc['interface']}')
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
% else :
|
|
357
|
+
% if rpc['dep_properties']:
|
|
358
|
+
function ${ClassName}:On${rpc['intf_class']}PropertiesChanged(cb)
|
|
359
|
+
self.signal_slots[#self.signal_slots + 1] = subscribe_signal.on_properties_changed(self:get_bus(), '/bmc', cb, '${rpc['interface']}'${render_utils.get_dep_properties(rpc["dep_properties"])})
|
|
360
|
+
end
|
|
361
|
+
%endif
|
|
362
|
+
|
|
363
|
+
function ${ClassName}:On${rpc['intf_class']}InterfacesAdded(cb)
|
|
364
|
+
self.signal_slots[#self.signal_slots + 1] = subscribe_signal.on_interfaces_added(self:get_bus(), '/bmc', cb, '${rpc['interface']}')
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
function ${ClassName}:On${rpc['intf_class']}InterfacesRemoved(cb)
|
|
368
|
+
self.signal_slots[#self.signal_slots + 1] = subscribe_signal.on_interfaces_removed(self:get_bus(), '/bmc', cb, '${rpc['interface']}')
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
% endif
|
|
372
|
+
%endfor
|
|
373
|
+
% for rpc in root['methods']:
|
|
374
|
+
%if rpc['path'] == '*' and not rpc['virtual']:
|
|
375
|
+
<% continue %>
|
|
376
|
+
% endif
|
|
377
|
+
% for p in render_utils.props(rpc['req']): ## 生成参数注释
|
|
378
|
+
---@param ${p['name']} ${utils_py.do_type_to_lua(p['type'], p['repeated'])}
|
|
379
|
+
% endfor
|
|
380
|
+
% if render_utils.rsp_message(rpc) != 'nil': ## 生成返回值注释
|
|
381
|
+
---@return ${render_utils.rsp_message(rpc)}
|
|
382
|
+
% endif
|
|
383
|
+
% if len(render_utils.params(rpc['req'])) == 0: ## 区分参数个数生成参数, 没有参数的b
|
|
384
|
+
function ${ClassName}:${rpc['name']}(ctx${render_utils.get_path_arg(rpc["full_path"])})
|
|
385
|
+
local obj = ${get_obj(rpc)}
|
|
386
|
+
return ${render_utils.rsp_message(rpc)}.new(obj:${rpc['func_name']}(ctx))
|
|
387
|
+
end
|
|
388
|
+
|
|
389
|
+
function ${ClassName}:P${rpc['name']}(ctx${render_utils.get_path_arg(rpc["full_path"])})
|
|
390
|
+
return pcall(function()
|
|
391
|
+
local obj = ${get_obj(rpc)}
|
|
392
|
+
return ${render_utils.rsp_message(rpc)}.new(obj:${rpc['func_name']}(ctx))
|
|
393
|
+
end)
|
|
394
|
+
end
|
|
395
|
+
|
|
396
|
+
% else: ## 有参数的
|
|
397
|
+
function ${ClassName}:${rpc['name']}(ctx${render_utils.get_path_arg(rpc["full_path"])}, ${render_utils.params(rpc['req'])})
|
|
398
|
+
local req = ${render_utils.req_message(rpc)}.new(${render_utils.params(rpc['req'])}):validate()
|
|
399
|
+
local obj = ${get_obj(rpc)}
|
|
400
|
+
return ${render_utils.rsp_message(rpc)}.new(obj:${rpc['func_name']}(ctx, req:unpack(true)))
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
function ${ClassName}:P${rpc['name']}(ctx${render_utils.get_path_arg(rpc["full_path"])}, ${render_utils.params(rpc['req'])})
|
|
404
|
+
return pcall(function()
|
|
405
|
+
local req = ${render_utils.req_message(rpc)}.new(${render_utils.params(rpc['req'])}):validate()
|
|
406
|
+
local obj = ${get_obj(rpc)}
|
|
407
|
+
return ${render_utils.rsp_message(rpc)}.new(obj:${rpc['func_name']}(ctx, req:unpack(true)))
|
|
408
|
+
end)
|
|
409
|
+
end
|
|
410
|
+
|
|
411
|
+
% endif
|
|
412
|
+
% endfor
|
|
413
|
+
## 生成信号订阅接口
|
|
414
|
+
% for signal in root['signals']:
|
|
415
|
+
function ${ClassName}:Subscribe${signal['name']}(cb)
|
|
416
|
+
local sig = MatchRule.signal('${signal['signal_name']}', '${signal['interface']}')${'' if signal['path'] == '*' else (':with_path("' +signal['path']+'")')}
|
|
417
|
+
self.signal_slots[#self.signal_slots+1] = self:get_bus():match(sig, function(msg)
|
|
418
|
+
cb(msg:read())
|
|
419
|
+
end)
|
|
420
|
+
end
|
|
421
|
+
|
|
422
|
+
% endfor
|
|
423
|
+
function ${ClassName}:ctor()
|
|
424
|
+
self.signal_slots = {}
|
|
425
|
+
end
|
|
426
|
+
|
|
427
|
+
---@type ${ClassName}
|
|
428
|
+
return ${ClassName}.new('${root['package']}')
|
|
429
|
+
% endif
|