mirror of https://git.48k.eu/ogclient
utils: cache: redefine cache path constants
Rename OGIMG as OG_IMAGE_PATH. Rename OGCACHE_MOUNTPOINT as OG_CACHE_PATH. Define OG_CACHE_IMAGE_PATH as OG_CACHE_PATH + OG_IMAGE_PATH. This will serve to have a unique point to obtain cache related paths.master
parent
4626383cc4
commit
03d33d4fa9
|
@ -13,8 +13,9 @@ from src.utils.fs import mount_mkdir, umount
|
|||
from src.utils.net import getifaddr
|
||||
from src.utils.probe import get_cache_dev_path
|
||||
|
||||
OGIMG='/opt/opengnsys/images/'
|
||||
OGCACHE_MOUNTPOINT='/opt/opengnsys/cache'
|
||||
OG_IMAGE_PATH = '/opt/opengnsys/images/'
|
||||
OG_CACHE_PATH = '/opt/opengnsys/cache'
|
||||
OG_CACHE_IMAGE_PATH = OG_CACHE_PATH + OG_IMAGE_PATH
|
||||
OGCLIENT_LOG_CACHE='/opt/opengnsys/log/{ip}.cache.txt'
|
||||
|
||||
def mount_cache():
|
||||
|
@ -27,18 +28,18 @@ def mount_cache():
|
|||
|
||||
if cache_dev:
|
||||
# cache_target = cache_dev.replace('dev', 'mnt')
|
||||
mount_mkdir(cache_dev, OGCACHE_MOUNTPOINT)
|
||||
return OGCACHE_MOUNTPOINT
|
||||
mount_mkdir(cache_dev, OG_CACHE_PATH)
|
||||
return OG_CACHE_PATH
|
||||
|
||||
return ''
|
||||
|
||||
def umount_cache():
|
||||
"""
|
||||
If OGCACHE_MOUNTPOINT is a mountpoint, umounts.
|
||||
If OG_CACHE_PATH is a mountpoint, umounts.
|
||||
If not, does nothing.
|
||||
"""
|
||||
if os.path.ismount(OGCACHE_MOUNTPOINT):
|
||||
umount(OGCACHE_MOUNTPOINT)
|
||||
if os.path.ismount(OG_CACHE_PATH):
|
||||
umount(OG_CACHE_PATH)
|
||||
|
||||
def write_cache_txt(content):
|
||||
"""
|
||||
|
@ -63,7 +64,7 @@ def generate_cache_txt():
|
|||
|
||||
if cache_path:
|
||||
try:
|
||||
files = os.listdir(f'{cache_path}{OGIMG}')
|
||||
files = os.listdir(f'{cache_path}{OG_IMAGE_PATH}')
|
||||
except FileNotFoundError:
|
||||
return
|
||||
content = ','.join(files)
|
||||
|
|
Loading…
Reference in New Issue