update config x2

This commit is contained in:
Nico Schottelius 2019-12-08 13:41:42 +01:00
parent 537a5b01f1
commit 72af426b3a
2 changed files with 17 additions and 20 deletions

View file

@ -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

View file

@ -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")