60 lines
No EOL
1.7 KiB
Python
60 lines
No EOL
1.7 KiB
Python
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']}"
|
|
) |