Exemplo n.º 1
0
    def __wrapper(*args, **kwargs):

        log.critical('Function(%s) start execute' % (func.__name__))
        start_time = time.time()

        try:
            result = func(*args, **kwargs)
        except Exception, e:
            log.error('Function(%s) exec error, reason = %s' %
                      (func.__name__, e))
            return request_result(601)
Exemplo n.º 2
0
    def __wrapper(*args, **kwargs):

        func_info = type(
            inspect.getcallargs(func, *args, **kwargs).get('self'))
        log.critical('Method(%s.%s) start execute' %
                     (func_info, func.__name__))
        start_time = time.time()

        try:
            result = func(*args, **kwargs)
        except Exception, e:
            log.error('Method(%s.%s) exec error, reason = %s' %
                      (func_info, func.__name__, e))
            return request_result(601)
Exemplo n.º 3
0
def server_start(service_name):

    from conf import conf
    from common.logs import logging as log
    from api_register import rest_app_run

    api_host = conf.api_server
    port = conf.compute_port
    debug = conf.api_debug

    while True:
        try:
            log.critical('Starting %s Restful API Server' % (service_name))
            rest_app_run(api_host, port, debug)
        except Exception, e:
            log.error('%s RESTful API Server running error, reason=%s'
                      % (service_name, e))
        time.sleep(10)
                                              resource_uuid=vm_uuid)
            except Exception, e:
                log.error('cloudhost reclaim failure, reason=%s' % (e))

    def cloudhost_reclaim_delete(self):

        try:
            ret = self.ucenter_api.service_token()
            if int(ret.get('status')) == 0:
                token = ret['result']['user_token']
            else:
                raise (Exception('request_code not equal 0'))
        except Exception, e:
            log.error('Get service token error: reason=%s' % (e))
            return request_result(601)

        try:
            cloudhosts_list = self.compute_db.cloudhost_list_dead(
            )['cloudhost_list']
            for cloudhost_info in cloudhosts_list:
                vm_uuid = cloudhost_info['vm_uuid']
                vm_name = cloudhost_info['vm_name']

                self.compute_db.cloudhost_delete(vm_uuid)
                log.critical('cloudhost name=%s, uuid=%s, '
                             'physical delete finish.' % (vm_name, vm_uuid))
        except Exception, e:
            log.error('cloudhost reclaim delete failure, '
                      'vm_uuid=%s, vm_name=%s, reason=%s' %
                      (vm_uuid, vm_name, e))