This commit is contained in:
llnu 2019-12-08 13:41:37 +01:00
commit 871aa5347b
2 changed files with 17 additions and 20 deletions

View file

@ -35,7 +35,7 @@ HOST_PREFIx = hosts
IMAGE_PREFIX = image/ IMAGE_PREFIX = image/
IMAGE_STORE_PREFIX = imagestore/ IMAGE_STORE_PREFIX = imagestore/
NETWORK_PREFIX = network/ NETWORK_PREFIX = networks
REQUEST_PREFIX = request/ REQUEST_PREFIX = requests
USER_PREFIX = user/ USER_PREFIX = users
VM_PREFIX = vm/ VM_PREFIX = vms

View file

@ -35,10 +35,6 @@ except FileNotFoundError:
log.warn("Configuration file not found - using defaults") 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 importing config, but don't fail if it does not exist
# try: # try:
# env_vars = Config(RepositoryEnv('/etc/ucloud/ucloud.conf')) # env_vars = Config(RepositoryEnv('/etc/ucloud/ucloud.conf'))
@ -48,26 +44,27 @@ env_vars = config
etcd_wrapper_args = () etcd_wrapper_args = ()
etcd_wrapper_kwargs = { etcd_wrapper_kwargs = {
'host': env_vars.get('ETCD_URL', 'localhost'), 'host': config['etcd']['ETCD_URL'],
'port': env_vars.get('ETCD_PORT', 2379), 'port': config['etcd']['ETCD_PORT'],
'ca_cert': env_vars.get('CA_CERT', None), 'ca_cert': config['etcd']['CA_CERT'],
'cert_cert': env_vars.get('CERT_CERT', None), 'cert_cert': config['etcd']['CERT_CERT'],
'cert_key': env_vars.get('CERT_KEY', None) 'cert_key': config['etcd']['CERT_KEY']
} }
etcd_client = Etcd3Wrapper(*etcd_wrapper_args, **etcd_wrapper_kwargs) etcd_client = Etcd3Wrapper(*etcd_wrapper_args, **etcd_wrapper_kwargs)
host_pool = HostPool(etcd_client, env_vars.get('HOST_PREFIX', "hosts")) host_pool = HostPool(etcd_client, config['etcd']['HOST_PREFIX'])
vm_pool = VmPool(etcd_client, env_vars.get('VM_PREFIX', "vms")) vm_pool = VmPool(etcd_client, config['etcd']['VM_PREFIX'])
request_pool = RequestPool(etcd_client, env_vars.get('REQUEST_PREFIX', "requests")) request_pool = RequestPool(etcd_client, config['etcd']['REQUEST_PREFIX'])
running_vms = [] running_vms = []
__storage_backend = env_vars.get("STORAGE_BACKEND", "filesystem") __storage_backend = config['storage']["STORAGE_BACKEND"]
if __storage_backend == "filesystem": if __storage_backend == "filesystem":
image_storage_handler = FileSystemBasedImageStorageHandler(vm_base=env_vars.get("VM_DIR", "/tmp/ucloud-vms"), image_storage_handler = FileSystemBasedImageStorageHandler(vm_base=config['storage']["VM_DIR"],
image_base=env_vars.get("IMAGE_DIR", "/tmp/ucloud-images")) image_base=config['storage']["IMAGE_DIR"])
elif __storage_backend == "ceph": 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: else:
raise Exception("Unknown Image Storage Handler") raise Exception("Unknown Image Storage Handler")