Configuration/Setting module added

This commit is contained in:
ahmadbilalkhalid 2019-12-21 14:36:55 +05:00
commit bc58a6ed9c
11 changed files with 217 additions and 106 deletions

View file

@ -1,7 +1,9 @@
import json
import os
import subprocess
import sys
from os.path import isdir
from os.path import join as join_path
from ucloud.config import etcd_client, config, image_storage_handler
from ucloud.imagescanner import logger
@ -20,10 +22,10 @@ def qemu_img_type(path):
def check():
""" check whether settings are sane, refuse to start if they aren't """
if config['storage']['backend'] == 'filesystem' and not isdir(config['storage']['image_dir']):
print("You have set STORAGE_BACKEND to filesystem, but "
"{} does not exist. Refusing to start".format(config['storage']['image_dir']))
sys.exit(1)
if config['storage']['storage_backend'] == 'filesystem' and not isdir(config['storage']['image_dir']):
sys.exit("You have set STORAGE_BACKEND to filesystem, but "
"{} does not exist. Refusing to start".format(config['storage']['image_dir'])
)
try:
subprocess.check_output(['which', 'qemu-img'])