Exemplo n.º 1
0
def port_counter_graph(request, interfaceid, kind='Octets'):
    """Creates an url to Graphite for rendering a graph as an image

    Redirects to the created url if successful
    """
    if kind not in (
            'Octets',
            'Errors',
            'UcastPkts',
            'Discards',
            'MulticastPkts',
            'BroadcastPkts',
    ):
        raise Http404

    timeframe = request.GET.get('timeframe', 'day')
    port = get_object_or_404(Interface, id=interfaceid)
    url = utils.get_interface_counter_graph_url(port,
                                                timeframe,
                                                kind,
                                                expect='png')

    if url:
        return redirect(url)
    else:
        return HttpResponse(status=500)
Exemplo n.º 2
0
def port_counter_graph(request, interfaceid, kind='Octets'):
    """Returns a JSON response containing a Graphite graph render URL for
    counter values for an interface.

    """
    if kind not in ('Octets', 'Errors', 'UcastPkts', 'Discards'):
        raise Http404

    timeframe = request.GET.get('timeframe', 'day')
    port = get_object_or_404(Interface, id=interfaceid)
    url = get_interface_counter_graph_url(port, timeframe, kind)

    if url:
        return redirect(url)
    else:
        return HttpResponse(status=500)
Exemplo n.º 3
0
def port_counter_graph(request, interfaceid, kind='Octets'):
    """Returns a JSON response containing a Graphite graph render URL for
    counter values for an interface.

    """
    if kind not in ('Octets', 'Errors', 'UcastPkts', 'Discards'):
        raise Http404

    timeframe = request.GET.get('timeframe', 'day')
    port = get_object_or_404(Interface, id=interfaceid)
    url = get_interface_counter_graph_url(port, timeframe, kind)

    if url:
        return redirect(url)
    else:
        return HttpResponse(status=500)
Exemplo n.º 4
0
def test_get_interface_counter_graph_url_should_handle_utf8():
    ifc = Mock()
    ifc.ifalias = u"æøå"
    assert get_interface_counter_graph_url(ifc) != ""
Exemplo n.º 5
0
def test_get_interface_counter_graph_url_should_handle_utf8():
    ifc = Mock()
    ifc.netbox.sysname = u"example-sw.example.org"
    ifc.ifname = u"Ethernet1/1"
    ifc.ifalias = u"æøå"
    assert get_interface_counter_graph_url(ifc) != ""