コード例 #1
0
def do_service_test(service_name, result_defer, wait_timeout):
    try:
        svc_info = api.service_info(service_name)
        if not svc_info or 'result' not in svc_info:
            lg.err('failed to fetch service info: %r' % svc_info)
            result_defer.callback(
                dict(
                    error='disconnected',
                    reason='{}_info_error'.format(service_name),
                ))
            return None
        svc_state = svc_info['result']['state']
    except:
        lg.exc('service "%s" test failed' % service_name)
        result_defer.callback(
            dict(
                error='disconnected',
                reason='{}_info_error'.format(service_name),
            ))
        return None
    if _Debug:
        lg.args(_DebugLevel,
                service=service_name,
                state=svc_state,
                wait_timeout=wait_timeout)
    if svc_state == 'STARTING':
        reactor.callLater(0.1, do_service_test, service_name, result_defer,
                          wait_timeout)  # @UndefinedVariable
        return None
    if svc_state != 'ON':
        do_service_restart(service_name, result_defer, wait_timeout)
        return None
    if service_name == 'service_network':
        reactor.callLater(0, do_service_test, 'service_gateway', result_defer,
                          wait_timeout)  # @UndefinedVariable
    elif service_name == 'service_gateway':
        reactor.callLater(0, do_service_test, 'service_p2p_hookups',
                          result_defer, wait_timeout)  # @UndefinedVariable
    elif service_name == 'service_p2p_hookups':
        reactor.callLater(0, do_p2p_connector_test,
                          result_defer)  # @UndefinedVariable
    elif service_name == 'service_proxy_transport':
        reactor.callLater(0, do_service_proxy_transport_test,
                          result_defer)  # @UndefinedVariable
    else:
        raise Exception('unknown service to test %s' % service_name)
    return None
コード例 #2
0
 def jsonrpc_service_info(self, service_name):
     return api.service_info(service_name)
コード例 #3
0
 def service_info_v1(self, request, service_name):
     return api.service_info(service_name)