From b750713045a5d8131dd23ce56a3321baa0089084 Mon Sep 17 00:00:00 2001 From: v_gqpgguo Date: Thu, 22 Aug 2024 15:37:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20windows=E5=AE=89=E8=A3=85agent=E5=87=BA?= =?UTF-8?q?=E7=8E=B0ieod=E8=84=9A=E6=9C=AC=E5=90=8C=E6=97=B6curl=E5=92=8C?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=20(closed=20#2409)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../collections/agent_new/test_install.py | 42 +------------------ apps/core/script_manage/data.py | 2 + env/__init__.py | 5 +++ .../kubernetes/helm/bk-nodeman/README.md | 1 + .../templates/configmaps/env-configmap.yaml | 1 + .../kubernetes/helm/bk-nodeman/values.yaml | 2 + 6 files changed, 12 insertions(+), 41 deletions(-) diff --git a/apps/backend/tests/components/collections/agent_new/test_install.py b/apps/backend/tests/components/collections/agent_new/test_install.py index 65a45300c..bfd7b131b 100644 --- a/apps/backend/tests/components/collections/agent_new/test_install.py +++ b/apps/backend/tests/components/collections/agent_new/test_install.py @@ -32,16 +32,12 @@ from apps.core.remote import exceptions from apps.core.remote.tests import base from apps.core.remote.tests.base import AsyncMockConn -from apps.core.script_manage.data import ( - IEOD_ACTIVE_FIREWALL_POLICY_SCRIPT_INFO, - JUMP_SERVER_POLICY_SCRIPT_INFO, -) +from apps.core.script_manage.data import JUMP_SERVER_POLICY_SCRIPT_INFO from apps.core.script_manage.handlers import ScriptManageHandler from apps.exceptions import ApiResultError from apps.mock_data import api_mkd, common_unit from apps.mock_data import utils as mock_data_utils from apps.node_man import constants, models -from apps.node_man.models import GlobalSettings from env.constants import GseVersion from pipeline.component_framework.test import ( ComponentTestCase, @@ -1183,7 +1179,6 @@ def init_mock_clients(self): class WindowsActiveFirewallPolicyInDirectAreaTestCase(InstallWindowsWithScriptHooksTestCase): def adjust_db(self): - GlobalSettings.objects.filter(key=GlobalSettings.KeyEnum.AGENT_INSTALL_SCRIPT_HOOK_CONTENT.value).delete() sub_step_obj: models.SubscriptionStep = self.obj_factory.sub_step_objs[0] sub_step_obj.params.update( { @@ -1226,41 +1221,6 @@ def test_batch_solution(self): ) -class ActiveFirewallAddConfigTestCase(WindowsActiveFirewallPolicyInDirectAreaTestCase): - def adjust_db(self): - super().adjust_db() - GlobalSettings.set_config( - GlobalSettings.KeyEnum.AGENT_INSTALL_SCRIPT_HOOK_CONTENT.value, - {IEOD_ACTIVE_FIREWALL_POLICY_SCRIPT_INFO.name: "test"}, - ) - - def test_batch_solution(self): - host, script_hook_objs, installation_tool, solution_parse_result = self.build_solution_result( - script_hooks=[{"name": "ieod_active_firewall_policy"}] - ) - - self.assertEqual( - constants.AgentWindowsDependencies.list_member_values() + ["setup_agent.bat"], - solution_parse_result["dependencies"], - ) - self.assertEqual( - solution_parse_result["cmds"], - [ - # 一:创建临时目录 - f"mkdir {installation_tool.dest_dir}", - # 二:执行ieod_active_firewall_policy - "test", - # 三:执行安装脚本 - f"{installation_tool.dest_dir}setup_agent.bat" - f" -O 48668 -E 58925 -A 58625 -V 58930 -B 10020 -S 60020 -Z 60030 -K 10030" - f' -e "127.0.0.1" -a "127.0.0.1" -k "127.0.0.1"' - f" -l http://127.0.0.1/download -r http://127.0.0.1/backend" - f" -i 0 -I {host.inner_ip} -T C:\\tmp\\ -p c:\\gse" - f" -c {solution_parse_result['params']['token']} -s {mock_data_utils.JOB_TASK_PIPELINE_ID} -N SERVER", - ], - ) - - class WindowsActiveFirewallPolicyNotInDirectAreaTestCase(WindowsActiveFirewallPolicyInDirectAreaTestCase): def adjust_db(self): super().adjust_db() diff --git a/apps/core/script_manage/data.py b/apps/core/script_manage/data.py index 058a5df0d..d788ff6d5 100644 --- a/apps/core/script_manage/data.py +++ b/apps/core/script_manage/data.py @@ -13,6 +13,7 @@ from django.utils.translation import ugettext_lazy as _ +import env from apps.node_man import constants as node_man_constants from ...node_man.constants import DEFAULT_CLOUD @@ -40,6 +41,7 @@ filename="ieod_active_firewall_policy.bat", path="script_manage_tmp/ieod_active_firewall_policy.bat", description=_("IDC Windows 物理机安装策略开通"), + oneline=env.BKAPP_IEOD_ACTIVE_FIREWALL_POLICY_SCRIPT_INFO, support_os_list=[node_man_constants.OsType.WINDOWS], support_cloud_id=DEFAULT_CLOUD, ) diff --git a/env/__init__.py b/env/__init__.py index 933c55b5b..12dd6144a 100644 --- a/env/__init__.py +++ b/env/__init__.py @@ -65,6 +65,8 @@ "BKPAAS_SHARED_RES_URL", "BKAPP_LEGACY_AUTH", "BK_NOTICE_ENABLED", + # WINDOWS IEOD脚本内容 + "BKAPP_IEOD_ACTIVE_FIREWALL_POLICY_SCRIPT_INFO", ] # =============================================================================== @@ -86,6 +88,9 @@ key="BKAPP_SYNC_PROC_STATUS_TASK_INTERVAL", default=20 * 60, _type=int ) BKAPP_SCRIPT_HOOKS = get_type_env(key="BKAPP_SCRIPT_HOOKS", default="", _type=str) +BKAPP_IEOD_ACTIVE_FIREWALL_POLICY_SCRIPT_INFO = get_type_env( + key="BKAPP_IEOD_ACTIVE_FIREWALL_POLICY_SCRIPT_INFO", default="", _type=str +) # =============================================================================== # 日志 diff --git a/support-files/kubernetes/helm/bk-nodeman/README.md b/support-files/kubernetes/helm/bk-nodeman/README.md index c7e8b3fc4..c13aeb743 100644 --- a/support-files/kubernetes/helm/bk-nodeman/README.md +++ b/support-files/kubernetes/helm/bk-nodeman/README.md @@ -349,6 +349,7 @@ externalRabbitMQ: | `config.bkAppNavHelperUrl` | 导航栏技术支持地址 | `https://wpa1.qq.com/KziXGWJs?_type=wpa&qidian=true` | | `config.bkAppSyncProcStatusTaskInterval` | 插件进程状态同步周期 | `20 * 60` | | `config.bkAppScriptHooks` | Agent安装前置脚本 | `""` | +| `config.bkAppIEODActiveFirewallPolicyScriptInfo` | WINDOWS IEOD脚本内容 | `""` | ## 额外的环境变量 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 f9ddb38a0..f3c5a6af5 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 @@ -131,3 +131,4 @@ data: BKPAAS_SHARED_RES_URL: "{{ .Values.bkSharedResUrl }}" BKAPP_LEGACY_AUTH: "{{ .Values.config.bkAppLegacyAuth }}" BK_NOTICE_ENABLED: "{{ .Values.bkNotice.enabled }}" + BKAPP_IEOD_ACTIVE_FIREWALL_POLICY_SCRIPT_INFO: "{{ .Values.config.bkAppIEODActiveFirewallPolicyScriptInfo }}" diff --git a/support-files/kubernetes/helm/bk-nodeman/values.yaml b/support-files/kubernetes/helm/bk-nodeman/values.yaml index 9da409769..38d00c7fa 100644 --- a/support-files/kubernetes/helm/bk-nodeman/values.yaml +++ b/support-files/kubernetes/helm/bk-nodeman/values.yaml @@ -467,6 +467,8 @@ config: bkAppSyncProcStatusTaskInterval: 1200 ## Agent安装前置脚本 bkAppScriptHooks: "" + ## WINDOWS IEOD脚本内容 + bkAppIEODActiveFirewallPolicyScriptInfo: "" ## --------------------------------------