Skip to content

Commit

Permalink
优化资源池导入的flow,执行window机器 TencentBlueKing#7130
Browse files Browse the repository at this point in the history
  • Loading branch information
yksitu committed Sep 26, 2024
1 parent 8676f0c commit fe6e763
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
3 changes: 3 additions & 0 deletions dbm-ui/backend/flow/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@
# window操作系统超级账号,标准运维调用
WINDOW_ADMIN_USER_FOR_CHECK = "Administrator"

# linux操作系统超级账号,标准运维调用
LINUX_ADMIN_USER_FOR_CHECK = "root"

# tendisplus默认kvstorecount
DEFAULT_TENDISPLUS_KVSTORECOUNT = 10

Expand Down
17 changes: 15 additions & 2 deletions dbm-ui/backend/flow/engine/bamboo/scene/common/machine_os_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
from backend.components.dbresource.client import DBResourceApi
from backend.configuration.constants import SystemSettingsEnum
from backend.configuration.models import SystemSettings
from backend.db_services.ipchooser.constants import BkOsType
from backend.flow.consts import LINUX_ADMIN_USER_FOR_CHECK, WINDOW_ADMIN_USER_FOR_CHECK
from backend.flow.engine.bamboo.scene.common.builder import Builder
from backend.flow.plugins.components.collections.common.external_service import ExternalServiceComponent
from backend.flow.plugins.components.collections.common.sa_idle_check import CheckMachineIdleComponent
Expand All @@ -39,12 +41,23 @@ def machine_init_flow(self):
p = Builder(root_id=self.root_id, data=self.data)
ip_list = self.data["hosts"]
bk_biz_id = self.data["bk_biz_id"]

if self.data.get("os_type", BkOsType.LINUX.value) == BkOsType.WINDOWS.value:
# 如果是window类型机器,用administrator账号
account_name = WINDOW_ADMIN_USER_FOR_CHECK
else:
account_name = LINUX_ADMIN_USER_FOR_CHECK

# 先执行空闲检查
if env.SA_CHECK_TEMPLATE_ID:
p.add_act(
act_name=_("执行sa空闲检查"),
act_component_code=CheckMachineIdleComponent.code,
kwargs=asdict(InitCheckForResourceKwargs(ips=[host["ip"] for host in ip_list], bk_biz_id=bk_biz_id)),
kwargs=asdict(
InitCheckForResourceKwargs(
ips=[host["ip"] for host in ip_list], bk_biz_id=bk_biz_id, account_name=account_name
)
),
)

# 在执行sa初始化
Expand All @@ -53,7 +66,7 @@ def machine_init_flow(self):
p.add_act(
act_name=_("执行sa初始化"),
act_component_code=SaInitComponent.code,
kwargs={"ips": [host["ip"] for host in ip_list], "bk_biz_id": bk_biz_id},
kwargs={"ips": [host["ip"] for host in ip_list], "bk_biz_id": bk_biz_id, "account_name": account_name},
)

# 调用资源导入接口
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def _execute(self, data, parent_data) -> bool:
"${biz_cc_id}": bk_biz_id,
"${job_ip_list}": "\n".join(iplist),
"${bk_biz_id}": bk_biz_id,
"${job_account}": kwargs.get("account_name", "root"),
},
}
rpdata = BkSopsApi.create_task(param)
Expand Down
1 change: 1 addition & 0 deletions dbm-ui/backend/flow/utils/mysql/mysql_act_dataclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ class InitCheckForResourceKwargs:

ips: list
bk_biz_id: int = env.DBA_APP_BK_BIZ_ID
account_name: str = "root"


@dataclass()
Expand Down

0 comments on commit fe6e763

Please sign in to comment.