change logging

This commit is contained in:
deflax 2016-04-02 04:29:22 +03:00
parent d98ca0c5ae
commit f21cc8449d
2 changed files with 10 additions and 4 deletions

View file

@ -50,7 +50,7 @@ def sync(cached=True):
real_slave = { "id":slave_id, "slave":slave_name, "masterip":slave_masterip, "password":decoded_password } real_slave = { "id":slave_id, "slave":slave_name, "masterip":slave_masterip, "password":decoded_password }
optional_slave = {} optional_slave = {}
cache_file = 'cache-slave-' + slave_id + '.json' cache_file = 'cache-slave-' + slave_id + '.json'
prefix = 'cache> [' + slave_name + '] ' prefix = 'slave[' + slave_name + ']> '
# check if slave is in current region and include it in current dict if it is # check if slave is in current region and include it in current dict if it is
if slave_regionid == region_id: if slave_regionid == region_id:
@ -60,7 +60,7 @@ def sync(cached=True):
proxobject = plugin.auth(slave_id, slave_masterip, enc_slave_password) proxobject = plugin.auth(slave_id, slave_masterip, enc_slave_password)
vmlist = plugin.vmlist(proxobject) vmlist = plugin.vmlist(proxobject)
real_slave['alive'] = 'up' real_slave['alive'] = 'up'
logger.info(prefix + 'is up') logger.info(prefix + 'is online')
except: except:
#raise #raise
#slave cant be read so it will be marked down. #slave cant be read so it will be marked down.
@ -342,7 +342,7 @@ def query_vm(req_vmid):
logger.error('vm[{}]> type is unknown!'.format(vm_id)) logger.error('vm[{}]> type is unknown!'.format(vm_id))
raise raise
logger.info('vm[{}]> type={} path={}'.format(target, vm_type, str(path))) #logger.info('vm[{}]> type={} path={}'.format(target, vm_type, str(path)))
return slave_id, vm_type return slave_id, vm_type

View file

@ -19,12 +19,14 @@ import clientsdb
config = ioconfig.parser config = ioconfig.parser
logger = ioconfig.logger logger = ioconfig.logger
def welcome(): def welcome():
"""displays motd in log as welcome message""" """displays motd in log as welcome message"""
logger.info('###################################') logger.info('###################################')
logger.info('# proxmaster ][ (c) 2015-2016 afx #') logger.info('# proxmaster ][ (c) 2015-2016 afx #')
logger.info('###################################') logger.info('###################################')
def apicheck(params): def apicheck(params):
""" compares request params for api key with the config file""" """ compares request params for api key with the config file"""
try: try:
@ -43,6 +45,7 @@ def apicheck(params):
finally: finally:
return (status, response) return (status, response)
#API methods #API methods
class Validate(object): class Validate(object):
def on_post(self, req, resp): def on_post(self, req, resp):
@ -58,7 +61,6 @@ class Validate(object):
else: else:
resp.status = falcon.HTTP_403 resp.status = falcon.HTTP_403
resp.body = 'ERR' resp.body = 'ERR'
class ClusterResource(object): class ClusterResource(object):
@ -91,6 +93,7 @@ class ClusterResource(object):
resp.status = falcon.HTTP_403 resp.status = falcon.HTTP_403
resp.body = apicheck_resp resp.body = apicheck_resp
class StatusResource(object): class StatusResource(object):
def on_get(self, req, resp, vmid): def on_get(self, req, resp, vmid):
""" check vm status """ """ check vm status """
@ -129,6 +132,7 @@ class DeleteResource(object):
resp.status = falcon.HTTP_403 resp.status = falcon.HTTP_403
resp.body = apicheck_resp resp.body = apicheck_resp
class ArchivateResource(object): class ArchivateResource(object):
def on_post(self, req, resp, vmid): def on_post(self, req, resp, vmid):
""" Temporary suspend the instance """ """ Temporary suspend the instance """
@ -148,6 +152,7 @@ class ArchivateResource(object):
resp.status = falcon.HTTP_403 resp.status = falcon.HTTP_403
resp.body = apicheck_resp resp.body = apicheck_resp
class UnArchiveResource(object): class UnArchiveResource(object):
def on_post(self, req, resp, vmid): def on_post(self, req, resp, vmid):
""" Unuspend the instance """ """ Unuspend the instance """
@ -167,6 +172,7 @@ class UnArchiveResource(object):
resp.status = falcon.HTTP_403 resp.status = falcon.HTTP_403
resp.body = apicheck_resp resp.body = apicheck_resp
class StartResource(object): class StartResource(object):
def on_post(self, req, resp, vmid): def on_post(self, req, resp, vmid):
""" Start the instance """ """ Start the instance """