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,575 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# coding=utf-8
|
|
3
|
+
# Copyright (c) 2024 Huawei Technologies Co., Ltd.
|
|
4
|
+
# openUBMC is licensed under Mulan PSL v2.
|
|
5
|
+
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
6
|
+
# You may obtain a copy of Mulan PSL v2 at:
|
|
7
|
+
# http://license.coscl.org.cn/MulanPSL2
|
|
8
|
+
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
|
9
|
+
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
|
10
|
+
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
11
|
+
# See the Mulan PSL v2 for more details.
|
|
12
|
+
|
|
13
|
+
import json
|
|
14
|
+
import logging
|
|
15
|
+
import getopt
|
|
16
|
+
import sys
|
|
17
|
+
import os
|
|
18
|
+
import re
|
|
19
|
+
import mds_util as utils
|
|
20
|
+
from utils import Utils
|
|
21
|
+
|
|
22
|
+
PROP_PRIORITY = "priority"
|
|
23
|
+
PROP_LOCAL = "LocalPer"
|
|
24
|
+
|
|
25
|
+
PROP_REMOTE = "RemotePer"
|
|
26
|
+
CLASS_PRIVATE = "private_class"
|
|
27
|
+
INTERFACES = "interfaces"
|
|
28
|
+
METHODS = "methods"
|
|
29
|
+
SIGNALS = "signals"
|
|
30
|
+
NEED_MEM_DB = "need_mem_db"
|
|
31
|
+
KLASS = "class"
|
|
32
|
+
PATH = "path"
|
|
33
|
+
PATHS = "paths"
|
|
34
|
+
DEFS = "defs"
|
|
35
|
+
ITEMS = ["dep_properties", "dep_methods", "dep_signals"]
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class InterfaceDep:
|
|
39
|
+
def __init__(self, required: dict):
|
|
40
|
+
self.name = required.get("interface", "")
|
|
41
|
+
self.optional = required.get("optional", False)
|
|
42
|
+
self.stage = required.get("stage", "running")
|
|
43
|
+
self.dep_properties = ["*"]
|
|
44
|
+
self.dep_methods = ["*"]
|
|
45
|
+
self.dep_signals = ["*"]
|
|
46
|
+
if "properties" in required:
|
|
47
|
+
self.dep_properties = []
|
|
48
|
+
for prop, prop_config in required["properties"].items():
|
|
49
|
+
if "subscribe" in prop_config:
|
|
50
|
+
self.dep_properties.append(prop)
|
|
51
|
+
|
|
52
|
+
if "methods" in required:
|
|
53
|
+
self.dep_methods = list(required["methods"].keys())
|
|
54
|
+
|
|
55
|
+
if "signals" in required:
|
|
56
|
+
self.dep_signals = list(required["signals"].keys())
|
|
57
|
+
|
|
58
|
+
if "paths" in required:
|
|
59
|
+
self.paths = required[PATHS]
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def save_service(service, intf_imports, paths, of_name, path_level):
|
|
63
|
+
service_json_path, ipmi_json_path = paths.get('service_json_path', ''), paths.get('ipmi_json_path', '')
|
|
64
|
+
load_f = utils.open_file(service_json_path)
|
|
65
|
+
load_dict = json.load(load_f)
|
|
66
|
+
imports = [
|
|
67
|
+
"google/protobuf/descriptor.proto",
|
|
68
|
+
"types.proto",
|
|
69
|
+
"google/protobuf/empty.proto",
|
|
70
|
+
]
|
|
71
|
+
opt = {}
|
|
72
|
+
if PROP_LOCAL in intf_imports:
|
|
73
|
+
for local_per_type in intf_imports[PROP_LOCAL]:
|
|
74
|
+
opt["has_local_" + local_per_type.lower()[:-3]] = True
|
|
75
|
+
if intf_imports.get(PROP_REMOTE):
|
|
76
|
+
opt["has_remote_per"] = True
|
|
77
|
+
class_require = intf_imports[KLASS]
|
|
78
|
+
handled_intf_imports = {}
|
|
79
|
+
for k, v in intf_imports["intf"].items():
|
|
80
|
+
if v['interface'].startswith('bmc.dev.'):
|
|
81
|
+
handled_intf_imports[os.path.join('../device_types/' + k)] = v
|
|
82
|
+
else:
|
|
83
|
+
handled_intf_imports[k] = v
|
|
84
|
+
|
|
85
|
+
has_ipmi_cmd = False
|
|
86
|
+
if os.path.exists(ipmi_json_path):
|
|
87
|
+
with open(ipmi_json_path, "r", encoding="utf-8") as fd:
|
|
88
|
+
ipmi_data = json.load(fd)
|
|
89
|
+
if ipmi_data.get('cmds', {}):
|
|
90
|
+
has_ipmi_cmd = True
|
|
91
|
+
|
|
92
|
+
intf_imports_old = handled_intf_imports.keys()
|
|
93
|
+
intf_imports_tmp = list(map(lambda x: x + ".proto", intf_imports_old))
|
|
94
|
+
depends = ["types.proto", "google/protobuf/empty.proto"]
|
|
95
|
+
datas = {
|
|
96
|
+
"imports": imports + intf_imports_tmp,
|
|
97
|
+
"dependency": depends,
|
|
98
|
+
"intf_imports": intf_imports["intf"],
|
|
99
|
+
"class_require": class_require,
|
|
100
|
+
"private_class_require": intf_imports.get(CLASS_PRIVATE, {}),
|
|
101
|
+
"data": [],
|
|
102
|
+
INTERFACES: service[INTERFACES],
|
|
103
|
+
METHODS: service[METHODS],
|
|
104
|
+
SIGNALS: service[SIGNALS],
|
|
105
|
+
"has_ipmi_cmd": has_ipmi_cmd,
|
|
106
|
+
"package": load_dict['name'],
|
|
107
|
+
"options": opt,
|
|
108
|
+
NEED_MEM_DB: service.get(NEED_MEM_DB, False)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
## 匹配APP下的service_json_path目录,如果是扩展组件,层级为3
|
|
112
|
+
if path_level != 0:
|
|
113
|
+
datas['path_level'] = path_level
|
|
114
|
+
|
|
115
|
+
utils.save_proto_json(of_name, datas)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def check_duplicate(services, method_name):
|
|
119
|
+
for method in services:
|
|
120
|
+
if method["name"] == method_name:
|
|
121
|
+
return True
|
|
122
|
+
return False
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def get_require_by_path(path, class_name):
|
|
126
|
+
if path == "*":
|
|
127
|
+
return path
|
|
128
|
+
path = utils.cut_ids(path)
|
|
129
|
+
path = os.path.realpath(path)
|
|
130
|
+
return "mdb" + path.replace("/", ".") + "." + class_name
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def get_intf_impl(intf_data):
|
|
134
|
+
return "" if "implement" not in intf_data else intf_data["implement"]
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def fill_imports(imports, intf_data, intf, class_path, class_name):
|
|
138
|
+
intf_class = Utils.get_unique_intf_name(intf)
|
|
139
|
+
imports["intf"][intf_class] = {
|
|
140
|
+
"interface": intf,
|
|
141
|
+
"default": get_intf_impl(intf_data),
|
|
142
|
+
"data": {intf: intf_data},
|
|
143
|
+
}
|
|
144
|
+
if class_path != "*":
|
|
145
|
+
imports[KLASS][class_name] = {
|
|
146
|
+
PATH: class_path.replace("${", ":").replace("}", ""),
|
|
147
|
+
PROP_PRIORITY: 0 if PROP_PRIORITY not in intf_data else intf_data[PROP_PRIORITY],
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def get_override(intf_data, method_name):
|
|
152
|
+
override = True
|
|
153
|
+
if "non_overrides" in intf_data:
|
|
154
|
+
override = method_name not in intf_data["non_overrides"]
|
|
155
|
+
|
|
156
|
+
return override
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def get_intf_default(intf_data):
|
|
160
|
+
return (
|
|
161
|
+
""
|
|
162
|
+
if "default" not in intf_data
|
|
163
|
+
else utils.get_intf_package_name(intf_data["default"])
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def check_interface_duplicate(interfaces, interface, intf_name, intf_data):
|
|
168
|
+
for intf in interfaces:
|
|
169
|
+
if intf["name"] == interface and PATHS not in intf_data and PATHS not in intf:
|
|
170
|
+
return True
|
|
171
|
+
|
|
172
|
+
if intf["interface"] == intf_name and PATHS in intf_data and PATHS in intf:
|
|
173
|
+
return True
|
|
174
|
+
return False
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def generate_interface(class_name, intf_data, interfaces, intf, class_path):
|
|
178
|
+
intf_class = Utils.get_unique_intf_name(intf)
|
|
179
|
+
interface = class_name + intf_class
|
|
180
|
+
if check_interface_duplicate(interfaces, interface, intf, intf_data):
|
|
181
|
+
return
|
|
182
|
+
|
|
183
|
+
for item in ITEMS:
|
|
184
|
+
values = intf_data.get(item, [])
|
|
185
|
+
if values == ["*"]:
|
|
186
|
+
continue
|
|
187
|
+
if values and set(values) == set(intf_data.get(item[4:], {}).keys()):
|
|
188
|
+
intf_data[item] = ["*"]
|
|
189
|
+
continue
|
|
190
|
+
for value in values:
|
|
191
|
+
if not intf_data.get(item[4:], {}).get(value, {}):
|
|
192
|
+
raise Exception(f"在service.json中配置了不存在的依赖项, interface: {intf}, item: {value}")
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
interface_data = {
|
|
196
|
+
"name": interface,
|
|
197
|
+
KLASS: class_name,
|
|
198
|
+
PATH: utils.get_real_path(class_path),
|
|
199
|
+
"interface": intf,
|
|
200
|
+
"intf_class": intf_class,
|
|
201
|
+
"virtual": "virtual" in intf_data,
|
|
202
|
+
"implement": get_intf_impl(intf_data),
|
|
203
|
+
"default": get_intf_default(intf_data),
|
|
204
|
+
"full_path": class_path,
|
|
205
|
+
"retry": intf_data.get("retry", False),
|
|
206
|
+
"dep_properties": intf_data.get("dep_properties", ["*"]),
|
|
207
|
+
"dep_methods": intf_data.get("dep_methods", ["*"]),
|
|
208
|
+
"dep_signals": intf_data.get("dep_signals", ["*"])
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if PATHS in intf_data:
|
|
212
|
+
interface_data[PATHS] = intf_data[PATHS]
|
|
213
|
+
|
|
214
|
+
interfaces.append(interface_data)
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
def generate_method(class_name, intf_data, methods, intf, class_path):
|
|
218
|
+
if not intf_data.get(METHODS, {}):
|
|
219
|
+
return
|
|
220
|
+
|
|
221
|
+
intf_class = Utils.get_unique_intf_name(intf)
|
|
222
|
+
for method_name in intf_data[METHODS].keys():
|
|
223
|
+
dep_methods = intf_data.get("dep_methods", ["*"])
|
|
224
|
+
if dep_methods != ["*"] and method_name not in intf_data.get("dep_methods", []):
|
|
225
|
+
continue
|
|
226
|
+
method = "".join([class_name, intf_class, method_name])
|
|
227
|
+
if check_duplicate(methods, method):
|
|
228
|
+
continue
|
|
229
|
+
req_name = method_name + "Req"
|
|
230
|
+
rsp_name = method_name + "Rsp"
|
|
231
|
+
|
|
232
|
+
method_data = {
|
|
233
|
+
"name": method,
|
|
234
|
+
"func_name": method_name,
|
|
235
|
+
KLASS: class_name,
|
|
236
|
+
"req": "." + intf_class + "." + req_name,
|
|
237
|
+
"rsp": "." + intf_class + "." + rsp_name,
|
|
238
|
+
PATH: utils.get_real_path(class_path),
|
|
239
|
+
"interface": intf,
|
|
240
|
+
"intf_class": intf_class,
|
|
241
|
+
"virtual": "virtual" in intf_data,
|
|
242
|
+
"implement": get_intf_impl(intf_data),
|
|
243
|
+
"default": get_intf_default(intf_data),
|
|
244
|
+
"override": get_override(intf_data, method_name),
|
|
245
|
+
"full_path": class_path,
|
|
246
|
+
"retry": intf_data.get("retry", False)
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if PATHS in intf_data:
|
|
250
|
+
method_data[PATHS] = intf_data[PATHS]
|
|
251
|
+
|
|
252
|
+
methods.append(method_data)
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
def generate_signal(class_name, intf_data, signals, intf, class_path):
|
|
256
|
+
if SIGNALS not in intf_data or len(intf_data[SIGNALS]) == 0:
|
|
257
|
+
return
|
|
258
|
+
|
|
259
|
+
intf_class = Utils.get_unique_intf_name(intf)
|
|
260
|
+
for signal_name in intf_data[SIGNALS].keys():
|
|
261
|
+
dep_signals = intf_data.get("dep_signals", ["*"])
|
|
262
|
+
if dep_signals != ["*"] and signal_name not in intf_data.get("dep_signals", []):
|
|
263
|
+
continue
|
|
264
|
+
signal = class_name + intf_class + signal_name
|
|
265
|
+
if check_duplicate(signals, signal):
|
|
266
|
+
continue
|
|
267
|
+
sig_name = signal_name + "Signature"
|
|
268
|
+
signals.append(
|
|
269
|
+
{
|
|
270
|
+
"name": signal,
|
|
271
|
+
"signal_name": signal_name,
|
|
272
|
+
KLASS: class_name,
|
|
273
|
+
"signature": "." + intf_class + "." + sig_name,
|
|
274
|
+
PATH: class_path,
|
|
275
|
+
"interface": intf,
|
|
276
|
+
"intf_class": intf_class,
|
|
277
|
+
}
|
|
278
|
+
)
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
def prepare_virutal(intf_data):
|
|
282
|
+
if "virtual" in intf_data:
|
|
283
|
+
intf_data["properties"][PROP_PRIORITY] = {
|
|
284
|
+
"baseType": "U8",
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
def prepare_intf_data(intf_data, intf_dep: InterfaceDep):
|
|
289
|
+
intf = intf_dep.name
|
|
290
|
+
if DEFS in intf_data:
|
|
291
|
+
intf_data[intf][DEFS] = intf_data[DEFS]
|
|
292
|
+
prepare_virutal(intf_data)
|
|
293
|
+
intf_data[intf]["retry"] = not intf_dep.optional and intf_dep.stage == "running"
|
|
294
|
+
for item in ITEMS:
|
|
295
|
+
intf_data[intf][item] = getattr(intf_dep, item)
|
|
296
|
+
if Utils.get_lua_codegen_version() >= 17:
|
|
297
|
+
if hasattr(intf_dep, PATHS):
|
|
298
|
+
intf_data[intf][PATHS] = getattr(intf_dep, PATHS)
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
def generate_path_interface(load_dict, service, imports, mdb_path, intf_dep: InterfaceDep):
|
|
302
|
+
intf = intf_dep.name
|
|
303
|
+
for class_name, class_data in load_dict.items():
|
|
304
|
+
if INTERFACES in class_data:
|
|
305
|
+
intf_data = utils.get_intf(intf, mdb_path)
|
|
306
|
+
if "implement" in intf_data[intf]:
|
|
307
|
+
intf_data = utils.generate_default(intf_data, mdb_path)
|
|
308
|
+
prepare_intf_data(intf_data, intf_dep)
|
|
309
|
+
generate_interface(
|
|
310
|
+
class_name,
|
|
311
|
+
intf_data[intf],
|
|
312
|
+
service[INTERFACES],
|
|
313
|
+
intf,
|
|
314
|
+
class_data[PATH],
|
|
315
|
+
)
|
|
316
|
+
generate_method(
|
|
317
|
+
class_name,
|
|
318
|
+
intf_data[intf],
|
|
319
|
+
service[METHODS],
|
|
320
|
+
intf,
|
|
321
|
+
class_data[PATH],
|
|
322
|
+
)
|
|
323
|
+
generate_signal(
|
|
324
|
+
class_name,
|
|
325
|
+
intf_data[intf],
|
|
326
|
+
service[SIGNALS],
|
|
327
|
+
intf,
|
|
328
|
+
class_data[PATH],
|
|
329
|
+
)
|
|
330
|
+
fill_imports(imports, intf_data[intf],
|
|
331
|
+
intf, class_data[PATH], class_name)
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
def check_local_location(class_data, imports):
|
|
335
|
+
if class_data.get("tableLocation", "") != "Local":
|
|
336
|
+
return
|
|
337
|
+
if PROP_LOCAL not in imports:
|
|
338
|
+
imports[PROP_LOCAL] = {}
|
|
339
|
+
imports[PROP_LOCAL][class_data.get("tableType", "PoweroffPer")] = True
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
def check_remote_per(class_data):
|
|
343
|
+
if "tableName" not in class_data or class_data.get("tableLocation") == "Local":
|
|
344
|
+
return False
|
|
345
|
+
if "tableType" in class_data:
|
|
346
|
+
return True
|
|
347
|
+
class_props = list(class_data.get("properties", {}).values())
|
|
348
|
+
for intf_data in class_data.get(INTERFACES, {}).values():
|
|
349
|
+
class_props.extend(intf_data.get("properties", {}).values())
|
|
350
|
+
|
|
351
|
+
for prop_data in class_props:
|
|
352
|
+
for item in prop_data.get("usage", []):
|
|
353
|
+
if "Per" in item:
|
|
354
|
+
return True
|
|
355
|
+
return False
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
def generate_service(model_merged_file, of_name, service_json_path, ipmi_json_path, path_level):
|
|
359
|
+
load_f = utils.open_file(model_merged_file)
|
|
360
|
+
load_dict = json.load(load_f)
|
|
361
|
+
|
|
362
|
+
interfaces = []
|
|
363
|
+
methods = []
|
|
364
|
+
signals = []
|
|
365
|
+
imports = {"intf": {}, KLASS: {}, CLASS_PRIVATE: {}}
|
|
366
|
+
imports[PROP_REMOTE] = False
|
|
367
|
+
for class_name, class_data in load_dict.items():
|
|
368
|
+
imports[PROP_REMOTE] = imports[PROP_REMOTE] or check_remote_per(class_data)
|
|
369
|
+
check_local_location(class_data, imports)
|
|
370
|
+
if INTERFACES not in class_data:
|
|
371
|
+
if CLASS_PRIVATE in imports:
|
|
372
|
+
imports[CLASS_PRIVATE][class_name] = {"data": class_data}
|
|
373
|
+
continue
|
|
374
|
+
|
|
375
|
+
for intf_name, intf_data in class_data[INTERFACES].items():
|
|
376
|
+
generate_interface(
|
|
377
|
+
class_name,
|
|
378
|
+
intf_data,
|
|
379
|
+
interfaces,
|
|
380
|
+
intf_name,
|
|
381
|
+
class_data[PATH],
|
|
382
|
+
)
|
|
383
|
+
generate_method(
|
|
384
|
+
class_name,
|
|
385
|
+
intf_data,
|
|
386
|
+
methods,
|
|
387
|
+
intf_name,
|
|
388
|
+
class_data[PATH],
|
|
389
|
+
)
|
|
390
|
+
generate_signal(
|
|
391
|
+
class_name,
|
|
392
|
+
intf_data,
|
|
393
|
+
signals,
|
|
394
|
+
intf_name,
|
|
395
|
+
class_data[PATH],
|
|
396
|
+
)
|
|
397
|
+
fill_imports(imports, intf_data, intf_name,
|
|
398
|
+
class_data[PATH], class_name)
|
|
399
|
+
if class_name not in imports[KLASS]:
|
|
400
|
+
imports[KLASS][class_name] = {PATH: class_data[PATH]}
|
|
401
|
+
imports[KLASS][class_name]["data"] = class_data
|
|
402
|
+
|
|
403
|
+
service = {INTERFACES: interfaces, METHODS: methods, SIGNALS: signals}
|
|
404
|
+
service[NEED_MEM_DB] = Utils.check_model_need_mem_db(load_dict)
|
|
405
|
+
paths = {"service_json_path": service_json_path, "ipmi_json_path": ipmi_json_path}
|
|
406
|
+
save_service(service, imports, paths, of_name, path_level)
|
|
407
|
+
load_f.close()
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
def get_class_name(path):
|
|
411
|
+
pos = -2 if path.endswith("/") else -1
|
|
412
|
+
return path.split("/")[pos]
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
def generate_only_interface(intf_dep: InterfaceDep, service, imports, mdb_path):
|
|
416
|
+
intf = intf_dep.name
|
|
417
|
+
intf_data = utils.get_intf(intf, mdb_path)
|
|
418
|
+
if "implement" in intf_data[intf]:
|
|
419
|
+
intf_data = utils.generate_default(intf_data, mdb_path)
|
|
420
|
+
|
|
421
|
+
prepare_intf_data(intf_data, intf_dep)
|
|
422
|
+
generate_interface(
|
|
423
|
+
"",
|
|
424
|
+
intf_data[intf],
|
|
425
|
+
service[INTERFACES],
|
|
426
|
+
intf,
|
|
427
|
+
"*",
|
|
428
|
+
)
|
|
429
|
+
generate_method(
|
|
430
|
+
"",
|
|
431
|
+
intf_data[intf],
|
|
432
|
+
service[METHODS],
|
|
433
|
+
intf,
|
|
434
|
+
"*",
|
|
435
|
+
)
|
|
436
|
+
generate_signal(
|
|
437
|
+
"",
|
|
438
|
+
intf_data[intf],
|
|
439
|
+
service[SIGNALS],
|
|
440
|
+
intf,
|
|
441
|
+
"*",
|
|
442
|
+
)
|
|
443
|
+
fill_imports(imports, intf_data[intf], intf, "*", "")
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
def fill_client_intf(service, imports, mdb_path, required, path):
|
|
447
|
+
intf_dep = InterfaceDep(required)
|
|
448
|
+
if path != "*":
|
|
449
|
+
class_name, path_json = utils.get_path_by_interface(mdb_path, required["interface"], path)
|
|
450
|
+
generate_path_interface(
|
|
451
|
+
path_json, service, imports, mdb_path, intf_dep
|
|
452
|
+
)
|
|
453
|
+
|
|
454
|
+
if class_name not in imports[KLASS]:
|
|
455
|
+
imports[KLASS][class_name] = {}
|
|
456
|
+
imports[KLASS][class_name]["data"] = path_json[class_name]
|
|
457
|
+
else:
|
|
458
|
+
generate_only_interface(
|
|
459
|
+
intf_dep, service, imports, mdb_path
|
|
460
|
+
)
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
def check_multiple_paths(interfaces):
|
|
464
|
+
intf_map = {}
|
|
465
|
+
for intf in interfaces:
|
|
466
|
+
intf_name = intf["interface"]
|
|
467
|
+
if intf_name in intf_map and PATHS in intf:
|
|
468
|
+
raise Exception(f"service.json中{intf_name}接口配置了多个paths依赖")
|
|
469
|
+
if PATHS in intf:
|
|
470
|
+
intf_map[intf_name] = True
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
def generate_client(service_file, output, mdb_path, mds_path, path_level):
|
|
474
|
+
load_f = utils.open_file(service_file)
|
|
475
|
+
service_dict = json.load(load_f)
|
|
476
|
+
|
|
477
|
+
imports = {"intf": {}, KLASS: {}}
|
|
478
|
+
if "required" not in service_dict:
|
|
479
|
+
load_f.close()
|
|
480
|
+
return
|
|
481
|
+
|
|
482
|
+
if Utils.get_lua_codegen_version() >= 17:
|
|
483
|
+
check_multiple_paths(service_dict["required"])
|
|
484
|
+
|
|
485
|
+
interfaces = []
|
|
486
|
+
methods = []
|
|
487
|
+
signals = []
|
|
488
|
+
service = {INTERFACES: interfaces, METHODS: methods, SIGNALS: signals}
|
|
489
|
+
for required in service_dict["required"]:
|
|
490
|
+
if PATH in required:
|
|
491
|
+
fill_client_intf(service, imports, mdb_path, required, required[PATH])
|
|
492
|
+
continue
|
|
493
|
+
|
|
494
|
+
if Utils.get_lua_codegen_version() >= 17:
|
|
495
|
+
if PATHS not in required:
|
|
496
|
+
continue
|
|
497
|
+
for path in required[PATHS]:
|
|
498
|
+
fill_client_intf(service, imports, mdb_path, required, path)
|
|
499
|
+
|
|
500
|
+
paths = {"service_json_path": mds_path}
|
|
501
|
+
save_service(service, imports, paths, output, path_level)
|
|
502
|
+
load_f.close()
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
def usage():
|
|
506
|
+
logging.info(
|
|
507
|
+
"gen_intf_rpc_json.py -i <inputfile> -d<mdb_path> -o<outputfile> -c<client> -s<service_json_path>"
|
|
508
|
+
)
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
def count_dir_level(path):
|
|
512
|
+
level = 0
|
|
513
|
+
while True:
|
|
514
|
+
path = os.path.dirname(path)
|
|
515
|
+
if path == '/':
|
|
516
|
+
break
|
|
517
|
+
level += 1
|
|
518
|
+
return level
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
## 匹配APP下的service_json_path目录,如果是扩展组件,层级为3
|
|
522
|
+
def match_level(service_json_path):
|
|
523
|
+
path_level = 0
|
|
524
|
+
match = re.search(r'.*(/[^/]+/mds/.*)', service_json_path)
|
|
525
|
+
if match:
|
|
526
|
+
mds_path = match.group(1)
|
|
527
|
+
path_level = count_dir_level(mds_path)
|
|
528
|
+
return path_level
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
def main(argv):
|
|
532
|
+
m_input = ""
|
|
533
|
+
output = ""
|
|
534
|
+
mdb_path = ""
|
|
535
|
+
service_json_path = ""
|
|
536
|
+
try:
|
|
537
|
+
opts, _ = getopt.getopt(
|
|
538
|
+
argv,
|
|
539
|
+
"hi:o:d:s:p:cx",
|
|
540
|
+
["help", "input=", "out=", "service_json_path=", "ipmi_json_path=", "client", "client_msg"],
|
|
541
|
+
)
|
|
542
|
+
except getopt.GetoptError:
|
|
543
|
+
help()
|
|
544
|
+
return
|
|
545
|
+
for opt, arg in opts:
|
|
546
|
+
if opt in ("-h", "--help"):
|
|
547
|
+
usage()
|
|
548
|
+
return
|
|
549
|
+
elif opt in ("-i", "--input"):
|
|
550
|
+
m_input = arg
|
|
551
|
+
elif opt in ("-o", "--out"):
|
|
552
|
+
output = arg
|
|
553
|
+
elif opt in ("-d", "--dir"):
|
|
554
|
+
mdb_path = arg
|
|
555
|
+
elif opt in ("-s", "--service_json_path"):
|
|
556
|
+
service_json_path = arg
|
|
557
|
+
path_level = match_level(service_json_path)
|
|
558
|
+
if path_level != 2:
|
|
559
|
+
parent_path = os.path.abspath(os.path.join(service_json_path, os.pardir, os.pardir))
|
|
560
|
+
service_json_path = os.path.join(parent_path, "service.json")
|
|
561
|
+
elif opt in ("-p", "--ipmi_json_path"):
|
|
562
|
+
ipmi_json_path = arg
|
|
563
|
+
elif opt in ("-c", "--client"):
|
|
564
|
+
generate_client(m_input, output, mdb_path, service_json_path, path_level)
|
|
565
|
+
return
|
|
566
|
+
else:
|
|
567
|
+
raise RuntimeError("不支持的选项: {}".format(opt))
|
|
568
|
+
if not m_input or not output:
|
|
569
|
+
usage()
|
|
570
|
+
return
|
|
571
|
+
generate_service(m_input, output, service_json_path, ipmi_json_path, path_level)
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
if __name__ == "__main__":
|
|
575
|
+
main(sys.argv[1:])
|