Disks Service

This commit is contained in:
Henrik Brüsecke 2026-10-22 19:38:18 +03:00
parent 271007044a
commit 7f5b5209a1
10 changed files with 256 additions and 0 deletions

View file

@ -0,0 +1,30 @@
import pathlib
import shutil
import subprocess
import tempfile
def create_os_disk(paths):
with tempfile.TemporaryDirectory(dir=paths.staging_path) as temporary_directory:
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):
with tempfile.TemporaryDirectory(dir=paths.staging_path) as temporary_directory:
temporary_path = pathlib.Path(temporary_directory) / 'NVRAM.img'
shutil.copyfile(paths.nvram_path, temporary_path)
temporary_path.replace(paths.nvram_target_path)