From 72af426b3a3687e66597bad823d06310b403d907 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 8 Dec 2019 13:41:42 +0100 Subject: [PATCH] update config x2 --- conf/ucloud.conf | 8 ++++---- ucloud/config.py | 29 +++++++++++++---------------- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/conf/ucloud.conf b/conf/ucloud.conf index f2b681a..7cd9725 100644 --- a/conf/ucloud.conf +++ b/conf/ucloud.conf @@ -35,7 +35,7 @@ HOST_PREFIx = hosts IMAGE_PREFIX = image/ IMAGE_STORE_PREFIX = imagestore/ -NETWORK_PREFIX = network/ -REQUEST_PREFIX = request/ -USER_PREFIX = user/ -VM_PREFIX = vm/ +NETWORK_PREFIX = networks +REQUEST_PREFIX = requests +USER_PREFIX = users +VM_PREFIX = vms diff --git a/ucloud/config.py b/ucloud/config.py index b508f56..b8b4dcf 100644 --- a/ucloud/config.py +++ b/ucloud/config.py @@ -35,10 +35,6 @@ except FileNotFoundError: log.warn("Configuration file not found - using defaults") -# Compatibility to old code -env_vars = config - - # Try importing config, but don't fail if it does not exist # try: # env_vars = Config(RepositoryEnv('/etc/ucloud/ucloud.conf')) @@ -48,26 +44,27 @@ env_vars = config etcd_wrapper_args = () etcd_wrapper_kwargs = { - 'host': env_vars.get('ETCD_URL', 'localhost'), - 'port': env_vars.get('ETCD_PORT', 2379), - 'ca_cert': env_vars.get('CA_CERT', None), - 'cert_cert': env_vars.get('CERT_CERT', None), - 'cert_key': env_vars.get('CERT_KEY', None) + 'host': config['etcd']['ETCD_URL'], + 'port': config['etcd']['ETCD_PORT'], + 'ca_cert': config['etcd']['CA_CERT'], + 'cert_cert': config['etcd']['CERT_CERT'], + 'cert_key': config['etcd']['CERT_KEY'] } etcd_client = Etcd3Wrapper(*etcd_wrapper_args, **etcd_wrapper_kwargs) -host_pool = HostPool(etcd_client, env_vars.get('HOST_PREFIX', "hosts")) -vm_pool = VmPool(etcd_client, env_vars.get('VM_PREFIX', "vms")) -request_pool = RequestPool(etcd_client, env_vars.get('REQUEST_PREFIX', "requests")) +host_pool = HostPool(etcd_client, config['etcd']['HOST_PREFIX']) +vm_pool = VmPool(etcd_client, config['etcd']['VM_PREFIX']) +request_pool = RequestPool(etcd_client, config['etcd']['REQUEST_PREFIX']) running_vms = [] -__storage_backend = env_vars.get("STORAGE_BACKEND", "filesystem") +__storage_backend = config['storage']["STORAGE_BACKEND"] if __storage_backend == "filesystem": - image_storage_handler = FileSystemBasedImageStorageHandler(vm_base=env_vars.get("VM_DIR", "/tmp/ucloud-vms"), - image_base=env_vars.get("IMAGE_DIR", "/tmp/ucloud-images")) + image_storage_handler = FileSystemBasedImageStorageHandler(vm_base=config['storage']["VM_DIR"], + image_base=config['storage']["IMAGE_DIR"]) elif __storage_backend == "ceph": - image_storage_handler = CEPHBasedImageStorageHandler(vm_base="ssd", image_base="ssd") + image_storage_handler = CEPHBasedImageStorageHandler(vm_base=config['storage']["CEPH_VM_POOL"], + image_base=config['storage']["CEPH_IMAGE_POOL"]) else: raise Exception("Unknown Image Storage Handler")