2019-11-18 17:39:57 +00:00
|
|
|
from etcd3_wrapper import Etcd3Wrapper
|
|
|
|
|
|
|
|
from common.host import HostPool
|
|
|
|
from common.request import RequestPool
|
|
|
|
from common.vm import VmPool
|
2019-11-25 06:52:36 +00:00
|
|
|
from common.storage_handlers import FileSystemBasedImageStorageHandler, CEPHBasedImageStorageHandler
|
|
|
|
from decouple import Config, RepositoryEnv
|
2019-11-18 17:39:57 +00:00
|
|
|
|
2019-11-25 06:52:36 +00:00
|
|
|
|
|
|
|
env_vars = Config(RepositoryEnv('/etc/ucloud/ucloud.conf'))
|
2019-11-18 17:39:57 +00:00
|
|
|
|
|
|
|
etcd_wrapper_args = ()
|
2019-11-25 06:52:36 +00:00
|
|
|
etcd_wrapper_kwargs = {'host': env_vars.get('ETCD_URL')}
|
2019-11-18 17:39:57 +00:00
|
|
|
|
|
|
|
etcd_client = Etcd3Wrapper(*etcd_wrapper_args, **etcd_wrapper_kwargs)
|
|
|
|
|
|
|
|
host_pool = HostPool(etcd_client, env_vars.get('HOST_PREFIX'))
|
|
|
|
vm_pool = VmPool(etcd_client, env_vars.get('VM_PREFIX'))
|
|
|
|
request_pool = RequestPool(etcd_client, env_vars.get('REQUEST_PREFIX'))
|
|
|
|
|
|
|
|
running_vms = []
|
2019-11-25 06:52:36 +00:00
|
|
|
|
|
|
|
__storage_backend = env_vars.get("STORAGE_BACKEND")
|
|
|
|
if __storage_backend == "filesystem":
|
|
|
|
image_storage_handler = FileSystemBasedImageStorageHandler(vm_base=env_vars.get("VM_DIR"),
|
|
|
|
image_base=env_vars.get("IMAGE_DIR"))
|
|
|
|
elif __storage_backend == "ceph":
|
|
|
|
image_storage_handler = CEPHBasedImageStorageHandler(vm_base="ssd", image_base="ssd")
|
|
|
|
else:
|
|
|
|
raise Exception("Unknown Image Storage Handler")
|