summaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorAlejandro Sirgo Rica <asirgo@soleta.eu>2024-05-20 13:23:06 +0200
committerAlejandro Sirgo Rica <asirgo@soleta.eu>2024-05-27 17:09:10 +0200
commit03d33d4fa91c02c4fbaca3d1ed4bb9850124ed0f (patch)
tree89362eeeafbf97ced3899ef156e9fdfeb0d86c21 /src/utils
parent4626383cc4523e46784943103f00e72ce63e9184 (diff)
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.
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/cache.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/utils/cache.py b/src/utils/cache.py
index b60b5be..374f8e0 100644
--- a/src/utils/cache.py
+++ b/src/utils/cache.py
@@ -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)