Browse Source

associate crawled hosts with crawlrun entry

master
Sebastian Lohff 7 years ago
parent
commit
0ce6a266ae
  1. 20
      bgpdata/migrations/0012_crawlrun_hostscrawled.py
  2. 2
      bgpdata/models.py
  3. 1
      bin/crawl.py

20
bgpdata/migrations/0012_crawlrun_hostscrawled.py

@ -0,0 +1,20 @@ @@ -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,
),
]

2
bgpdata/models.py

@ -23,6 +23,8 @@ class CrawlRun(models.Model): @@ -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 "?")

1
bin/crawl.py

@ -42,6 +42,7 @@ def main(): @@ -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:

Loading…
Cancel
Save