[scheduler] refactored from env_vars to config

This commit is contained in:
llnu 2019-12-08 13:23:26 +01:00
parent cfb09c29de
commit 7486fafbaa

View file

@ -6,7 +6,7 @@
from ucloud.common.request import RequestEntry, RequestType
from ucloud.config import etcd_client
from ucloud.config import host_pool, request_pool, vm_pool, env_vars
from ucloud.config import host_pool, request_pool, vm_pool, config
from .helper import (get_suitable_host, dead_host_mitigation, dead_host_detection,
assign_host, NoSuitableHostFound)
from . import logger
@ -18,8 +18,8 @@ def main():
pending_vms = []
for request_iterator in [
etcd_client.get_prefix(env_vars.get('REQUEST_PREFIX'), value_in_json=True),
etcd_client.watch_prefix(env_vars.get('REQUEST_PREFIX'), timeout=5, value_in_json=True),
etcd_client.get_prefix(config['etcd']['REQUEST_PREFIX'], value_in_json=True),
etcd_client.watch_prefix(config['etcd']['REQUEST_PREFIX'], timeout=5, value_in_json=True),
]:
for request_event in request_iterator:
request_entry = RequestEntry(request_event)
@ -46,7 +46,7 @@ def main():
r = RequestEntry.from_scratch(type="ScheduleVM",
uuid=pending_vm_entry.uuid,
hostname=pending_vm_entry.hostname,
request_prefix=env_vars.get("REQUEST_PREFIX"))
request_prefix=config['etcd']["REQUEST_PREFIX"])
request_pool.put(r)
elif request_entry.type == RequestType.ScheduleVM:
@ -72,7 +72,7 @@ def main():
r = RequestEntry.from_scratch(type=RequestType.InitVMMigration,
uuid=request_entry.uuid,
destination=request_entry.destination,
request_prefix=env_vars.get("REQUEST_PREFIX"))
request_prefix=config['etcd']["REQUEST_PREFIX"])
request_pool.put(r)
# If the Request is about a VM that just want to get started/created