live: check if cache partition is available before calling tiptorrent

The image restore command must check if the cache partition is
available. Otherwise if the user forgets to create the cache
tiptorrent fails.
master
Alejandro Sirgo Rica 2024-03-07 13:07:03 +01:00 committed by lupoDharkael
parent 52ab38fc28
commit 37600660f3
1 changed files with 4 additions and 0 deletions

View File

@ -40,6 +40,7 @@ from src.ogClient import ogClient
from src.utils.probe import OSFamily, get_os_family
OG_SHELL = '/bin/bash'
OG_CACHE_PATH = '/opt/opengnsys/cache/opt/opengnsys/images'
class OgLiveOperations:
def __init__(self, config):
@ -166,6 +167,9 @@ class OgLiveOperations:
self._restore_image(image_path, devpath)
def _restore_image_tiptorrent(self, repo, name, devpath):
if not os.path.exists(OG_CACHE_PATH):
raise RuntimeError('No cache partition is mounted')
image_path = f'/opt/opengnsys/cache/opt/opengnsys/images/{name}.img'
try:
if (not os.path.exists(image_path) or