mirror of https://git.48k.eu/ogclient
src: fix cache mount in new ogLive
Mount cache in image_create() image_restore() and cache_fetch(). Remove init_cache() and ensure /opt/opengnsys/images/ exists within the cache mountpoint if it does not exists in cache_mount().master
parent
fe960010a0
commit
f942b19eae
|
@ -543,7 +543,7 @@ class OgLiveOperations:
|
||||||
|
|
||||||
fs = part["filesystem"].lower()
|
fs = part["filesystem"].lower()
|
||||||
if fs == 'cache':
|
if fs == 'cache':
|
||||||
init_cache()
|
mount_cache()
|
||||||
|
|
||||||
logging.info('Partition setup command OK')
|
logging.info('Partition setup command OK')
|
||||||
result = self.refresh(ogRest)
|
result = self.refresh(ogRest)
|
||||||
|
@ -562,6 +562,8 @@ class OgLiveOperations:
|
||||||
cid = request.getId()
|
cid = request.getId()
|
||||||
partdev = get_partition_device(disk, partition)
|
partdev = get_partition_device(disk, partition)
|
||||||
|
|
||||||
|
mount_cache()
|
||||||
|
|
||||||
self._ogbrowser_clear_logs()
|
self._ogbrowser_clear_logs()
|
||||||
self._restartBrowser(self._url_log)
|
self._restartBrowser(self._url_log)
|
||||||
|
|
||||||
|
@ -600,6 +602,8 @@ class OgLiveOperations:
|
||||||
backup = request.getBackup()
|
backup = request.getBackup()
|
||||||
image_path = f'/opt/opengnsys/images/{name}.img'
|
image_path = f'/opt/opengnsys/images/{name}.img'
|
||||||
|
|
||||||
|
mount_cache()
|
||||||
|
|
||||||
self._ogbrowser_clear_logs()
|
self._ogbrowser_clear_logs()
|
||||||
self._restartBrowser(self._url_log)
|
self._restartBrowser(self._url_log)
|
||||||
|
|
||||||
|
@ -772,6 +776,8 @@ class OgLiveOperations:
|
||||||
repo = request.getRepo()
|
repo = request.getRepo()
|
||||||
ctype = request.getType()
|
ctype = request.getType()
|
||||||
|
|
||||||
|
mount_cache()
|
||||||
|
|
||||||
logging.info(f'Request to cache image {image}.img via {ctype} from {repo}')
|
logging.info(f'Request to cache image {image}.img via {ctype} from {repo}')
|
||||||
|
|
||||||
if ctype == 'UNICAST':
|
if ctype == 'UNICAST':
|
||||||
|
|
|
@ -19,16 +19,13 @@ OG_CACHE_IMAGE_PATH = OG_CACHE_PATH + OG_IMAGE_PATH
|
||||||
OGCLIENT_LOG_CACHE='/opt/opengnsys/log/{ip}.cache.txt'
|
OGCLIENT_LOG_CACHE='/opt/opengnsys/log/{ip}.cache.txt'
|
||||||
|
|
||||||
def mount_cache():
|
def mount_cache():
|
||||||
"""
|
|
||||||
Probes for cache and mounts if succesful.
|
|
||||||
|
|
||||||
Returns the mountpoint or an empty string.
|
|
||||||
"""
|
|
||||||
cache_dev = get_cache_dev_path()
|
cache_dev = get_cache_dev_path()
|
||||||
|
|
||||||
if cache_dev:
|
if cache_dev:
|
||||||
# cache_target = cache_dev.replace('dev', 'mnt')
|
cache_mounted = mount_mkdir(cache_dev, OG_CACHE_PATH)
|
||||||
mount_mkdir(cache_dev, OG_CACHE_PATH)
|
|
||||||
|
if cache_mounted and not os.path.exists(OG_CACHE_IMAGE_PATH):
|
||||||
|
os.makedirs(OG_CACHE_IMAGE_PATH)
|
||||||
return OG_CACHE_PATH
|
return OG_CACHE_PATH
|
||||||
|
|
||||||
return ''
|
return ''
|
||||||
|
@ -69,15 +66,3 @@ def generate_cache_txt():
|
||||||
return
|
return
|
||||||
content = ','.join(files)
|
content = ','.join(files)
|
||||||
write_cache_txt(content)
|
write_cache_txt(content)
|
||||||
|
|
||||||
|
|
||||||
def init_cache():
|
|
||||||
"""
|
|
||||||
If a cache partition is present, creates the following directories
|
|
||||||
/opt/opengnsys/images. This is the default folder in which images
|
|
||||||
are stored when using tiptorrent-cache.
|
|
||||||
"""
|
|
||||||
mountpoint = mount_cache()
|
|
||||||
if mountpoint:
|
|
||||||
logging.info(f'Creating cache directory at {mountpoint}')
|
|
||||||
os.makedirs(f'{mountpoint}/opt/opengnsys/images')
|
|
||||||
|
|
Loading…
Reference in New Issue