dnmapper/bgpdata/views.py

25 lines
885 B
Python
Raw Normal View History

2018-01-19 13:28:52 +01:00
# This file is part of dnmapper, an AS--level mapping tool
# Licensed under GNU General Public License v3 or later
# Written by Sebastian Lohff (seba@someserver.de)
2015-03-23 01:42:31 +01:00
from django.shortcuts import render
2015-03-27 15:33:54 +01:00
from bgpdata.models import CrawlRun, AS, Peering
2017-01-14 00:15:21 +01:00
from django.core.paginator import Paginator
2015-03-23 01:42:31 +01:00
2015-03-27 15:33:54 +01:00
def overview(request):
crawls = CrawlRun.objects.order_by("-startTime")
2017-04-11 01:05:58 +02:00
crawlsPage = Paginator(crawls, 200)
2017-01-14 00:15:21 +01:00
return render(request, 'bgpdata/overview.html', {"crawls": crawlsPage.page(1)})
2015-03-27 15:33:54 +01:00
def showMap(request, crawlId):
2015-03-28 22:12:42 +01:00
crawl = None
try:
crawl = CrawlRun.objects.get(id=crawlId)
except CrawlRun.DoesNotExist:
return render(request, "bgpdata/no-map-found.html", {"crawl_id": crawlId})
2015-03-27 15:33:54 +01:00
ASses = AS.objects.filter(crawl=crawl)
peerings = Peering.objects.filter(as1__crawl=crawl)
return render(request, 'bgpdata/map.html', {"crawl": crawl, 'ASses': ASses, 'peerings': peerings})