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:
parent
334883dd26
commit
80c5e2ceda
1 changed files with 7 additions and 2 deletions
|
|
@ -270,9 +270,14 @@ def _process_job(job_id: str, req: JobSubmissionRequest):
|
||||||
_update_job(job_id, status=JobStatus.IMPORTING_STORAGE, progress=70,
|
_update_job(job_id, status=JobStatus.IMPORTING_STORAGE, progress=70,
|
||||||
message="Creating VM...")
|
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"
|
bios = "ovmf" if req.boot_type.value == "uefi" else "seabios"
|
||||||
_run(["qm", "create", str(vmid),
|
_run(["qm", "create", str(vmid),
|
||||||
"--name", req.vm_name,
|
"--name", safe_name,
|
||||||
"--bios", bios,
|
"--bios", bios,
|
||||||
"--cores", str(req.cpu_cores),
|
"--cores", str(req.cpu_cores),
|
||||||
"--memory", str(req.ram_mb),
|
"--memory", str(req.ram_mb),
|
||||||
|
|
@ -282,7 +287,7 @@ def _process_job(job_id: str, req: JobSubmissionRequest):
|
||||||
# ── Import and attach each disk ────────────────────────────
|
# ── Import and attach each disk ────────────────────────────
|
||||||
for idx, disk_path in enumerate(disk_paths):
|
for idx, disk_path in enumerate(disk_paths):
|
||||||
logger.info("Importing disk %d: %s", idx, disk_path)
|
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])
|
req.target_storage])
|
||||||
output = result.stdout + result.stderr
|
output = result.stdout + result.stderr
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue