From 5030f1ebb790b39049eed21cec5effe7f920161d Mon Sep 17 00:00:00 2001 From: dcd <1151627903@qq.com> Date: Tue, 10 Sep 2024 14:25:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=89=E8=A3=85=E9=80=9A=E9=81=93list?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=95=B0=E6=8D=AE=E7=BB=93=E6=9E=84=E8=A7=84?= =?UTF-8?q?=E8=8C=83=20(closed=20#2430)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/node_man/constants.py | 4 +++- apps/node_man/views/install_channel.py | 12 +++++++++++- env/__init__.py | 5 +++++ support-files/kubernetes/helm/bk-nodeman/README.md | 2 ++ .../templates/configmaps/env-configmap.yaml | 2 ++ support-files/kubernetes/helm/bk-nodeman/values.yaml | 4 ++++ 6 files changed, 27 insertions(+), 2 deletions(-) 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 ## --------------------------------------