fix: sanitize VM name + use qm disk import (newer Proxmox syntax)

- VM name now sanitized: spaces→hyphens, lowercase, strip invalid chars
- qm importdisk → qm disk import (newer Proxmox VE command)
This commit is contained in:
Claus Lohmar 2026-07-23 08:25:46 +00:00
parent 334883dd26
commit 80c5e2ceda

View file

@ -270,9 +270,14 @@ def _process_job(job_id: str, req: JobSubmissionRequest):
_update_job(job_id, status=JobStatus.IMPORTING_STORAGE, progress=70,
message="Creating VM...")
# Sanitize VM name: Proxmox requires DNS-safe names (a-z, 0-9, hyphens)
safe_name = re.sub(r'[^a-zA-Z0-9-]', '-', req.vm_name).strip('-').lower()
if not safe_name:
safe_name = f"vm-{vmid}"
bios = "ovmf" if req.boot_type.value == "uefi" else "seabios"
_run(["qm", "create", str(vmid),
"--name", req.vm_name,
"--name", safe_name,
"--bios", bios,
"--cores", str(req.cpu_cores),
"--memory", str(req.ram_mb),
@ -282,7 +287,7 @@ def _process_job(job_id: str, req: JobSubmissionRequest):
# ── Import and attach each disk ────────────────────────────
for idx, disk_path in enumerate(disk_paths):
logger.info("Importing disk %d: %s", idx, disk_path)
result = _run(["qm", "importdisk", str(vmid), str(disk_path),
result = _run(["qm", "disk", "import", str(vmid), str(disk_path),
req.target_storage])
output = result.stdout + result.stderr