2026-10-22 19:38:18 +03:00
|
|
|
import pathlib
|
|
|
|
|
import shutil
|
|
|
|
|
import subprocess
|
|
|
|
|
import tempfile
|
|
|
|
|
|
|
|
|
|
def create_os_disk(paths):
|
2026-11-07 13:04:20 +02:00
|
|
|
with tempfile.TemporaryDirectory(dir=paths.target_path.parent) as temporary_directory:
|
2026-10-22 19:38:18 +03:00
|
|
|
temporary_path = pathlib.Path(temporary_directory) / 'disk.qcow2'
|
|
|
|
|
|
|
|
|
|
subprocess.run(
|
|
|
|
|
args=[
|
|
|
|
|
'qemu-img', 'create',
|
|
|
|
|
'--format', 'qcow2',
|
|
|
|
|
'--backing', paths.template_path,
|
|
|
|
|
'--backing-format', 'qcow2',
|
|
|
|
|
temporary_path
|
|
|
|
|
],
|
|
|
|
|
check=True,
|
|
|
|
|
timeout=10
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
temporary_path.replace(paths.target_path)
|
|
|
|
|
|
|
|
|
|
def create_nvram_disk(paths):
|
2026-11-07 13:04:20 +02:00
|
|
|
with tempfile.TemporaryDirectory(dir=paths.nvram_target_path.parent) as temporary_directory:
|
2026-10-22 19:38:18 +03:00
|
|
|
temporary_path = pathlib.Path(temporary_directory) / 'NVRAM.img'
|
|
|
|
|
|
|
|
|
|
shutil.copyfile(paths.nvram_path, temporary_path)
|
|
|
|
|
|
|
|
|
|
temporary_path.replace(paths.nvram_target_path)
|