diff --git a/backend/provisioner.py b/backend/provisioner.py index 1044364..fd6217d 100644 --- a/backend/provisioner.py +++ b/backend/provisioner.py @@ -24,10 +24,10 @@ from models import ( JobStatus, DiskType, ) +from converter import extract_if_needed, discover_disk logger = logging.getLogger("backend.provisioner") -STAGING_IN = Path("/mnt/converter/in") STAGING_OUT = Path("/mnt/converter/out") # In-memory job tracking — survives as long as the process runs @@ -164,13 +164,15 @@ def _process_job(job_id: str, req: JobSubmissionRequest): output_path = out_dir / f"vm-{vmid}-disk-{idx}.qcow2" if spec.disk_type == DiskType.IMAGE_FILE: - source_path = STAGING_IN / spec.source_filename - if not source_path.exists(): - raise FileNotFoundError(f"Source file not found: {source_path}") + # Extract archive if needed, then locate the actual disk image + source = extract_if_needed(spec.source_filename) + disk = discover_disk(source) + source_path = disk.path + logger.info("Disk %d: source=%s format=%s size=%.1f GiB", + idx, source_path, disk.format, disk.size_gb) - logger.info("Converting disk %d: %s → %s", idx, source_path, output_path) _run(["qemu-img", "convert", - "-f", spec.format.value if spec.format else "vmdk", + "-f", disk.format, "-O", "qcow2", str(source_path), str(output_path)], timeout=7200)