fester/backend/storage/config.py

32 lines
612 B
Python

import json
from pathlib import Path
DEFAULT_CONFIG_PATH = Path("/etc/fester/storage.json")
DEFAULT_CONFIG = {
"tmpfs": True,
"btrfs": False,
"qcow2_freeze": False,
"btrfs_path": "/var/lib/fester/cas",
"tmpfs_path": "/dev/shm/fester-build",
"qcow2_path": "/var/lib/fester/snapshots"
}
def load_storage_config():
if not DEFAULT_CONFIG_PATH.exists():
return DEFAULT_CONFIG
try:
with open(DEFAULT_CONFIG_PATH) as f:
user_cfg = json.load(f)
except:
user_cfg = {}
cfg = DEFAULT_CONFIG.copy()
cfg.update(user_cfg)
return cfg