Disks Service
This commit is contained in:
parent
271007044a
commit
7f5b5209a1
10 changed files with 256 additions and 0 deletions
30
backend/disks/disk_utils.py
Normal file
30
backend/disks/disk_utils.py
Normal 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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue