openubmc-bingo 0.5.243__py3-none-any.whl → 0.5.254__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 +1 -1
- bmcgo/bmcgo_config.py +81 -1
- bmcgo/codegen/lua/Makefile +13 -0
- bmcgo/codegen/lua/codegen.py +6 -3
- bmcgo/codegen/lua/script/dto/options.py +1 -0
- bmcgo/codegen/lua/script/{render_utils/factory.py → factory.py} +1 -1
- bmcgo/codegen/lua/script/gen_entry.py +6 -3
- bmcgo/codegen/lua/script/gen_intf_rpc_json.py +12 -0
- bmcgo/codegen/lua/script/gen_schema.py +2 -0
- bmcgo/codegen/lua/script/merge_model.py +10 -3
- bmcgo/codegen/lua/script/render_utils/__init__.py +5 -4
- bmcgo/codegen/lua/script/render_utils/client_lua.py +2 -2
- bmcgo/codegen/lua/script/render_utils/controller_lua.py +2 -2
- bmcgo/codegen/lua/script/render_utils/db_lua.py +2 -2
- bmcgo/codegen/lua/script/render_utils/error_lua.py +2 -2
- bmcgo/codegen/lua/script/render_utils/ipmi_lua.py +2 -2
- bmcgo/codegen/lua/script/render_utils/ipmi_message_lua.py +2 -2
- bmcgo/codegen/lua/script/render_utils/mdb_lua.py +2 -2
- bmcgo/codegen/lua/script/render_utils/message_lua.py +2 -2
- bmcgo/codegen/lua/script/render_utils/messages_lua.py +2 -2
- bmcgo/codegen/lua/script/render_utils/model_lua.py +2 -2
- bmcgo/codegen/lua/script/render_utils/old_model_lua.py +2 -2
- bmcgo/codegen/lua/script/render_utils/plugin_lua.py +2 -2
- bmcgo/codegen/lua/script/render_utils/redfish_proto.py +2 -2
- bmcgo/codegen/lua/script/render_utils/request_lua.py +2 -2
- bmcgo/codegen/lua/script/render_utils/service_lua.py +3 -2
- bmcgo/codegen/lua/script/template.py +5 -1
- bmcgo/codegen/lua/script/utils.py +9 -2
- bmcgo/codegen/lua/templates/Makefile +8 -0
- bmcgo/codegen/lua/templates/apps/Makefile +27 -1
- bmcgo/codegen/lua/templates/apps/controller.lua.mako +20 -4
- bmcgo/codegen/lua/v1/script/gen_schema.py +328 -0
- bmcgo/codegen/lua/v1/script/render_utils/model_lua.py +458 -0
- bmcgo/codegen/lua/v1/templates/apps/model.lua.mako +62 -0
- bmcgo/codegen/lua/v1/templates/apps/service.lua.mako +193 -0
- bmcgo/component/build.py +26 -43
- bmcgo/component/component_helper.py +54 -0
- bmcgo/component/coverage/incremental_cov.py +25 -33
- bmcgo/frame.py +9 -6
- bmcgo/functional/conan_index_build.py +16 -41
- bmcgo/functional/config.py +7 -0
- bmcgo/functional/csr_build.py +313 -88
- bmcgo/functional/diff.py +3 -3
- bmcgo/functional/json_check.py +109 -0
- bmcgo/functional/upgrade.py +31 -1
- bmcgo/misc.py +32 -2
- bmcgo/target/install_sdk.yml +6 -0
- bmcgo/tasks/task.py +69 -43
- bmcgo/tasks/task_build_conan.py +6 -2
- bmcgo/tasks/task_build_wbd_up.py +4 -4
- bmcgo/utils/basic_enums.py +45 -0
- bmcgo/utils/config.py +20 -8
- bmcgo/utils/install_manager.py +75 -20
- bmcgo/utils/installations/base_installer.py +114 -7
- bmcgo/utils/installations/install_consts.py +3 -1
- bmcgo/utils/installations/install_plans/bingo.yml +2 -4
- bmcgo/utils/installations/install_workflow.py +6 -2
- bmcgo/utils/installations/installers/apt_installer.py +58 -136
- bmcgo/utils/installations/installers/pip_installer.py +52 -18
- bmcgo/utils/installations/version_util.py +1 -1
- bmcgo/utils/json_validator.py +241 -0
- {openubmc_bingo-0.5.243.dist-info → openubmc_bingo-0.5.254.dist-info}/METADATA +2 -1
- {openubmc_bingo-0.5.243.dist-info → openubmc_bingo-0.5.254.dist-info}/RECORD +67 -60
- /bmcgo/codegen/lua/script/{render_utils/base.py → base.py} +0 -0
- {openubmc_bingo-0.5.243.dist-info → openubmc_bingo-0.5.254.dist-info}/WHEEL +0 -0
- {openubmc_bingo-0.5.243.dist-info → openubmc_bingo-0.5.254.dist-info}/entry_points.txt +0 -0
- {openubmc_bingo-0.5.243.dist-info → openubmc_bingo-0.5.254.dist-info}/top_level.txt +0 -0
bmcgo/__init__.py
CHANGED
bmcgo/bmcgo_config.py
CHANGED
|
@@ -48,6 +48,44 @@ class BmcgoManifest(object):
|
|
|
48
48
|
self.config = config
|
|
49
49
|
|
|
50
50
|
|
|
51
|
+
class BmcgoHpmServerSign(object):
|
|
52
|
+
def __init__(self, config: configparser.ConfigParser):
|
|
53
|
+
self.config = config
|
|
54
|
+
self.rootca_der = config.get(misc.HPM_SERVER_SIGN, misc.HPM_SIGN_ROOTCA_DER)
|
|
55
|
+
self.cert_id = config.get(misc.HPM_SERVER_SIGN, misc.HPM_SERVER_SIGN_CERT_ID)
|
|
56
|
+
self.url = config.get(misc.HPM_SERVER_SIGN, misc.HPM_SERVER_SIGN_URL)
|
|
57
|
+
self.ssl_verify = config.get(misc.HPM_SERVER_SIGN, misc.HPM_SERVER_SIGN_SSL_VERYFY)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class BmcgoHpmSelfSign(object):
|
|
61
|
+
def __init__(self, config: configparser.ConfigParser):
|
|
62
|
+
self.config = config
|
|
63
|
+
self.rootca_der = config.get(misc.HPM_SELF_SIGN, misc.HPM_SIGN_ROOTCA_DER)
|
|
64
|
+
self.rootca_crl = config.get(misc.HPM_SELF_SIGN, misc.HPM_SELF_SIGN_ROOTCA_CRL)
|
|
65
|
+
self.signer_pem = config.get(misc.HPM_SELF_SIGN, misc.HPM_SELF_SIGN_SIGNER_PEM)
|
|
66
|
+
self.ts_signer_pem = config.get(misc.HPM_SELF_SIGN, misc.HPM_SELF_SIGN_TS_PEM)
|
|
67
|
+
self.ts_signer_cnf = config.get(misc.HPM_SELF_SIGN, misc.HPM_SELF_SIGN_TS_CNF)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class BmcgoE2pServerSign(object):
|
|
71
|
+
def __init__(self, config: configparser.ConfigParser):
|
|
72
|
+
self.config = config
|
|
73
|
+
self.url = config.get(misc.E2P_SERVER_SIGN, misc.E2P_SERVER_SIGN_URL)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class BmcgoE2pSelfSign(object):
|
|
77
|
+
def __init__(self, config: configparser.ConfigParser):
|
|
78
|
+
self.config = config
|
|
79
|
+
self.pem = config.get(misc.E2P_SELF_SIGN, misc.E2P_SELF_SIGN_PEM)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
class BmcgoHpmEncrypt(object):
|
|
83
|
+
def __init__(self, config: configparser.ConfigParser):
|
|
84
|
+
self.config = config
|
|
85
|
+
self.need_encrypt = config.getboolean(misc.HPM_ENCRYPT, misc.HPM_ENCRYPT_ENABLE)
|
|
86
|
+
self.tool_path = shutil.which(misc.HPM_ENCRYPT_TOOL)
|
|
87
|
+
|
|
88
|
+
|
|
51
89
|
class BmcgoConfig(object):
|
|
52
90
|
def __init__(self):
|
|
53
91
|
"""初始化"""
|
|
@@ -55,6 +93,11 @@ class BmcgoConfig(object):
|
|
|
55
93
|
self.conan_index = None
|
|
56
94
|
self.manifest = None
|
|
57
95
|
self.ibmc_sdk = None
|
|
96
|
+
self.hpm_self_sign: BmcgoHpmSelfSign = None
|
|
97
|
+
self.hpm_server_sign: BmcgoHpmServerSign = None
|
|
98
|
+
self.e2p_self_sign: BmcgoE2pSelfSign = None
|
|
99
|
+
self.e2p_server_sign: BmcgoE2pServerSign = None
|
|
100
|
+
self.hpm_encrypt = None
|
|
58
101
|
self.new_frame = False
|
|
59
102
|
self.conan_blacklist = []
|
|
60
103
|
self.bmcgo_path = os.path.dirname(os.path.realpath(__file__))
|
|
@@ -130,7 +173,8 @@ class BmcgoConfig(object):
|
|
|
130
173
|
self.component = BmcgoComp(folder, conf)
|
|
131
174
|
except (NoSectionError, NoOptionError):
|
|
132
175
|
log.debug("不是一个合法的组件仓,尝试查找mds/service.json")
|
|
133
|
-
|
|
176
|
+
|
|
177
|
+
self._bmcgo_signature_config_load(conf)
|
|
134
178
|
|
|
135
179
|
config_file = os.path.join(cwd, "mds", "service.json")
|
|
136
180
|
if self.manifest is None and os.path.isfile(config_file):
|
|
@@ -144,6 +188,9 @@ class BmcgoConfig(object):
|
|
|
144
188
|
self._bmcgo_system_config_load()
|
|
145
189
|
self._bmcgo_global_config_load()
|
|
146
190
|
self._bmcgo_local_config_load()
|
|
191
|
+
self._bmcgo_signature_config_load(self.bmcgo_local_config)
|
|
192
|
+
self._bmcgo_signature_config_load(self.bmcgo_global_config)
|
|
193
|
+
self._bmcgo_signature_config_load(self.bmcgo_system_config)
|
|
147
194
|
|
|
148
195
|
def _bmcgo_system_config_load(self):
|
|
149
196
|
"""读取配置"""
|
|
@@ -169,6 +216,39 @@ class BmcgoConfig(object):
|
|
|
169
216
|
for k, v in self.bmcgo_local_config.items(section):
|
|
170
217
|
self._generate_bmcgo_config(section, k, v)
|
|
171
218
|
|
|
219
|
+
def _bmcgo_signature_config_load(self, conf: configparser.ConfigParser):
|
|
220
|
+
"""解析hpm与eeprom签名加密配置,优先级如下"""
|
|
221
|
+
""".bmcgo/config > local config > global config > system config"""
|
|
222
|
+
try:
|
|
223
|
+
if not self.hpm_self_sign:
|
|
224
|
+
self.hpm_self_sign = BmcgoHpmSelfSign(conf)
|
|
225
|
+
except (NoSectionError, NoOptionError):
|
|
226
|
+
log.debug("未找到hpm自签名配置")
|
|
227
|
+
|
|
228
|
+
try:
|
|
229
|
+
if not self.hpm_server_sign:
|
|
230
|
+
self.hpm_server_sign = BmcgoHpmServerSign(conf)
|
|
231
|
+
except (NoSectionError, NoOptionError):
|
|
232
|
+
log.debug("未找到hpm服务器签名配置")
|
|
233
|
+
|
|
234
|
+
try:
|
|
235
|
+
if not self.e2p_self_sign:
|
|
236
|
+
self.e2p_self_sign = BmcgoE2pSelfSign(conf)
|
|
237
|
+
except (NoSectionError, NoOptionError):
|
|
238
|
+
log.debug("未找到eeprom自签名配置")
|
|
239
|
+
|
|
240
|
+
try:
|
|
241
|
+
if not self.e2p_server_sign:
|
|
242
|
+
self.e2p_server_sign = BmcgoE2pServerSign(conf)
|
|
243
|
+
except (NoSectionError, NoOptionError):
|
|
244
|
+
log.debug("未找到eeprom服务器签名配置")
|
|
245
|
+
|
|
246
|
+
try:
|
|
247
|
+
if not self.hpm_encrypt:
|
|
248
|
+
self.hpm_encrypt = BmcgoHpmEncrypt(conf)
|
|
249
|
+
except (NoSectionError, NoOptionError):
|
|
250
|
+
log.debug("未找到hpm加密配置")
|
|
251
|
+
|
|
172
252
|
def _generate_bmcgo_config(self, section, key, value):
|
|
173
253
|
"""读取配置"""
|
|
174
254
|
if section not in self.bmcgo_config_list:
|
bmcgo/codegen/lua/Makefile
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
DATAMODE_DIR = $(shell pwd)
|
|
2
2
|
SCRIPT_DIR = $(DATAMODE_DIR)/script
|
|
3
|
+
MAJOR_VERIONS_DIR = $(DATAMODE_DIR)/
|
|
3
4
|
|
|
4
5
|
GEN_BIN = $(SCRIPT_DIR)/gen.py
|
|
5
6
|
GEN_DATAS_BIN = $(SCRIPT_DIR)/gen_datas.py
|
|
@@ -25,10 +26,12 @@ protos:
|
|
|
25
26
|
@cd proto && make -j12 \
|
|
26
27
|
PROTO_OUT_DIR=${PROTO_OUT_DIR} \
|
|
27
28
|
SCRIPT_DIR=${SCRIPT_DIR} \
|
|
29
|
+
MAJOR_VERIONS_DIR=${MAJOR_VERIONS_DIR} \
|
|
28
30
|
PROTO_DIR=${PROTO_DIR} \
|
|
29
31
|
JSON_DIR=${JSON_DIR}\
|
|
30
32
|
PROJECT_NAME=${PROJECT_NAME}\
|
|
31
33
|
VERSION=${VERSION} \
|
|
34
|
+
MAJOR_VERSION=${MAJOR_VERSION} \
|
|
32
35
|
|
|
33
36
|
DFT_SERVICE_JSON_EXISTS := $(wildcard ${MDS_DIR}/service.json)
|
|
34
37
|
DFT_MODEL_JSON_EXISTS := $(wildcard ${MDS_DIR}/dft/model.json)
|
|
@@ -38,10 +41,12 @@ dft_protos:
|
|
|
38
41
|
@cd proto && make -j12 \
|
|
39
42
|
PROTO_OUT_DIR=${PROTO_OUT_DIR}/dft \
|
|
40
43
|
SCRIPT_DIR=${SCRIPT_DIR} \
|
|
44
|
+
MAJOR_VERIONS_DIR=${MAJOR_VERIONS_DIR} \
|
|
41
45
|
PROTO_DIR=${PROTO_DIR} \
|
|
42
46
|
JSON_DIR=${JSON_DIR}\
|
|
43
47
|
PROJECT_NAME=${PROJECT_NAME}\
|
|
44
48
|
VERSION=${VERSION} \
|
|
49
|
+
MAJOR_VERSION=${MAJOR_VERSION} \
|
|
45
50
|
|
|
46
51
|
else
|
|
47
52
|
dft_protos:
|
|
@@ -55,10 +60,12 @@ debug_protos:
|
|
|
55
60
|
@cd proto && make -j12 \
|
|
56
61
|
PROTO_OUT_DIR=${PROTO_OUT_DIR}/debug \
|
|
57
62
|
SCRIPT_DIR=${SCRIPT_DIR} \
|
|
63
|
+
MAJOR_VERIONS_DIR=${MAJOR_VERIONS_DIR} \
|
|
58
64
|
PROTO_DIR=${PROTO_DIR} \
|
|
59
65
|
JSON_DIR=${JSON_DIR}\
|
|
60
66
|
PROJECT_NAME=${PROJECT_NAME}\
|
|
61
67
|
VERSION=${VERSION} \
|
|
68
|
+
MAJOR_VERSION=${MAJOR_VERSION} \
|
|
62
69
|
|
|
63
70
|
else
|
|
64
71
|
debug_protos:
|
|
@@ -69,9 +76,11 @@ gen: protos dft_protos debug_protos
|
|
|
69
76
|
PROTO_OUT_DIR=${PROTO_OUT_DIR} \
|
|
70
77
|
GENERATE_OUT_DIR=${GENERATE_OUT_DIR} \
|
|
71
78
|
SCRIPT_DIR=${SCRIPT_DIR} \
|
|
79
|
+
MAJOR_VERIONS_DIR=${MAJOR_VERIONS_DIR} \
|
|
72
80
|
PROTO_DIR=${PROTO_DIR} \
|
|
73
81
|
PROJECT_NAME=${PROJECT_NAME} \
|
|
74
82
|
VERSION=${VERSION} \
|
|
83
|
+
MAJOR_VERSION=${MAJOR_VERSION} \
|
|
75
84
|
RESTAPI_DIRS="${RESTAPI_DIRS}" \
|
|
76
85
|
MDS_DIR=${MDS_DIR}\
|
|
77
86
|
CONF_DIR=${CONF_DIR}\
|
|
@@ -83,9 +92,11 @@ mdb: protos
|
|
|
83
92
|
PROTO_OUT_DIR=${PROTO_OUT_DIR} \
|
|
84
93
|
GENERATE_OUT_DIR=${GENERATE_OUT_DIR} \
|
|
85
94
|
SCRIPT_DIR=${SCRIPT_DIR} \
|
|
95
|
+
MAJOR_VERIONS_DIR=${MAJOR_VERIONS_DIR} \
|
|
86
96
|
PROTO_DIR=${PROTO_DIR} \
|
|
87
97
|
PROJECT_NAME=${PROJECT_NAME} \
|
|
88
98
|
VERSION=${VERSION} \
|
|
99
|
+
MAJOR_VERSION=${MAJOR_VERSION} \
|
|
89
100
|
mdb
|
|
90
101
|
|
|
91
102
|
messages: protos
|
|
@@ -93,9 +104,11 @@ messages: protos
|
|
|
93
104
|
PROTO_OUT_DIR=${PROTO_OUT_DIR} \
|
|
94
105
|
GENERATE_OUT_DIR=${GENERATE_OUT_DIR} \
|
|
95
106
|
SCRIPT_DIR=${SCRIPT_DIR} \
|
|
107
|
+
MAJOR_VERIONS_DIR=${MAJOR_VERIONS_DIR} \
|
|
96
108
|
PROTO_DIR=${PROTO_DIR} \
|
|
97
109
|
PROJECT_NAME=${PROJECT_NAME} \
|
|
98
110
|
VERSION=${VERSION} \
|
|
111
|
+
MAJOR_VERSION=${MAJOR_VERSION} \
|
|
99
112
|
BUILD_DIR=${BUILD_DIR} \
|
|
100
113
|
messages
|
|
101
114
|
|
bmcgo/codegen/lua/codegen.py
CHANGED
|
@@ -22,11 +22,12 @@ cwd = os.path.split(os.path.realpath(__file__))[0]
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
class CodeGen(object):
|
|
25
|
-
def __init__(self, project_dir, version, remote):
|
|
25
|
+
def __init__(self, project_dir, version, remote, major_version=0):
|
|
26
26
|
self.gen_tool_dir = os.path.join(project_dir, 'temp/lua_codegen')
|
|
27
27
|
self.project_dir = project_dir
|
|
28
28
|
self.project_name = self.get_project_name()
|
|
29
29
|
self.version = version
|
|
30
|
+
self.major_version = major_version
|
|
30
31
|
self.remote = remote
|
|
31
32
|
|
|
32
33
|
def read_service_json(self):
|
|
@@ -143,9 +144,10 @@ class CodeGen(object):
|
|
|
143
144
|
lua_format = self.get_lua_format()
|
|
144
145
|
cmd = [
|
|
145
146
|
"/usr/bin/make", "-j12", f"PROJECT_NAME={self.project_name}", f"TPL_DIR={self.gen_tool_dir}",
|
|
146
|
-
f"VERSION={self.version}", "gen"
|
|
147
|
+
f"VERSION={self.version}", f"MAJOR_VERSION={self.major_version}", "gen"
|
|
147
148
|
]
|
|
148
149
|
subprocess.run(cmd, env=dict(os.environ, LUA_FORMAT=lua_format, LUA_CODEGEN_VERSION=str(self.version),
|
|
150
|
+
MAJOR_VERSION=str(self.major_version),
|
|
149
151
|
PROJECT_NAME=self.project_name), check=True)
|
|
150
152
|
if args.with_template:
|
|
151
153
|
script_path = os.path.join(cwd, 'script', 'gen_entry.py')
|
|
@@ -153,7 +155,8 @@ class CodeGen(object):
|
|
|
153
155
|
model_path = os.path.join(self.gen_tool_dir, self.project_name, '_model.json')
|
|
154
156
|
ipmi_path = os.path.join(self.project_dir, 'mds', 'ipmi.json')
|
|
155
157
|
subprocess.run(["/usr/bin/python3", script_path, "-i", ipmi_path, "-m", model_path, "-o", self.project_dir,
|
|
156
|
-
"-n", self.project_name, "-f", lua_format, "-t", mako_dir, "-v", self.version],
|
|
158
|
+
"-n", self.project_name, "-f", lua_format, "-t", mako_dir, "-v", self.version, "-p", self.major_version],
|
|
159
|
+
check=True)
|
|
157
160
|
|
|
158
161
|
def gen(self, args):
|
|
159
162
|
check_cmd_file = os.path.join(self.project_dir, 'temp/lua_codegen/temp/check_cmd.json')
|
|
@@ -21,6 +21,7 @@ class Options:
|
|
|
21
21
|
self.enable_auto_merge: bool = options.enable_auto_merge
|
|
22
22
|
self.project_name = options.project_name
|
|
23
23
|
self.version = options.version
|
|
24
|
+
self.major_version = options.major_version
|
|
24
25
|
self.proto_root_path = os.path.normpath(options.proto_root_path)
|
|
25
26
|
self.proto_json_root_path = os.path.normpath(
|
|
26
27
|
options.proto_json_root_path)
|
|
@@ -132,7 +132,8 @@ def template_render(options, template_path, output_file_path, class_name="", dra
|
|
|
132
132
|
make_header=header,
|
|
133
133
|
project_name=options[APP_NAME],
|
|
134
134
|
class_name=class_name,
|
|
135
|
-
render_utils=Utils
|
|
135
|
+
render_utils=Utils,
|
|
136
|
+
major_version=options["major_version"]
|
|
136
137
|
))
|
|
137
138
|
output_file.write(render_data)
|
|
138
139
|
output_file.close()
|
|
@@ -217,8 +218,8 @@ def main(argv):
|
|
|
217
218
|
logging.getLogger().setLevel(logging.INFO)
|
|
218
219
|
options = dict()
|
|
219
220
|
try:
|
|
220
|
-
opts, _ = getopt.getopt(argv, "hi:m:o:n:f:t:", ["help", "ipmi=", "model=",
|
|
221
|
-
"out=", "name=", "formatter=", "template"])
|
|
221
|
+
opts, _ = getopt.getopt(argv, "hi:m:o:n:f:t:v:p:", ["help", "ipmi=", "model=",
|
|
222
|
+
"out=", "name=", "formatter=", "template=", "version=", "major_version="])
|
|
222
223
|
except getopt.GetoptError as getopt_error:
|
|
223
224
|
logging.error(getopt_error)
|
|
224
225
|
return
|
|
@@ -240,6 +241,8 @@ def main(argv):
|
|
|
240
241
|
options['template_dir'] = arg
|
|
241
242
|
elif opt in ("-v", "--version"):
|
|
242
243
|
options['version'] = arg
|
|
244
|
+
elif opt in ("-p", "--major_version"):
|
|
245
|
+
options['major_version'] = arg
|
|
243
246
|
else:
|
|
244
247
|
raise RuntimeError("不支持的选项: {}".format(opt))
|
|
245
248
|
required_keys = {
|
|
@@ -18,6 +18,7 @@ import os
|
|
|
18
18
|
import re
|
|
19
19
|
import mds_util as utils
|
|
20
20
|
from utils import Utils
|
|
21
|
+
from bmcgo.utils.tools import Tools
|
|
21
22
|
|
|
22
23
|
PROP_PRIORITY = "priority"
|
|
23
24
|
PROP_LOCAL = "LocalPer"
|
|
@@ -33,6 +34,10 @@ PATH = "path"
|
|
|
33
34
|
PATHS = "paths"
|
|
34
35
|
DEFS = "defs"
|
|
35
36
|
ITEMS = ["dep_properties", "dep_methods", "dep_signals"]
|
|
37
|
+
DEPRECATED = "deprecated"
|
|
38
|
+
|
|
39
|
+
tool = Tools()
|
|
40
|
+
log = tool.log
|
|
36
41
|
|
|
37
42
|
|
|
38
43
|
class InterfaceDep:
|
|
@@ -179,6 +184,8 @@ def generate_interface(class_name, intf_data, interfaces, intf, class_path):
|
|
|
179
184
|
interface = class_name + intf_class
|
|
180
185
|
if check_interface_duplicate(interfaces, interface, intf, intf_data):
|
|
181
186
|
return
|
|
187
|
+
if intf_data.get(DEPRECATED, False):
|
|
188
|
+
log.warning(f"在service.json中配置了已废弃的依赖项, interface: {intf}")
|
|
182
189
|
|
|
183
190
|
for item in ITEMS:
|
|
184
191
|
values = intf_data.get(item, [])
|
|
@@ -190,6 +197,8 @@ def generate_interface(class_name, intf_data, interfaces, intf, class_path):
|
|
|
190
197
|
for value in values:
|
|
191
198
|
if not intf_data.get(item[4:], {}).get(value, {}):
|
|
192
199
|
raise Exception(f"在service.json中配置了不存在的依赖项, interface: {intf}, item: {value}")
|
|
200
|
+
if intf_data.get(item[4:], {}).get(value, {}).get(DEPRECATED, False):
|
|
201
|
+
log.warning(f"在service.json中配置了已废弃的依赖项, interface: {intf}, item: {value}")
|
|
193
202
|
|
|
194
203
|
|
|
195
204
|
interface_data = {
|
|
@@ -445,6 +454,9 @@ def generate_only_interface(intf_dep: InterfaceDep, service, imports, mdb_path):
|
|
|
445
454
|
|
|
446
455
|
def fill_client_intf(service, imports, mdb_path, required, path):
|
|
447
456
|
intf_dep = InterfaceDep(required)
|
|
457
|
+
intf_seg = (intf_dep.name).split('.')
|
|
458
|
+
if len(intf_seg) >= 3 and intf_seg[2] == 'Debug':
|
|
459
|
+
raise Exception(f"在service.json中配置了调试版本的依赖项, interface: {intf_dep.name}")
|
|
448
460
|
if path != "*":
|
|
449
461
|
class_name, path_json = utils.get_path_by_interface(mdb_path, required["interface"], path)
|
|
450
462
|
generate_path_interface(
|
|
@@ -82,6 +82,8 @@ def read_properties(properties, out_properties, is_intf_props):
|
|
|
82
82
|
# filter properties which no need for csr
|
|
83
83
|
prop_alias = prop
|
|
84
84
|
if not is_usage_csr(properties[prop]):
|
|
85
|
+
prop_alias = properties[prop].pop("alias", prop)
|
|
86
|
+
props[index] = prop_alias
|
|
85
87
|
continue
|
|
86
88
|
# if prop have alias, use alias name replace prop name
|
|
87
89
|
if "alias" in properties[prop] and Utils.get_lua_codegen_version() >= 13:
|
|
@@ -27,6 +27,7 @@ log = tool.log
|
|
|
27
27
|
OPTIONS_SETTING = ["explicit", "volatile"]
|
|
28
28
|
CHECK_PROPS_SETTINGS = ["usage", "alias", "primaryKey", "uniqueKey", "privilege", "default", "featureTag", "critical",
|
|
29
29
|
"notAllowNull", "refInterface", "displayDescription", "sensitive"]
|
|
30
|
+
DEPRECATED = "deprecated"
|
|
30
31
|
|
|
31
32
|
|
|
32
33
|
def save_file(of_name, model_new):
|
|
@@ -40,9 +41,9 @@ def save_file(of_name, model_new):
|
|
|
40
41
|
os.open(
|
|
41
42
|
of_name, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, stat.S_IWUSR | stat.S_IRUSR
|
|
42
43
|
),
|
|
43
|
-
"w",
|
|
44
|
+
"w", encoding="utf-8"
|
|
44
45
|
) as load_f:
|
|
45
|
-
json.dump(model_new, load_f, indent=4)
|
|
46
|
+
json.dump(model_new, load_f, ensure_ascii=False, indent=4)
|
|
46
47
|
logging.info("schema 已经更改")
|
|
47
48
|
|
|
48
49
|
|
|
@@ -123,9 +124,11 @@ def merge_when_intf_exist(model, intf, item, class_name, intf_name):
|
|
|
123
124
|
|
|
124
125
|
properties = model[item]
|
|
125
126
|
for prop in list(properties):
|
|
127
|
+
label = "方法" if item == "methods" else "信号"
|
|
126
128
|
if prop in intf[item]:
|
|
129
|
+
if intf[item][prop].get(DEPRECATED, False):
|
|
130
|
+
log.warning(f"model.json中类{class_name}接口{intf_name}的{label}{prop}已废弃")
|
|
127
131
|
continue
|
|
128
|
-
label = "方法" if item == "methods" else "信号"
|
|
129
132
|
raise RuntimeError(f"model.json中类{class_name}接口{intf_name}的{label}{prop}在mdb_interface中没有被定义")
|
|
130
133
|
|
|
131
134
|
intf_info = {"class_name": class_name, "intf_name": intf_name}
|
|
@@ -146,6 +149,8 @@ def merge_model_intf(intf_data, model_intf, class_name, intf_name):
|
|
|
146
149
|
for prop in model_props.keys():
|
|
147
150
|
if prop not in mdb_props:
|
|
148
151
|
raise RuntimeError(f"model.json中类{class_name}接口{intf_name}的属性{prop}在mdb_interface中没有被定义")
|
|
152
|
+
if mdb_props[prop].get(DEPRECATED, False):
|
|
153
|
+
log.warning(f"model.json中类{class_name}接口{intf_name}的属性{prop}已废弃")
|
|
149
154
|
if mdb_props and "virtual" in intf_data:
|
|
150
155
|
model_props["priority"] = {
|
|
151
156
|
"baseType": "U8",
|
|
@@ -179,6 +184,8 @@ def merge_model_class(class_name, mds_class, mdb_obj, mdb_path):
|
|
|
179
184
|
for intf_name in mdb_obj[class_name]["interfaces"]:
|
|
180
185
|
if intf_name not in mds_class["interfaces"]:
|
|
181
186
|
raise RuntimeError(f"model.json中类{class_name}未配置资源树接口{intf_name}")
|
|
187
|
+
if mds_class["interfaces"][intf_name].get(DEPRECATED, False):
|
|
188
|
+
log.warning(f"model.json中类{class_name}配置了已废弃的资源数接口{intf_name}")
|
|
182
189
|
for item in mds_class["interfaces"][intf_name]:
|
|
183
190
|
if item not in ["properties", "methods", "signals", "privilege"]:
|
|
184
191
|
raise RuntimeError(f"model.json中类{class_name}接口{intf_name}的字段{item}超出取值范围")
|
|
@@ -12,17 +12,15 @@
|
|
|
12
12
|
|
|
13
13
|
__all__ = [
|
|
14
14
|
'Base', 'Factory', 'RequestLuaUtils', 'ControllerLuaUtils', 'IpmiMessageUtils', 'MessageUtils',
|
|
15
|
-
'UtilsMessageLua', 'ErrorLuaUtils', 'ClientLuaUtils',
|
|
15
|
+
'UtilsMessageLua', 'ErrorLuaUtils', 'ClientLuaUtils', "ConsistencyModelLuaUtils",
|
|
16
16
|
'DbLuaUtils', 'IpmiLuaUtils', 'RedfishProtoUtils', 'ServicesUtils',
|
|
17
17
|
'MdbLuaUtils', 'OldModelLuaUtils', 'ModelLuaUtils', "MdbRegister", 'MessagesLuaUtils', 'PluginLuaUtils'
|
|
18
18
|
]
|
|
19
19
|
|
|
20
|
-
from render_utils.base import Base
|
|
21
20
|
from render_utils.client_lua import ClientLuaUtils
|
|
22
21
|
from render_utils.controller_lua import ControllerLuaUtils
|
|
23
22
|
from render_utils.db_lua import DbLuaUtils
|
|
24
23
|
from render_utils.error_lua import ErrorLuaUtils
|
|
25
|
-
from render_utils.factory import Factory
|
|
26
24
|
from render_utils.ipmi_lua import IpmiLuaUtils
|
|
27
25
|
from render_utils.ipmi_message_lua import IpmiMessageUtils
|
|
28
26
|
from render_utils.mdb_lua import MdbLuaUtils
|
|
@@ -35,4 +33,7 @@ from render_utils.old_model_lua import OldModelLuaUtils
|
|
|
35
33
|
from render_utils.model_lua import ModelLuaUtils
|
|
36
34
|
from render_utils.mdb_register import MdbRegister
|
|
37
35
|
from render_utils.messages_lua import MessagesLuaUtils
|
|
38
|
-
from render_utils.plugin_lua import PluginLuaUtils
|
|
36
|
+
from render_utils.plugin_lua import PluginLuaUtils
|
|
37
|
+
from bmcgo.codegen.lua.script.base import Base
|
|
38
|
+
from bmcgo.codegen.lua.script.factory import Factory
|
|
39
|
+
from bmcgo.codegen.lua.v1.script.render_utils.model_lua import ConsistencyModelLuaUtils
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
|
|
13
13
|
from utils import Utils
|
|
14
14
|
from dto.options import Options
|
|
15
|
-
from render_utils.base import Base
|
|
16
|
-
from render_utils.factory import Factory
|
|
17
15
|
from render_utils.mdb_register import MdbRegister
|
|
16
|
+
from bmcgo.codegen.lua.script.base import Base
|
|
17
|
+
from bmcgo.codegen.lua.script.factory import Factory
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
class ClientLuaUtils(Base, Utils, MdbRegister):
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
# See the Mulan PSL v2 for more details.
|
|
12
12
|
|
|
13
13
|
from dto.options import Options
|
|
14
|
-
from render_utils.base import Base
|
|
15
|
-
from render_utils.factory import Factory
|
|
16
14
|
from render_utils.utils_message_lua import UtilsMessageLua
|
|
17
15
|
from render_utils.validate_lua import ValidateLua
|
|
16
|
+
from bmcgo.codegen.lua.script.base import Base
|
|
17
|
+
from bmcgo.codegen.lua.script.factory import Factory
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
class ControllerLuaUtils(Base, ValidateLua, UtilsMessageLua):
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
import json
|
|
14
14
|
from utils import Utils
|
|
15
15
|
from dto.options import Options
|
|
16
|
-
from
|
|
17
|
-
from
|
|
16
|
+
from bmcgo.codegen.lua.script.base import Base
|
|
17
|
+
from bmcgo.codegen.lua.script.factory import Factory
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
class DbLuaUtils(Base, Utils):
|
|
@@ -14,8 +14,8 @@ import re
|
|
|
14
14
|
|
|
15
15
|
from utils import Utils
|
|
16
16
|
from dto.options import Options
|
|
17
|
-
from
|
|
18
|
-
from
|
|
17
|
+
from bmcgo.codegen.lua.script.base import Base
|
|
18
|
+
from bmcgo.codegen.lua.script.factory import Factory
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
class ErrorLuaUtils(Base, Utils):
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
# See the Mulan PSL v2 for more details.
|
|
12
12
|
|
|
13
13
|
from dto.options import Options
|
|
14
|
-
from
|
|
15
|
-
from
|
|
14
|
+
from bmcgo.codegen.lua.script.base import Base
|
|
15
|
+
from bmcgo.codegen.lua.script.factory import Factory
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
class IpmiLuaUtils(Base):
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
# See the Mulan PSL v2 for more details.
|
|
12
12
|
|
|
13
13
|
from dto.options import Options
|
|
14
|
-
from render_utils.base import Base
|
|
15
|
-
from render_utils.factory import Factory
|
|
16
14
|
from render_utils.utils_message_lua import UtilsMessageLua
|
|
17
15
|
from render_utils.validate_lua import ValidateLua
|
|
16
|
+
from bmcgo.codegen.lua.script.base import Base
|
|
17
|
+
from bmcgo.codegen.lua.script.factory import Factory
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
class IpmiMessageUtils(Base, ValidateLua, UtilsMessageLua):
|
|
@@ -14,10 +14,10 @@ import re
|
|
|
14
14
|
|
|
15
15
|
from utils import Utils
|
|
16
16
|
from dto.options import Options
|
|
17
|
-
from render_utils.base import Base
|
|
18
|
-
from render_utils.factory import Factory
|
|
19
17
|
from render_utils.utils_message_lua import UtilsMessageLua
|
|
20
18
|
from render_utils.validate_lua import ValidateLua
|
|
19
|
+
from bmcgo.codegen.lua.script.base import Base
|
|
20
|
+
from bmcgo.codegen.lua.script.factory import Factory
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
class MdbLuaUtils(Base, ValidateLua, UtilsMessageLua):
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
# See the Mulan PSL v2 for more details.
|
|
12
12
|
|
|
13
13
|
from dto.options import Options
|
|
14
|
-
from render_utils.base import Base
|
|
15
|
-
from render_utils.factory import Factory
|
|
16
14
|
from render_utils.utils_message_lua import UtilsMessageLua
|
|
17
15
|
from render_utils.validate_lua import ValidateLua
|
|
18
16
|
from render_utils.mdb_register import MdbRegister
|
|
17
|
+
from bmcgo.codegen.lua.script.base import Base
|
|
18
|
+
from bmcgo.codegen.lua.script.factory import Factory
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
class MessageUtils(Base, ValidateLua, UtilsMessageLua, MdbRegister):
|
|
@@ -14,8 +14,8 @@ import re
|
|
|
14
14
|
|
|
15
15
|
from utils import Utils
|
|
16
16
|
from dto.options import Options
|
|
17
|
-
from
|
|
18
|
-
from
|
|
17
|
+
from bmcgo.codegen.lua.script.base import Base
|
|
18
|
+
from bmcgo.codegen.lua.script.factory import Factory
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
class MessagesLuaUtils(Base, Utils):
|
|
@@ -14,8 +14,8 @@ import re
|
|
|
14
14
|
|
|
15
15
|
from utils import Utils
|
|
16
16
|
from dto.options import Options
|
|
17
|
-
from
|
|
18
|
-
from
|
|
17
|
+
from bmcgo.codegen.lua.script.base import Base
|
|
18
|
+
from bmcgo.codegen.lua.script.factory import Factory
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
BASE_TYPE = "baseType"
|
|
@@ -14,8 +14,8 @@ import re
|
|
|
14
14
|
|
|
15
15
|
from utils import Utils
|
|
16
16
|
from dto.options import Options
|
|
17
|
-
from
|
|
18
|
-
from
|
|
17
|
+
from bmcgo.codegen.lua.script.base import Base
|
|
18
|
+
from bmcgo.codegen.lua.script.factory import Factory
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
BASE_TYPE = "baseType"
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
|
|
13
13
|
from utils import Utils
|
|
14
14
|
from dto.options import Options
|
|
15
|
-
from
|
|
16
|
-
from
|
|
15
|
+
from bmcgo.codegen.lua.script.base import Base
|
|
16
|
+
from bmcgo.codegen.lua.script.factory import Factory
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
class PluginLuaUtils(Base, Utils):
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
|
|
13
13
|
import merge_proto_algo
|
|
14
14
|
from dto.options import Options
|
|
15
|
-
from
|
|
16
|
-
from
|
|
15
|
+
from bmcgo.codegen.lua.script.base import Base
|
|
16
|
+
from bmcgo.codegen.lua.script.factory import Factory
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
class RedfishProtoUtils(Base):
|
|
@@ -20,8 +20,8 @@ from dto.redfish_api import MessageSchemaMgr, MessageSchema, Property
|
|
|
20
20
|
from dto.url_route import UrlRouteDict
|
|
21
21
|
from loader import kepler_abstract_loader
|
|
22
22
|
from loader.redfish_loader import RedfishLoader
|
|
23
|
-
from
|
|
24
|
-
from
|
|
23
|
+
from bmcgo.codegen.lua.script.factory import Factory
|
|
24
|
+
from bmcgo.codegen.lua.script.base import Base
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
class RequestLua:
|
|
@@ -14,10 +14,10 @@ import os
|
|
|
14
14
|
import re
|
|
15
15
|
from utils import Utils
|
|
16
16
|
from dto.options import Options
|
|
17
|
-
from render_utils.base import Base
|
|
18
|
-
from render_utils.factory import Factory
|
|
19
17
|
from render_utils.validate_lua import ValidateLua
|
|
20
18
|
from render_utils.mdb_register import MdbRegister
|
|
19
|
+
from bmcgo.codegen.lua.script.base import Base
|
|
20
|
+
from bmcgo.codegen.lua.script.factory import Factory
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
class ServicesUtils(Base, ValidateLua, Utils, MdbRegister):
|
|
@@ -128,3 +128,4 @@ class ServicesUtils(Base, ValidateLua, Utils, MdbRegister):
|
|
|
128
128
|
|
|
129
129
|
|
|
130
130
|
Factory().register("service.lua.mako", ServicesUtils)
|
|
131
|
+
Factory().register("v1/templates/apps/service.lua.mako", ServicesUtils)
|
|
@@ -46,6 +46,9 @@ def parse_input_args() -> Options:
|
|
|
46
46
|
parser.add_argument("-n", "--project_name", dest="project_name",
|
|
47
47
|
help="project name",
|
|
48
48
|
default="")
|
|
49
|
+
parser.add_argument("-p", "--major_version", dest="major_version",
|
|
50
|
+
help="major version",
|
|
51
|
+
default="")
|
|
49
52
|
parser.add_argument("-v", "--version", dest="version",
|
|
50
53
|
help="version",
|
|
51
54
|
default=-1)
|
|
@@ -122,7 +125,7 @@ def generate(options: Options):
|
|
|
122
125
|
|
|
123
126
|
header = utils.Utils(data, options).make_header(
|
|
124
127
|
options.template_name, options.output_file_path)
|
|
125
|
-
lookup = TemplateLookup(directories=[os.getcwd() + "/"], input_encoding='utf-8')
|
|
128
|
+
lookup = TemplateLookup(directories=[os.getcwd() + "/", os.getcwd() + "/../../"], input_encoding='utf-8')
|
|
126
129
|
template = lookup.get_template(options.template_name)
|
|
127
130
|
if os.path.exists(options.output_file_path):
|
|
128
131
|
os.remove(options.output_file_path)
|
|
@@ -144,6 +147,7 @@ def generate(options: Options):
|
|
|
144
147
|
load_import=make_load_import(data, options),
|
|
145
148
|
project_name=options.project_name,
|
|
146
149
|
version=options.version,
|
|
150
|
+
major_version=options.major_version,
|
|
147
151
|
use_frame_log=use_frame_log,
|
|
148
152
|
))
|
|
149
153
|
output_file.write(render_data)
|