[filescanner] use configparser

This commit is contained in:
Nico Schottelius 2019-12-08 13:51:40 +01:00
parent b235f0833c
commit 00563c7dc2
2 changed files with 14 additions and 6 deletions

View file

@ -41,8 +41,17 @@ USER_PREFIX = users
VM_PREFIX = vms VM_PREFIX = vms
[storage] [storage]
STORAGE_BACKEND = #values = filesystem, #values = filesystem, ceph
STORAGE_BACKEND =
# if STORAGE_BACKEND = filesystem
VM_DIR = VM_DIR =
IMG_DIR = IMG_DIR =
# if STORAGE_BACKEND = ceph
CEPH_VM_POOL = CEPH_VM_POOL =
CEPH_IMG_POOL = CEPH_IMG_POOL =
# Importing uploaded files
FILE_DIR = /var/lib/ucloud/files
FILE_PREFIX = noclue-ahmed

View file

@ -6,7 +6,7 @@ import time
from uuid import uuid4 from uuid import uuid4
from . import logger from . import logger
from ucloud.config import env_vars, etcd_client from ucloud.config import config, etcd_client
def getxattr(file, attr): def getxattr(file, attr):
@ -37,7 +37,7 @@ def setxattr(file, attr, value):
def sha512sum(file: str): def sha512sum(file: str):
"""Use sha512sum utility to compute sha512 sum of arg:file """Use sha512sum utility to compute sha512 sum of arg:file
IF arg:file does not exists: IF arg:file does not exists:
raise FileNotFoundError exception raise FileNotFoundError exception
ELSE IF sum successfully computer: ELSE IF sum successfully computer:
@ -69,9 +69,8 @@ except Exception as e:
def main(): def main():
BASE_DIR = env_vars.get("BASE_DIR") BASE_DIR = config['storage']["FILE_DIR"]
FILE_PREFIX = config['storage']["FILE_PREFIX"]
FILE_PREFIX = env_vars.get("FILE_PREFIX")
# Recursively Get All Files and Folder below BASE_DIR # Recursively Get All Files and Folder below BASE_DIR
files = glob.glob("{}/**".format(BASE_DIR), recursive=True) files = glob.glob("{}/**".format(BASE_DIR), recursive=True)