- Better error reporting.
- Flask now uses application's logger instead of its own. - ucloud file scanner refactored.
This commit is contained in:
parent
eea6c1568e
commit
972bb5a920
14 changed files with 157 additions and 154 deletions
|
|
@ -16,8 +16,7 @@ vmm = virtualmachine.VMM()
|
|||
def update_heartbeat(hostname):
|
||||
"""Update Last HeartBeat Time for :param hostname: in etcd"""
|
||||
|
||||
client = shared.etcd_client
|
||||
host_pool = HostPool(client)
|
||||
host_pool = shared.host_pool
|
||||
this_host = next(filter(lambda h: h.hostname == hostname, host_pool.hosts), None)
|
||||
|
||||
while True:
|
||||
|
|
@ -27,7 +26,7 @@ def update_heartbeat(hostname):
|
|||
|
||||
|
||||
def main(hostname):
|
||||
host_pool = HostPool(shared.etcd_client)
|
||||
host_pool = shared.host_pool
|
||||
host = next(filter(lambda h: h.hostname == hostname, host_pool.hosts), None)
|
||||
assert host is not None, "No such host with name = {}".format(hostname)
|
||||
|
||||
|
|
|
|||
|
|
@ -44,29 +44,7 @@ def capture_all_exception(func):
|
|||
try:
|
||||
func(*args, **kwargs)
|
||||
except Exception:
|
||||
logger.info("Exception absorbed by captual_all_exception()")
|
||||
logger.exception(func.__name__)
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
def need_running_vm(func):
|
||||
@wraps(func)
|
||||
def wrapper(self, e):
|
||||
vm = self.get_vm(self.running_vms, e.key)
|
||||
if vm:
|
||||
try:
|
||||
status = vm.handle.command("query-status")
|
||||
logger.debug("VM Status Check - %s", status)
|
||||
except Exception as exception:
|
||||
logger.info("%s failed - VM %s %s", func.__name__, e, exception)
|
||||
else:
|
||||
return func(e)
|
||||
|
||||
return None
|
||||
else:
|
||||
logger.info("%s failed because VM %s is not running", func.__name__, e.key)
|
||||
return None
|
||||
logger.exception('Unhandled exception occur in %s. For more details see Syslog.', __name__)
|
||||
|
||||
return wrapper
|
||||
|
||||
|
|
@ -168,7 +146,6 @@ class VMM:
|
|||
self.create(vm_entry)
|
||||
self.launch_vm(vm_entry)
|
||||
|
||||
@need_running_vm
|
||||
@capture_all_exception
|
||||
def stop(self, vm_entry):
|
||||
vm = self.get_vm(self.running_vms, vm_entry.key)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue