feat(vm): Medien pro VM (disk/floppy/iso) + ARIA-Urteilswissen
vm_register + Registry + boot fassen jetzt das ECHTE Boot-Medium (disk/floppy/ iso) — Eintrag, Startbefehl und App-Start spiegeln die reale Config. Leer = aria-vm erkennt disk.qcow2/floppy.img/cdrom.iso selbst. - project_vms.add_vm: floppy/disk-Felder. - main.py: VmAddBody + _vm_boot_args (baut --disk/--floppy/--iso), boot-Endpoint + boot_cmd nutzen sie. - agent.py: vm_register-Tool bekommt disk/floppy/iso. - Seed-Regel: URTEIL — VM nur wenn sinnvoll; Medium aus der Situation (Festplatte fuer DOS-Spiele, Diskette fuer OS-Dev, ISO fuer Installer); Architektur zum Task (ARM=aarch64, emuliert/langsam ok); Aenderungs-Zyklus stop→aendern→boot. py_compile clean. aria-vm schon live auf dem Host. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+18
-12
@@ -961,20 +961,30 @@ class VmAddBody(BaseModel):
|
||||
name: str
|
||||
arch: str = "i386"
|
||||
iso: str = ""
|
||||
floppy: str = ""
|
||||
disk: str = ""
|
||||
vnc_display: int = 1
|
||||
mem: int = 1024
|
||||
create_disk: bool = False
|
||||
size: str = "10G"
|
||||
|
||||
|
||||
def _vm_boot_args(v: dict) -> list:
|
||||
args = ["boot", v.get("name", "?"),
|
||||
"--vnc-display", str(v.get("vnc_display", 1)),
|
||||
"--mem", str(v.get("mem", 1024))]
|
||||
if v.get("disk"):
|
||||
args += ["--disk", v["disk"]]
|
||||
if v.get("floppy"):
|
||||
args += ["--floppy", v["floppy"]]
|
||||
if v.get("iso"):
|
||||
args += ["--iso", v["iso"]]
|
||||
return args
|
||||
|
||||
|
||||
def _vm_boot_cmd(v: dict) -> str:
|
||||
"""Lesbarer Start-Befehl (aria-vm) als 'Wert' hinter dem VM-Eintrag."""
|
||||
parts = ["aria-vm", "boot", v.get("name", "?"),
|
||||
"--vnc-display", str(v.get("vnc_display", 1)),
|
||||
"--mem", str(v.get("mem", 1024))]
|
||||
if v.get("iso"):
|
||||
parts += ["--iso", v["iso"]]
|
||||
return " ".join(parts)
|
||||
return "aria-vm " + " ".join(_vm_boot_args(v))
|
||||
|
||||
|
||||
@app.get("/projects/{project_id}/vms")
|
||||
@@ -992,7 +1002,7 @@ def project_vms_list(project_id: str):
|
||||
def project_vm_add(project_id: str, body: VmAddBody):
|
||||
try:
|
||||
vm = project_vms_mod.add_vm(project_id, body.name, body.arch, body.iso,
|
||||
body.vnc_display, body.mem)
|
||||
body.floppy, body.disk, body.vnc_display, body.mem)
|
||||
except ValueError as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc))
|
||||
if body.create_disk:
|
||||
@@ -1017,11 +1027,7 @@ def project_vm_boot(project_id: str, name: str):
|
||||
vm = project_vms_mod.get_vm(project_id, name)
|
||||
if not vm:
|
||||
raise HTTPException(status_code=404, detail=f"VM '{name}' nicht gefunden")
|
||||
args = ["boot", name, "--vnc-display", str(vm.get("vnc_display", 1)),
|
||||
"--mem", str(vm.get("mem", 1024))]
|
||||
if vm.get("iso"):
|
||||
args += ["--iso", vm["iso"]]
|
||||
rc, out, err = _ssh_aria_vm(*args, timeout=40)
|
||||
rc, out, err = _ssh_aria_vm(*_vm_boot_args(vm), timeout=40)
|
||||
return {"ok": rc == 0, "name": name, "vnc_port": 5900 + int(vm.get("vnc_display", 1)),
|
||||
"output": (out.strip() or err.strip())[:500]}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user