Exemplo n.º 1
0
def listado(request):
    if "query_iface" in request.GET and request.GET["query_iface"] != "":
        query_sent = request.GET["query_iface"]

        query = Iface.objects.query_cmd(query_sent)
        if query is None:
            query = Iface.objects.filter(
                Q(vlan__name__iregex=query_sent) | Q(ip__iregex=query_sent) | Q(mac__icontains=query_sent)
            )
    else:
        query = Iface.objects.all()
        query_sent = None
    print query.query
    listado = paginator(query, request)

    # if no iface is found, it shows advanced iface info
    if len(listado.object_list) == 0:
        try:
            ipaddr.IPv4Address(query_sent)
            vlan = Iface.find_vlan(query_sent)
            eirs = Iface.excluded_in_ranges(ip=query_sent, vlan=vlan)
            conflicts = ConflictingIP.objects.filter(ip=query_sent)
            return render_to_response(
                "iface/adv_info.html",
                {"vlan": vlan, "eirs": eirs, "ip": query_sent, "conflicts": conflicts},
                context_instance=RequestContext(request),
            )
        except Exception:
            pass

    #    if len(listado.object_list) == 1:
    #        obj = listado.object_list[0]
    #        return redirect(reverse("iface", args=[obj.pk, ]))
    return render_to_response("iface/list.html", {"listado": listado}, context_instance=RequestContext(request))
Exemplo n.º 2
0
def listado(request):
    #TODO change from icontains to iregex
    if "query_machine" in request.GET and request.GET["query_machine"] != "":
        qm = request.GET["query_machine"]
        query = Machine.objects.filter(
            Q(hostname__icontains=qm)|
            Q(dns_zone__name__icontains=qm)|
            Q(mtype__name__icontains=qm)|
            Q(environment__code__icontains=qm)
            )
        print query.query
    else:
        query = Machine.objects.all()

    listado = paginator(query, request)

#    if len(listado.object_list) == 1:
#        obj = listado.object_list[0]
#        return redirect(reverse("machine", args=[obj.pk, ]))
    return render_to_response(
        'machine/list.html',
        {"listado": listado},
        context_instance=RequestContext(request))
Exemplo n.º 3
0
def listado(request):
    #TODO change from icontains to iregex
    if "query_service" in request.GET and request.GET["query_service"] != "": #Si busco un service concreto
        qs = request.GET["query_service"]
        query = Service.objects.filter(
            Q(name__icontains=qs) |
            Q(description__icontains=qs) |
            Q(iface__ip__icontains=qs) |
            Q(iface__vlan__name__icontains=qs) |
            Q(iface__vlan__tag__icontains=qs)
        )
        print query.query
    else: #Si quiero un listado de todos los services
        query = Service.objects.all()

    listado = paginator(query, request)

#    if len(listado.object_list) == 1:
#        obj = listado.object_list[0]
#        return redirect(reverse("service", args=[obj.pk, ]))
    return render_to_response(
        'service/list.html',
        {"listado": listado},
        context_instance=RequestContext(request))