Disks Service
This commit is contained in:
parent
271007044a
commit
7f5b5209a1
10 changed files with 256 additions and 0 deletions
60
backend/disks/disk_paths.py
Normal file
60
backend/disks/disk_paths.py
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
import pathlib
|
||||
|
||||
class DiskPaths:
|
||||
STORAGE_HOSTS_PATH = pathlib.Path("/var/opt/instant-workstation/storage-hosts")
|
||||
|
||||
def __init__(self, request):
|
||||
self.persistence_type = request['persistence_type']
|
||||
self.storage_host = request['storage_host']
|
||||
self.workstation = request['workstation']
|
||||
self.user_id = request['user_id']
|
||||
|
||||
@property
|
||||
def nvram_filename(self):
|
||||
return f"{self.workstation_key}_NVRAM.img"
|
||||
|
||||
@property
|
||||
def nvram_path(self):
|
||||
return self.storage_host_path / 'firmware' / self.nvram_filename
|
||||
|
||||
@property
|
||||
def nvram_target_filename(self):
|
||||
return f"{self.user_id}_{self.nvram_filename}"
|
||||
|
||||
@property
|
||||
def nvram_target_path(self):
|
||||
return self.storage_host_path / self.persistence_type / self.nvram_target_filename
|
||||
|
||||
@property
|
||||
def staging_path(self):
|
||||
return self.storage_host_path / 'staging'
|
||||
|
||||
@property
|
||||
def storage_host_path(self):
|
||||
return self.STORAGE_HOSTS_PATH / self.storage_host
|
||||
|
||||
@property
|
||||
def target_filename(self):
|
||||
return f"{self.user_id}_{self.template_filename}"
|
||||
|
||||
@property
|
||||
def target_path(self):
|
||||
return self.storage_host_path / self.persistence_type / self.target_filename
|
||||
|
||||
@property
|
||||
def template_filename(self):
|
||||
return f"{self.workstation_key}.qcow2"
|
||||
|
||||
@property
|
||||
def template_path(self):
|
||||
return self.storage_host_path / 'template' / self.template_filename
|
||||
|
||||
@property
|
||||
def workstation_key(self):
|
||||
return (
|
||||
f"{self.workstation['name']}_"
|
||||
f"{self.workstation['version']}_"
|
||||
f"{self.workstation['cpu']}_"
|
||||
f"{self.workstation['bitness']}_"
|
||||
f"{self.workstation['endianness']}"
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue