associate crawled hosts with crawlrun entry

This commit is contained in:
Sebastian Lohff 2015-03-28 22:33:06 +01:00
parent 96f11dcd26
commit 0ce6a266ae
3 changed files with 23 additions and 0 deletions

View File

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('bgpdata', '0011_auto_20150327_1636'),
]
operations = [
migrations.AddField(
model_name='crawlrun',
name='hostsCrawled',
field=models.ManyToManyField(to='bgpdata.ConfigHost', null=True, blank=True),
preserve_default=True,
),
]

View File

@ -23,6 +23,8 @@ class CrawlRun(models.Model):
startTime = models.DateTimeField()
endTime = models.DateTimeField(null=True, blank=True)
hostsCrawled = models.ManyToManyField(ConfigHost, null=True, blank=True)
def __unicode__(self):
return u"Run %d - %s to %s" % (self.pk, self.startTime, self.endTime if self.endTime else "?")

View File

@ -42,6 +42,7 @@ def main():
# 2. get data from all hosts, put it in the database
for host in ConfigHost.objects.all():
crawl.hostsCrawled.add(host)
data = None
print(" -- Getting data for host %s" % host)
try: