diff --git a/apps/backend/subscription/tools.py b/apps/backend/subscription/tools.py index 7f37fbb95..a17198ce3 100644 --- a/apps/backend/subscription/tools.py +++ b/apps/backend/subscription/tools.py @@ -970,6 +970,20 @@ def get_plugin_path(plugin_name: str, target_host: models.Host, agent_config: Di return plugin_path +def get_plugin_common_constants(plugin_name: str) -> Dict: + """ + 获取插件配置公共常量 + https://github.com/TencentBlueKing/bk-nodeman/issues/1500 + :param plugin_name: 插件名称 + """ + common_constants = models.GlobalSettings.get_config( + key=models.GlobalSettings.KeyEnum.PLUGIN_COMMON_CONSTANTS.value, + default={}, + ) + # 返回特定插件是否开启公共常量 + return common_constants.get(plugin_name, {}).update({"global": common_constants.get("global", {})}) + + def get_all_subscription_steps_context( subscription_step: models.SubscriptionStep, instance_info: Dict, @@ -1011,10 +1025,11 @@ def get_all_subscription_steps_context( "inner_ip": target_host.inner_ip, "outer_ip": target_host.outer_ip, "login_ip": target_host.login_ip, - } + }, + # 获取插件配置公共常量 + "constants": get_plugin_common_constants(plugin_name), }, ) - # 深拷贝一份,避免原数据后续被污染 context = copy.deepcopy(context) return context diff --git a/apps/node_man/models.py b/apps/node_man/models.py index e320a150f..c1fe6d1f4 100644 --- a/apps/node_man/models.py +++ b/apps/node_man/models.py @@ -112,6 +112,8 @@ class KeyEnum(Enum): GSE_AGENT2_VERSION = "GSE_AGENT2_VERSION" # 【临时变量】主机安装动作新增推送身份动作, cc版本稳定后废除 ENABLE_PUSH_HOST_IDENTIFIER = "ENABLE_PUSH_HOST_IDENTIFIER" + # 插件配置公共常量支持 issue: https://github.com/TencentBlueKing/bk-nodeman/issues/1500 + PLUGIN_COMMON_CONSTANTS = "PLUGIN_COMMON_CONSTANTS" key = models.CharField(_("键"), max_length=255, db_index=True, primary_key=True) v_json = JSONField(_("值"))