From 0ce6a266aed4a596a16dd9a4108ff9be722cd3ba Mon Sep 17 00:00:00 2001 From: Sebastian Lohff Date: Sat, 28 Mar 2015 22:33:06 +0100 Subject: [PATCH] associate crawled hosts with crawlrun entry --- .../migrations/0012_crawlrun_hostscrawled.py | 20 +++++++++++++++++++ bgpdata/models.py | 2 ++ bin/crawl.py | 1 + 3 files changed, 23 insertions(+) create mode 100644 bgpdata/migrations/0012_crawlrun_hostscrawled.py diff --git a/bgpdata/migrations/0012_crawlrun_hostscrawled.py b/bgpdata/migrations/0012_crawlrun_hostscrawled.py new file mode 100644 index 0000000..40ae89c --- /dev/null +++ b/bgpdata/migrations/0012_crawlrun_hostscrawled.py @@ -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, + ), + ] diff --git a/bgpdata/models.py b/bgpdata/models.py index 04db76d..3303f62 100644 --- a/bgpdata/models.py +++ b/bgpdata/models.py @@ -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 "?") diff --git a/bin/crawl.py b/bin/crawl.py index c43e0ab..550b525 100755 --- a/bin/crawl.py +++ b/bin/crawl.py @@ -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: