From 00563c7dc2e1f7fc4cd3c9f859afb36adef9daa0 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 8 Dec 2019 13:51:40 +0100 Subject: [PATCH] [filescanner] use configparser --- conf/ucloud.conf | 11 ++++++++++- ucloud/filescanner/main.py | 9 ++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/conf/ucloud.conf b/conf/ucloud.conf index e0e3c27..2a06c81 100644 --- a/conf/ucloud.conf +++ b/conf/ucloud.conf @@ -41,8 +41,17 @@ USER_PREFIX = users VM_PREFIX = vms [storage] -STORAGE_BACKEND = #values = filesystem, +#values = filesystem, ceph +STORAGE_BACKEND = + +# if STORAGE_BACKEND = filesystem VM_DIR = IMG_DIR = + +# if STORAGE_BACKEND = ceph CEPH_VM_POOL = CEPH_IMG_POOL = + +# Importing uploaded files +FILE_DIR = /var/lib/ucloud/files +FILE_PREFIX = noclue-ahmed \ No newline at end of file diff --git a/ucloud/filescanner/main.py b/ucloud/filescanner/main.py index b70cb5b..ef6fee6 100755 --- a/ucloud/filescanner/main.py +++ b/ucloud/filescanner/main.py @@ -6,7 +6,7 @@ import time from uuid import uuid4 from . import logger -from ucloud.config import env_vars, etcd_client +from ucloud.config import config, etcd_client def getxattr(file, attr): @@ -37,7 +37,7 @@ def setxattr(file, attr, value): def sha512sum(file: str): """Use sha512sum utility to compute sha512 sum of arg:file - + IF arg:file does not exists: raise FileNotFoundError exception ELSE IF sum successfully computer: @@ -69,9 +69,8 @@ except Exception as e: def main(): - BASE_DIR = env_vars.get("BASE_DIR") - - FILE_PREFIX = env_vars.get("FILE_PREFIX") + BASE_DIR = config['storage']["FILE_DIR"] + FILE_PREFIX = config['storage']["FILE_PREFIX"] # Recursively Get All Files and Folder below BASE_DIR files = glob.glob("{}/**".format(BASE_DIR), recursive=True)