17abd62261
创建/导入/IP 添加成功后后台 onboard 任务;前端注册进度条与 toast。
31 lines
866 B
Python
31 lines
866 B
Python
"""Schedule post-create server onboarding (sudoers + target path detect)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import logging
|
|
from typing import Any
|
|
|
|
logger = logging.getLogger("nexus.server_onboarding")
|
|
|
|
|
|
async def schedule_server_onboarding(
|
|
server_ids: list[int],
|
|
*,
|
|
operator: str,
|
|
) -> dict[str, Any] | None:
|
|
"""Start background batch job ``onboard`` for *server_ids*; returns job dict or None."""
|
|
ids = [int(x) for x in server_ids if x]
|
|
if not ids:
|
|
return None
|
|
from server.application.services.server_batch_service import start_batch_job
|
|
|
|
try:
|
|
return await start_batch_job(
|
|
op="onboard",
|
|
server_ids=ids,
|
|
operator=operator or "admin",
|
|
)
|
|
except Exception as exc:
|
|
logger.warning("schedule_server_onboarding failed ids=%s: %s", ids, exc)
|
|
return None
|