mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-09-12 18:44:25 +08:00
fix: 修复 MSD 启用时 Ventoy 资源初始化问题 #275
- 将 Ventoy 资源初始化纳入 MSD 控制器启用流程 - 支持运行时启用 MSD,无需重启服务 - 调整验收测试并移除启用后的重启逻辑
This commit is contained in:
@@ -61,7 +61,7 @@ REPORT_HIDDEN_RESULTS = {
|
||||
}
|
||||
|
||||
CATEGORY_RULES = (
|
||||
("初始化与环境", ("target_", "setup_", "login", "network_", "target_inventory", "stream_codecs", "windows_agent", "ventoy_resources", "msd_restart")),
|
||||
("初始化与环境", ("target_", "setup_", "login", "network_", "target_inventory", "stream_codecs", "windows_agent", "ventoy_resources")),
|
||||
("视频性能", ("video_", "config_video_")),
|
||||
("HDMI 画面与颜色", ("hdmi_", "config_video_hdmi_probe")),
|
||||
("HID / MSD / ATX", ("hid_", "msd", "atx_")),
|
||||
@@ -71,12 +71,10 @@ DISPLAY_NAMES = {
|
||||
"target_reset": "目标机重置",
|
||||
"setup_init": "初始化账号",
|
||||
"login": "登录",
|
||||
"login_after_restart": "重启后登录",
|
||||
"network_latency": "网络延迟",
|
||||
"target_inventory": "目标机设备清单",
|
||||
"hid_msd_config": "HID/MSD 配置",
|
||||
"ventoy_resources": "Ventoy 资源",
|
||||
"msd_restart": "MSD 启用后重启",
|
||||
"video_input_select": "视频输入选择",
|
||||
"windows_agent": "Windows 配套程序连接",
|
||||
"config_video_hdmi_probe": "HDMI 采集配置",
|
||||
@@ -564,14 +562,12 @@ def summarize_result(result: CheckResult, metrics: list[Metric]) -> str:
|
||||
return "数据库已备份,服务已重启"
|
||||
if name == "setup_init":
|
||||
return "初始化检查完成"
|
||||
if name in {"login", "login_after_restart"}:
|
||||
if name == "login":
|
||||
return "认证成功"
|
||||
if name == "hid_msd_config":
|
||||
return "已按设备能力配置 HID/MSD"
|
||||
if name == "ventoy_resources":
|
||||
return "Ventoy 资源检查完成"
|
||||
if name == "msd_restart":
|
||||
return "服务重启完成"
|
||||
if name == "video_input_select":
|
||||
cases = data.get("cases") or []
|
||||
return ",".join(f"{c.get('fmt')} {c.get('width')}x{c.get('height')}@{c.get('fps')}" for c in cases if isinstance(c, dict))
|
||||
|
||||
@@ -507,6 +507,11 @@ echo "$BACKUP"
|
||||
},
|
||||
)
|
||||
self.selected_hid_backend = "otg"
|
||||
if not self.args.no_ventoy_sync:
|
||||
try:
|
||||
self.sync_ventoy_resources()
|
||||
except Exception as exc:
|
||||
self.reporter.add("ventoy_resources", "WARN", f"failed to sync Ventoy resources: {exc}")
|
||||
try:
|
||||
self.api.patch("/config/msd", {"enabled": True})
|
||||
except Exception as exc:
|
||||
@@ -514,16 +519,6 @@ echo "$BACKUP"
|
||||
self.reporter.add("hid_msd_config", "WARN", f"configured OTG HID but failed to enable MSD: {exc}", udc=udc_name)
|
||||
return
|
||||
self.reporter.add("hid_msd_config", "PASS", "configured OTG HID and enabled MSD", udc=udc_name)
|
||||
if not self.args.no_ventoy_sync:
|
||||
try:
|
||||
self.sync_ventoy_resources()
|
||||
except Exception as exc:
|
||||
self.reporter.add("ventoy_resources", "WARN", f"failed to sync Ventoy resources: {exc}")
|
||||
if not self.args.no_msd_restart_after_enable:
|
||||
try:
|
||||
self.restart_target_service("msd_restart", "restarted One-KVM after enabling MSD")
|
||||
except Exception as exc:
|
||||
self.reporter.add("msd_restart", "WARN", f"failed to restart after enabling MSD: {exc}")
|
||||
return
|
||||
if serial:
|
||||
port = serial[0]["path"]
|
||||
@@ -556,17 +551,6 @@ echo "$BACKUP"
|
||||
)
|
||||
)
|
||||
|
||||
def restart_target_service(self, check_name: str, detail: str) -> None:
|
||||
if not self.ssh_password and self.args.ssh_password_prompt:
|
||||
self.ssh_password = getpass.getpass(f"SSH password for {self.args.ssh_user}@{self.args.target}: ")
|
||||
ssh = SSHRunner(self.args.target, self.args.ssh_user, self.ssh_password, self.args.ssh_port)
|
||||
code, out, err = ssh.run("systemctl restart one-kvm || service one-kvm restart", timeout=90)
|
||||
if code != 0:
|
||||
raise RuntimeError(err or out or "service restart command failed")
|
||||
self.api.wait_health(timeout=self.args.health_timeout)
|
||||
self.authenticate("login_after_restart", "authenticated after One-KVM restart")
|
||||
self.reporter.add(check_name, "PASS", detail)
|
||||
|
||||
def sync_ventoy_resources(self) -> None:
|
||||
source_dir = Path(self.args.ventoy_resources_dir) if self.args.ventoy_resources_dir else default_ventoy_resources_dir()
|
||||
if not source_dir.exists():
|
||||
@@ -2277,7 +2261,6 @@ def build_parser() -> argparse.ArgumentParser:
|
||||
run.add_argument("--msd-probe-bytes", type=int, default=1024 * 1024)
|
||||
run.add_argument("--ventoy-resources-dir", default=None, help="local Ventoy resource directory; defaults to repo libs/ventoy-img-rs/resources")
|
||||
run.add_argument("--no-ventoy-sync", action="store_true", help="do not copy Ventoy resources to the target before MSD testing")
|
||||
run.add_argument("--no-msd-restart-after-enable", action="store_true", help="do not restart One-KVM after enabling MSD")
|
||||
run.add_argument("--strict-performance", action="store_true", help="fail video results below the expected FPS threshold; default only requires fps > 0")
|
||||
run.add_argument("--no-color", action="store_true", help="disable colored terminal output")
|
||||
run.add_argument("--no-screenshots", action="store_true", help="skip Playwright webpage screenshots")
|
||||
|
||||
Reference in New Issue
Block a user