diff --git a/apps/node_man/constants.py b/apps/node_man/constants.py index ff3aef0a1..6d7bd9560 100644 --- a/apps/node_man/constants.py +++ b/apps/node_man/constants.py @@ -78,7 +78,9 @@ class TimeUnit: # 自动选择接入点ID DEFAULT_AP_ID = int(os.environ.get("DEFAULT_AP_ID", -1)) # 自动选择安装通道ID -DEFAULT_INSTALL_CHANNEL_ID = int(os.environ.get("DEFAULT_AP_ID", -1)) +DEFAULT_INSTALL_CHANNEL_ID = int(os.environ.get("DEFAULT_INSTALL_CHANNEL_ID", -1)) +# 自动选择的云区域ID +AUTOMATIC_CHOICE_CLOUD_ID = int(os.environ.get("AUTOMATIC_CHOICE_CLOUD_ID", -1)) # 自动选择 AUTOMATIC_CHOICE = os.environ.get("AUTOMATIC_CHOICE", _("自动选择")) # 默认安装通道 diff --git a/apps/node_man/views/install_channel.py b/apps/node_man/views/install_channel.py index 6a721e632..25bf4c3f0 100644 --- a/apps/node_man/views/install_channel.py +++ b/apps/node_man/views/install_channel.py @@ -40,7 +40,17 @@ def get_queryset(self): def list(self, request, *args, **kwargs): response = super().list(request, *args, **kwargs) - response.data.insert(0, {"id": constants.DEFAULT_INSTALL_CHANNEL_ID, "name": constants.AUTOMATIC_CHOICE}) + response.data.insert( + 0, + { + "id": constants.DEFAULT_INSTALL_CHANNEL_ID, + "name": constants.AUTOMATIC_CHOICE, + "bk_cloud_id": constants.AUTOMATIC_CHOICE_CLOUD_ID, + "jump_servers": [], + "upstream_servers": {}, + "hidden": False, + }, + ) return response @swagger_auto_schema( diff --git a/env/__init__.py b/env/__init__.py index 12dd6144a..f0cd3b853 100644 --- a/env/__init__.py +++ b/env/__init__.py @@ -67,6 +67,9 @@ "BK_NOTICE_ENABLED", # WINDOWS IEOD脚本内容 "BKAPP_IEOD_ACTIVE_FIREWALL_POLICY_SCRIPT_INFO", + # 自动选择安装通道相关配置 + "BKAPP_DEFAULT_INSTALL_CHANNEL_ID", + "BKAPP_AUTOMATIC_CHOICE_CLOUD_ID", ] # =============================================================================== @@ -91,6 +94,8 @@ BKAPP_IEOD_ACTIVE_FIREWALL_POLICY_SCRIPT_INFO = get_type_env( key="BKAPP_IEOD_ACTIVE_FIREWALL_POLICY_SCRIPT_INFO", default="", _type=str ) +BKAPP_DEFAULT_INSTALL_CHANNEL_ID = get_type_env(key="BKAPP_DEFAULT_INSTALL_CHANNEL_ID", default=-1, _type=int) +BKAPP_AUTOMATIC_CHOICE_CLOUD_ID = get_type_env(key="BKAPP_AUTOMATIC_CHOICE_CLOUD_ID", default=-1, _type=int) # =============================================================================== # 日志 diff --git a/support-files/kubernetes/helm/bk-nodeman/README.md b/support-files/kubernetes/helm/bk-nodeman/README.md index c13aeb743..ce463e9cf 100644 --- a/support-files/kubernetes/helm/bk-nodeman/README.md +++ b/support-files/kubernetes/helm/bk-nodeman/README.md @@ -350,6 +350,8 @@ externalRabbitMQ: | `config.bkAppSyncProcStatusTaskInterval` | 插件进程状态同步周期 | `20 * 60` | | `config.bkAppScriptHooks` | Agent安装前置脚本 | `""` | | `config.bkAppIEODActiveFirewallPolicyScriptInfo` | WINDOWS IEOD脚本内容 | `""` | +| `config.bkAppDefaultInstallChannelId` | 自动选择安装通道ID | `-1` | +| `config.bkAppAutomaticChoiceCloudId` | 自动选择安装通道对应云区域ID | `-1` | ## 额外的环境变量 diff --git a/support-files/kubernetes/helm/bk-nodeman/templates/configmaps/env-configmap.yaml b/support-files/kubernetes/helm/bk-nodeman/templates/configmaps/env-configmap.yaml index 5251f7691..648a257b7 100644 --- a/support-files/kubernetes/helm/bk-nodeman/templates/configmaps/env-configmap.yaml +++ b/support-files/kubernetes/helm/bk-nodeman/templates/configmaps/env-configmap.yaml @@ -132,3 +132,5 @@ data: BKAPP_LEGACY_AUTH: "{{ .Values.config.bkAppLegacyAuth }}" BK_NOTICE_ENABLED: "{{ .Values.bkNotice.enabled }}" BKAPP_IEOD_ACTIVE_FIREWALL_POLICY_SCRIPT_INFO: '{{ .Values.config.bkAppIEODActiveFirewallPolicyScriptInfo }}' + BKAPP_DEFAULT_INSTALL_CHANNEL_ID: "{{ .Values.config.bkAppDefaultInstallChannelId}}" + BKAPP_AUTOMATIC_CHOICE_CLOUD_ID: "{{ .Values.config.bkAppAutomaticChoiceCloudId}}" diff --git a/support-files/kubernetes/helm/bk-nodeman/values.yaml b/support-files/kubernetes/helm/bk-nodeman/values.yaml index 38d00c7fa..9da7e9303 100644 --- a/support-files/kubernetes/helm/bk-nodeman/values.yaml +++ b/support-files/kubernetes/helm/bk-nodeman/values.yaml @@ -469,6 +469,10 @@ config: bkAppScriptHooks: "" ## WINDOWS IEOD脚本内容 bkAppIEODActiveFirewallPolicyScriptInfo: "" + ## 自动选择安装通道ID + bkAppDefaultInstallChannelId: -1 + ## 自动选择安装通道对应云区域ID + bkAppAutomaticChoiceCloudId: -1 ## --------------------------------------