Django 2 migration

This commit is contained in:
Sebastian Lohff 2020-06-06 22:01:51 +02:00
parent 285ee74560
commit 31d4620adf
13 changed files with 39 additions and 37 deletions

View File

@ -39,7 +39,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('pingable', models.BooleanField(default=False)), ('pingable', models.BooleanField(default=False)),
('reachable', models.BooleanField(default=False)), ('reachable', models.BooleanField(default=False)),
('AS', models.ForeignKey(to='bgpdata.AS')), ('AS', models.ForeignKey(to='bgpdata.AS', on_delete=models.CASCADE)),
], ],
options={ options={
}, },
@ -73,10 +73,10 @@ class Migration(migrations.Migration):
fields=[ fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('origin', models.CharField(max_length=10, choices=[(b'path', b'BGP Path'), (b'direct', b'Direct Connection')])), ('origin', models.CharField(max_length=10, choices=[(b'path', b'BGP Path'), (b'direct', b'Direct Connection')])),
('as1', models.ForeignKey(related_name='peering1', to='bgpdata.AS')), ('as1', models.ForeignKey(related_name='peering1', to='bgpdata.AS', on_delete=models.CASCADE)),
('as2', models.ForeignKey(related_name='peering2', to='bgpdata.AS')), ('as2', models.ForeignKey(related_name='peering2', to='bgpdata.AS', on_delete=models.CASCADE)),
('router1', models.ForeignKey(related_name='peering1', default=None, to='bgpdata.BorderRouter', null=True)), ('router1', models.ForeignKey(related_name='peering1', default=None, to='bgpdata.BorderRouter', null=True, on_delete=models.CASCADE)),
('router2', models.ForeignKey(related_name='peering2', default=None, to='bgpdata.BorderRouter', null=True)), ('router2', models.ForeignKey(related_name='peering2', default=None, to='bgpdata.BorderRouter', null=True, on_delete=models.CASCADE)),
], ],
options={ options={
}, },
@ -85,13 +85,13 @@ class Migration(migrations.Migration):
migrations.AddField( migrations.AddField(
model_name='as', model_name='as',
name='crawl', name='crawl',
field=models.ForeignKey(to='bgpdata.CrawlRun'), field=models.ForeignKey(to='bgpdata.CrawlRun', on_delete=models.CASCADE),
preserve_default=True, preserve_default=True,
), ),
migrations.AddField( migrations.AddField(
model_name='announcement', model_name='announcement',
name='originAS', name='originAS',
field=models.ForeignKey(to='bgpdata.AS'), field=models.ForeignKey(to='bgpdata.AS', on_delete=models.CASCADE),
preserve_default=True, preserve_default=True,
), ),
] ]

View File

@ -18,8 +18,8 @@ class Migration(migrations.Migration):
('logtime', models.DateTimeField(auto_now_add=True)), ('logtime', models.DateTimeField(auto_now_add=True)),
('severity', models.CharField(max_length=10, choices=[(b'INFO', b'info'), (b'ERROR', b'error'), (b'DEBUG', b'debug'), (b'WARN', b'warning')])), ('severity', models.CharField(max_length=10, choices=[(b'INFO', b'info'), (b'ERROR', b'error'), (b'DEBUG', b'debug'), (b'WARN', b'warning')])),
('message', models.TextField()), ('message', models.TextField()),
('crawl', models.ForeignKey(to='bgpdata.CrawlRun')), ('crawl', models.ForeignKey(to='bgpdata.CrawlRun', on_delete=models.CASCADE)),
('host', models.ForeignKey(to='bgpdata.ConfigHost')), ('host', models.ForeignKey(to='bgpdata.ConfigHost', on_delete=models.SET_NULL)),
], ],
options={ options={
}, },

View File

@ -14,7 +14,7 @@ class Migration(migrations.Migration):
migrations.AlterField( migrations.AlterField(
model_name='crawllog', model_name='crawllog',
name='host', name='host',
field=models.ForeignKey(to='bgpdata.ConfigHost', null=True), field=models.ForeignKey(to='bgpdata.ConfigHost', null=True, on_delete=models.SET_NULL),
preserve_default=True, preserve_default=True,
), ),
] ]

View File

@ -20,7 +20,7 @@ class Migration(migrations.Migration):
migrations.AlterField( migrations.AlterField(
model_name='crawllog', model_name='crawllog',
name='host', name='host',
field=models.ForeignKey(blank=True, to='bgpdata.ConfigHost', null=True), field=models.ForeignKey(blank=True, to='bgpdata.ConfigHost', null=True, on_delete=models.CASCADE),
preserve_default=True, preserve_default=True,
), ),
] ]

View File

@ -15,8 +15,8 @@ class Migration(migrations.Migration):
name='BorderRouterPair', name='BorderRouterPair',
fields=[ fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('router1', models.ForeignKey(related_name='routerpair1', default=None, blank=True, to='bgpdata.BorderRouter', null=True)), ('router1', models.ForeignKey(related_name='routerpair1', default=None, blank=True, to='bgpdata.BorderRouter', null=True, on_delete=models.CASCADE)),
('router2', models.ForeignKey(related_name='routerpair2', default=None, blank=True, to='bgpdata.BorderRouter', null=True)), ('router2', models.ForeignKey(related_name='routerpair2', default=None, blank=True, to='bgpdata.BorderRouter', null=True, on_delete=models.CASCADE)),
], ],
options={ options={
}, },
@ -33,7 +33,7 @@ class Migration(migrations.Migration):
migrations.AddField( migrations.AddField(
model_name='announcement', model_name='announcement',
name='router', name='router',
field=models.ForeignKey(default=None, to='bgpdata.BorderRouter'), field=models.ForeignKey(default=None, to='bgpdata.BorderRouter', on_delete=models.CASCADE),
preserve_default=False, preserve_default=False,
), ),
migrations.AddField( migrations.AddField(

View File

@ -18,7 +18,7 @@ class Migration(migrations.Migration):
migrations.AddField( migrations.AddField(
model_name='borderrouterpair', model_name='borderrouterpair',
name='peering', name='peering',
field=models.ForeignKey(default=None, to='bgpdata.Peering'), field=models.ForeignKey(default=None, to='bgpdata.Peering', on_delete=models.CASCADE),
preserve_default=False, preserve_default=False,
), ),
] ]

View File

@ -14,7 +14,7 @@ class Migration(migrations.Migration):
migrations.AddField( migrations.AddField(
model_name='as', model_name='as',
name='lastSeen', name='lastSeen',
field=models.ForeignKey(related_name='as_lastseen', default=None, blank=True, to='bgpdata.CrawlRun', null=True), field=models.ForeignKey(related_name='as_lastseen', default=None, blank=True, to='bgpdata.CrawlRun', null=True, on_delete=models.SET_NULL),
preserve_default=True, preserve_default=True,
), ),
migrations.AddField( migrations.AddField(

View File

@ -14,7 +14,7 @@ class Migration(migrations.Migration):
migrations.AddField( migrations.AddField(
model_name='announcement', model_name='announcement',
name='crawlAS', name='crawlAS',
field=models.ForeignKey(related_name='crawl_as', to='bgpdata.AS', null=True), field=models.ForeignKey(related_name='crawl_as', to='bgpdata.AS', null=True, on_delete=models.CASCADE),
preserve_default=True, preserve_default=True,
), ),
migrations.AlterField( migrations.AlterField(

View File

@ -14,7 +14,7 @@ class Migration(migrations.Migration):
migrations.AlterField( migrations.AlterField(
model_name='announcement', model_name='announcement',
name='originAS', name='originAS',
field=models.ForeignKey(to='bgpdata.AS', null=True), field=models.ForeignKey(to='bgpdata.AS', null=True, on_delete=models.CASCADE),
preserve_default=True, preserve_default=True,
), ),
] ]

View File

@ -29,7 +29,7 @@ class CrawlRun(models.Model):
startTime = models.DateTimeField() startTime = models.DateTimeField()
endTime = models.DateTimeField(null=True, blank=True) endTime = models.DateTimeField(null=True, blank=True)
hostsCrawled = models.ManyToManyField(ConfigHost, null=True, blank=True) hostsCrawled = models.ManyToManyField(ConfigHost, blank=True)
graph = models.TextField() graph = models.TextField()
asCount = models.IntegerField(default=0) asCount = models.IntegerField(default=0)
@ -65,7 +65,7 @@ class CrawlLog(models.Model):
(WARN, 'warning'), (WARN, 'warning'),
) )
crawl = models.ForeignKey(CrawlRun) crawl = models.ForeignKey(CrawlRun, on_delete=models.CASCADE)
host = models.ForeignKey(ConfigHost, null=True, blank=True, on_delete=models.SET_NULL) host = models.ForeignKey(ConfigHost, null=True, blank=True, on_delete=models.SET_NULL)
logtime = models.DateTimeField(auto_now_add=True) logtime = models.DateTimeField(auto_now_add=True)
severity = models.CharField(max_length=10, choices=SEVERITY) severity = models.CharField(max_length=10, choices=SEVERITY)
@ -90,12 +90,13 @@ class CrawlLog(models.Model):
class AS(models.Model): class AS(models.Model):
# asno # asno
crawl = models.ForeignKey(CrawlRun) crawl = models.ForeignKey(CrawlRun, on_delete=models.CASCADE)
number = models.IntegerField(db_index=True) number = models.IntegerField(db_index=True)
directlyCrawled = models.BooleanField(default=False) directlyCrawled = models.BooleanField(default=False)
online = models.BooleanField(default=True, db_index=True) online = models.BooleanField(default=True, db_index=True)
lastSeen = models.ForeignKey(CrawlRun, blank=True, null=True, default=None, related_name='as_lastseen') lastSeen = models.ForeignKey(CrawlRun, blank=True, null=True, default=None, related_name='as_lastseen',
on_delete=models.CASCADE)
class Meta: class Meta:
unique_together = (('crawl', 'number'),) unique_together = (('crawl', 'number'),)
@ -126,7 +127,7 @@ class AS(models.Model):
class BorderRouter(models.Model): class BorderRouter(models.Model):
# as id, ip, check method, pingable, reachable # as id, ip, check method, pingable, reachable
# unique: (crawl_id, asno, as id) # unique: (crawl_id, asno, as id)
AS = models.ForeignKey(AS) AS = models.ForeignKey(AS, on_delete=models.CASCADE)
routerID = models.GenericIPAddressField() routerID = models.GenericIPAddressField()
pingable = models.BooleanField(default=False) pingable = models.BooleanField(default=False)
@ -139,7 +140,7 @@ class BorderRouter(models.Model):
class Announcement(models.Model): class Announcement(models.Model):
router = models.ForeignKey(BorderRouter) router = models.ForeignKey(BorderRouter, on_delete=models.CASCADE)
ip = models.GenericIPAddressField() ip = models.GenericIPAddressField()
prefix = models.IntegerField() prefix = models.IntegerField()
@ -147,8 +148,8 @@ class Announcement(models.Model):
# NOTE: increase length for longer pathes (currently supports a length of ~85) # NOTE: increase length for longer pathes (currently supports a length of ~85)
ASPath = models.CharField(max_length=512) ASPath = models.CharField(max_length=512)
nextHop = models.GenericIPAddressField() nextHop = models.GenericIPAddressField()
originAS = models.ForeignKey(AS, null=True) originAS = models.ForeignKey(AS, null=True, on_delete=models.CASCADE)
crawlAS = models.ForeignKey(AS, related_name='crawl_as', null=True) crawlAS = models.ForeignKey(AS, related_name='crawl_as', null=True, on_delete=models.CASCADE)
def __str__(self): def __str__(self):
return "%s/%s via %s (crawl %s)" % (self.ip, self.prefix, self.ASPath, self.router.AS.crawl.pk) return "%s/%s via %s (crawl %s)" % (self.ip, self.prefix, self.ASPath, self.router.AS.crawl.pk)
@ -167,8 +168,8 @@ class Peering(models.Model):
('as1', 'as2'), ('as1', 'as2'),
) )
as1 = models.ForeignKey(AS, related_name='peering1') as1 = models.ForeignKey(AS, related_name='peering1', on_delete=models.CASCADE)
as2 = models.ForeignKey(AS, related_name='peering2') as2 = models.ForeignKey(AS, related_name='peering2', on_delete=models.CASCADE)
origin = models.CharField(max_length=10, choices=ORIGIN) origin = models.CharField(max_length=10, choices=ORIGIN)
def __str__(self): def __str__(self):
@ -188,9 +189,11 @@ class Peering(models.Model):
class BorderRouterPair(models.Model): class BorderRouterPair(models.Model):
peering = models.ForeignKey(Peering) peering = models.ForeignKey(Peering, on_delete=models.CASCADE)
router1 = models.ForeignKey(BorderRouter, default=None, blank=True, null=True, related_name='routerpair1') router1 = models.ForeignKey(BorderRouter, default=None, blank=True, null=True, related_name='routerpair1',
router2 = models.ForeignKey(BorderRouter, default=None, blank=True, null=True, related_name='routerpair2') on_delete=models.CASCADE)
router2 = models.ForeignKey(BorderRouter, default=None, blank=True, null=True, related_name='routerpair2',
on_delete=models.CASCADE)
def __str__(self): def __str__(self):
return "%s <--> %s (crawl %d)" % (self.router1, self.router2, self.router1.AS.crawl.pk) return "%s <--> %s (crawl %d)" % (self.router1, self.router2, self.router1.AS.crawl.pk)
@ -208,7 +211,7 @@ class ASLastSeen(models.Model):
directlyCrawled = models.BooleanField(default=False) directlyCrawled = models.BooleanField(default=False)
online = models.BooleanField() online = models.BooleanField()
lastSeen = models.DateTimeField(blank=True, null=True) lastSeen = models.DateTimeField(blank=True, null=True)
crawlLastSeen = models.ForeignKey(CrawlRun) crawlLastSeen = models.ForeignKey(CrawlRun, null=True, on_delete=models.SET_NULL)
def __str__(self): def __str__(self):
return ("AS{} {}, last seen {} (crawl {})" return ("AS{} {}, last seen {} (crawl {})"
@ -217,4 +220,4 @@ class ASLastSeen(models.Model):
class ASLastSeenNeighbor(models.Model): class ASLastSeenNeighbor(models.Model):
asn = models.IntegerField() asn = models.IntegerField()
neighbor = models.ForeignKey(ASLastSeen) neighbor = models.ForeignKey(ASLastSeen, on_delete=models.CASCADE)

View File

@ -47,12 +47,11 @@ INSTALLED_APPS = (
API_LIMIT_PER_PAGE = 100 API_LIMIT_PER_PAGE = 100
MIDDLEWARE_CLASSES = ( MIDDLEWARE = (
'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware', 'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware',
) )

View File

@ -14,5 +14,5 @@ urlpatterns = (
url(r'^$', RedirectView.as_view(url='/map/')), url(r'^$', RedirectView.as_view(url='/map/')),
url(r'^map/', include(bgpdata.urls)), url(r'^map/', include(bgpdata.urls)),
url(r'^admin/', include(admin.site.urls)), url(r'^admin/', admin.site.urls),
) )

View File

@ -1,3 +1,3 @@
django==1.11.25 django<3
django-tastypie django-tastypie