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)),
('pingable', 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={
},
@ -73,10 +73,10 @@ class Migration(migrations.Migration):
fields=[
('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')])),
('as1', models.ForeignKey(related_name='peering1', to='bgpdata.AS')),
('as2', models.ForeignKey(related_name='peering2', to='bgpdata.AS')),
('router1', models.ForeignKey(related_name='peering1', default=None, to='bgpdata.BorderRouter', null=True)),
('router2', models.ForeignKey(related_name='peering2', default=None, to='bgpdata.BorderRouter', null=True)),
('as1', models.ForeignKey(related_name='peering1', to='bgpdata.AS', on_delete=models.CASCADE)),
('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, on_delete=models.CASCADE)),
('router2', models.ForeignKey(related_name='peering2', default=None, to='bgpdata.BorderRouter', null=True, on_delete=models.CASCADE)),
],
options={
},
@ -85,13 +85,13 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='as',
name='crawl',
field=models.ForeignKey(to='bgpdata.CrawlRun'),
field=models.ForeignKey(to='bgpdata.CrawlRun', on_delete=models.CASCADE),
preserve_default=True,
),
migrations.AddField(
model_name='announcement',
name='originAS',
field=models.ForeignKey(to='bgpdata.AS'),
field=models.ForeignKey(to='bgpdata.AS', on_delete=models.CASCADE),
preserve_default=True,
),
]

View File

@ -18,8 +18,8 @@ class Migration(migrations.Migration):
('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')])),
('message', models.TextField()),
('crawl', models.ForeignKey(to='bgpdata.CrawlRun')),
('host', models.ForeignKey(to='bgpdata.ConfigHost')),
('crawl', models.ForeignKey(to='bgpdata.CrawlRun', on_delete=models.CASCADE)),
('host', models.ForeignKey(to='bgpdata.ConfigHost', on_delete=models.SET_NULL)),
],
options={
},

View File

@ -14,7 +14,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='crawllog',
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,
),
]

View File

@ -20,7 +20,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='crawllog',
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,
),
]

View File

@ -15,8 +15,8 @@ class Migration(migrations.Migration):
name='BorderRouterPair',
fields=[
('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)),
('router2', models.ForeignKey(related_name='routerpair2', 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, on_delete=models.CASCADE)),
],
options={
},
@ -33,7 +33,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='announcement',
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,
),
migrations.AddField(

View File

@ -18,7 +18,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='borderrouterpair',
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,
),
]

View File

@ -14,7 +14,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='as',
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,
),
migrations.AddField(

View File

@ -14,7 +14,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='announcement',
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,
),
migrations.AlterField(

View File

@ -14,7 +14,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='announcement',
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,
),
]

View File

@ -29,7 +29,7 @@ class CrawlRun(models.Model):
startTime = models.DateTimeField()
endTime = models.DateTimeField(null=True, blank=True)
hostsCrawled = models.ManyToManyField(ConfigHost, null=True, blank=True)
hostsCrawled = models.ManyToManyField(ConfigHost, blank=True)
graph = models.TextField()
asCount = models.IntegerField(default=0)
@ -65,7 +65,7 @@ class CrawlLog(models.Model):
(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)
logtime = models.DateTimeField(auto_now_add=True)
severity = models.CharField(max_length=10, choices=SEVERITY)
@ -90,12 +90,13 @@ class CrawlLog(models.Model):
class AS(models.Model):
# asno
crawl = models.ForeignKey(CrawlRun)
crawl = models.ForeignKey(CrawlRun, on_delete=models.CASCADE)
number = models.IntegerField(db_index=True)
directlyCrawled = models.BooleanField(default=False)
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:
unique_together = (('crawl', 'number'),)
@ -126,7 +127,7 @@ class AS(models.Model):
class BorderRouter(models.Model):
# as id, ip, check method, pingable, reachable
# unique: (crawl_id, asno, as id)
AS = models.ForeignKey(AS)
AS = models.ForeignKey(AS, on_delete=models.CASCADE)
routerID = models.GenericIPAddressField()
pingable = models.BooleanField(default=False)
@ -139,7 +140,7 @@ class BorderRouter(models.Model):
class Announcement(models.Model):
router = models.ForeignKey(BorderRouter)
router = models.ForeignKey(BorderRouter, on_delete=models.CASCADE)
ip = models.GenericIPAddressField()
prefix = models.IntegerField()
@ -147,8 +148,8 @@ class Announcement(models.Model):
# NOTE: increase length for longer pathes (currently supports a length of ~85)
ASPath = models.CharField(max_length=512)
nextHop = models.GenericIPAddressField()
originAS = models.ForeignKey(AS, null=True)
crawlAS = models.ForeignKey(AS, related_name='crawl_as', null=True)
originAS = models.ForeignKey(AS, null=True, on_delete=models.CASCADE)
crawlAS = models.ForeignKey(AS, related_name='crawl_as', null=True, on_delete=models.CASCADE)
def __str__(self):
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 = models.ForeignKey(AS, related_name='peering1')
as2 = models.ForeignKey(AS, related_name='peering2')
as1 = models.ForeignKey(AS, related_name='peering1', on_delete=models.CASCADE)
as2 = models.ForeignKey(AS, related_name='peering2', on_delete=models.CASCADE)
origin = models.CharField(max_length=10, choices=ORIGIN)
def __str__(self):
@ -188,9 +189,11 @@ class Peering(models.Model):
class BorderRouterPair(models.Model):
peering = models.ForeignKey(Peering)
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')
peering = models.ForeignKey(Peering, on_delete=models.CASCADE)
router1 = models.ForeignKey(BorderRouter, default=None, blank=True, null=True, related_name='routerpair1',
on_delete=models.CASCADE)
router2 = models.ForeignKey(BorderRouter, default=None, blank=True, null=True, related_name='routerpair2',
on_delete=models.CASCADE)
def __str__(self):
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)
online = models.BooleanField()
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):
return ("AS{} {}, last seen {} (crawl {})"
@ -217,4 +220,4 @@ class ASLastSeen(models.Model):
class ASLastSeenNeighbor(models.Model):
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
MIDDLEWARE_CLASSES = (
MIDDLEWARE = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

View File

@ -14,5 +14,5 @@ urlpatterns = (
url(r'^$', RedirectView.as_view(url='/map/')),
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