Ejemplo n.º 1
0
def show_multimessage(request, multimessage_id):
    ctx = _ctx()
    with get_service_cm() as service:
        multimessage = service.get_multimessage(multimessage_id)
    if multimessage is None:
        return HttpResponseNotFound("MultiMessage with ID '{0}' was not found".format(multimessage_id))
    ctx['multimessage'] = multimessage
    return HttpResponse(render_to_response('daedalus/frontend/multi_message_show.html',
        context_instance=RequestContext(request, ctx)))
Ejemplo n.º 2
0
def status(request):
    status_list = []
    ctx = _ctx(status_list=status_list)
    with get_service_cm(cache_enabled=False) as service:
        storage_status = service.get_status()
    for key in sorted(storage_status.keys()):
        status_list.append((key, storage_status[key]))
    return HttpResponse(render_to_response('daedalus/frontend/status.html',
        context_instance=RequestContext(request, ctx)))
Ejemplo n.º 3
0
def save_log(request):
    application = request.POST.get('application', None)
    host = request.POST.get('host', None)
    severity = request.POST.get('severity', None)
    timestamp = request.POST.get('timestamp', None)
    message = request.POST.get('message', None)

    with get_service_cm() as storage_service:
        try:
            storage_service.save_log(application, host, severity, timestamp, message)
        except DaedalusException, de:
            return HttpResponseBadRequest(json.dumps({'status': 'error', 'error': unicode(de.message)}))
Ejemplo n.º 4
0
def search_by_host(request, host):
    with get_service_cm() as service:
        from_col = service.str_to_column_key(request.GET.get('from', None))
        result = service.query_by_host(host, from_col=from_col)
    if result:
        last_message_id = result[-1]['_id']
    else:
        last_message_id = None
    ctx = _ctx(result=result, last_message_id=last_message_id,
        top_message="Showing only messages from host '{0}'.".format(host))
    return HttpResponse(render_to_response('daedalus/frontend/index.html',
        context_instance=RequestContext(request, ctx)))
Ejemplo n.º 5
0
def home(request):
    ctx = _ctx()
    with get_service_cm() as service:
        from_col = service.str_to_column_key(request.GET.get('from', None))
        try:
            ctx['result'] = service.query(from_col=from_col)
            if ctx['result']:
                ctx['last_message_id'] = ctx['result'][-1]['_id']
        except:
            ctx['render_messages'].append("Error detected while executing query()")
            logger.exception(ctx['render_messages'][-1])
    return HttpResponse(render_to_response('daedalus/frontend/index.html',
        context_instance=RequestContext(request, ctx)))
Ejemplo n.º 6
0
def _ctx(**kwargs):
    """
    Generates a context instance for rendering the Django view.
    """
    ctx = dict(kwargs)
    ctx['render_messages'] = []
    with get_service_cm() as service:
        try:
            ctx['app_list'] = service.list_applications()
        except:
            ctx['render_messages'].append("Error detected while trying to get application list")
            logger.exception(ctx['render_messages'][-1])
    
        try:
            ctx['host_list'] = service.list_hosts()
        except:
            ctx['render_messages'].append("Error detected while trying to get host list")
            logger.exception(ctx['render_messages'][-1])
    
        try:
            ctx['error_count'] = service.get_error_count()
        except:
            ctx['error_count'] = '?'
            ctx['render_messages'].append("Error detected while trying to get the count of ERRORs")
            logger.exception(ctx['render_messages'][-1])
    
        try:
            ctx['warn_count'] = service.get_warn_count()
        except:
            ctx['warn_count'] = '?'
            ctx['render_messages'].append("Error detected while trying to get the count of WARNs")
            logger.exception(ctx['render_messages'][-1])
    
        try:
            ctx['info_count'] = service.get_info_count()
        except:
            ctx['info_count'] = '?'
            ctx['render_messages'].append("Error detected while trying to get the count of INFOs")
            logger.exception(ctx['render_messages'][-1])
    
        try:
            ctx['debug_count'] = service.get_debug_count()
        except:
            ctx['debug_count'] = '?'
            ctx['render_messages'].append("Error detected while trying to get the count of DEBUGs")
            logger.exception(ctx['render_messages'][-1])

    return ctx
Ejemplo n.º 7
0
def charts(request, chart_type=None):
    ctx = _ctx()
    with get_service_cm() as service:
        if chart_type == '24hs':
            charts_data = service.generate_24hs_charts_data()
            chart_id = '24hs'
        elif chart_type == '48hs':
            charts_data = service.generate_48hs_charts_data()
            chart_id = '48hs'
        elif chart_type == '7d':
            charts_data = service.generate_7d_charts_data()
            chart_id = '7d'
        else:
            charts_data = service.generate_6hs_charts_data()
            chart_id = '6hs'
    ctx['charts_data'] = charts_data
    ctx['chart_id'] = chart_id
    return HttpResponse(render_to_response('daedalus/frontend/charts.html',
        context_instance=RequestContext(request, ctx)))
Ejemplo n.º 8
0
 def handle(self, *args, **options):
     with get_service_cm() as service:
         service.create_keyspace_and_cfs()
Ejemplo n.º 9
0
 def handle(self, *args, **options):
     with get_service_cm() as service:
         service.create_keyspace_and_cfs()
Ejemplo n.º 10
0
def get_message_detail(request, message_id):
    with get_service_cm() as service:
        obj = service.get_by_id(message_id)
    return HttpResponse(json.dumps(obj), mimetype='application/json')