|
1 | 1 | from django.db import migrations
|
| 2 | +from django_celery_beat.models import PeriodicTask |
2 | 3 |
|
3 | 4 |
|
4 | 5 | def migrate(apps, schema_editor):
|
5 | 6 | IngestorConfig = apps.get_model("ingestors_manager", "IngestorConfig")
|
6 | 7 |
|
7 | 8 | ic_threatfox = IngestorConfig.objects.get(name="ThreatFox")
|
8 | 9 | ic_malwarebazaar = IngestorConfig.objects.get(name="MalwareBazaar")
|
| 10 | + pt_threatfox = PeriodicTask.objects.get(name="ThreatFoxIngestor") |
| 11 | + pt_malwarebazaar = PeriodicTask.objects.get(name="MalwareBazaarIngestor") |
9 | 12 |
|
10 | 13 | ic_threatfox.disabled = True
|
11 | 14 | ic_malwarebazaar.disabled = True
|
| 15 | + pt_threatfox.enabled = False |
| 16 | + pt_malwarebazaar.enabled = False |
12 | 17 |
|
13 |
| - ic_threatfox.full_clean() |
14 |
| - ic_threatfox.save() |
| 18 | + ic_threatfox.routing_key = "ingestor" |
| 19 | + ic_malwarebazaar.routing_key = "ingestor" |
| 20 | + |
| 21 | + pt_threatfox.queue = "ingestor" |
| 22 | + pt_malwarebazaar.queue = "ingestor" |
15 | 23 |
|
| 24 | + ic_threatfox.full_clean() |
16 | 25 | ic_malwarebazaar.full_clean()
|
| 26 | + pt_threatfox.full_clean() |
| 27 | + pt_malwarebazaar.full_clean() |
| 28 | + |
| 29 | + ic_threatfox.save() |
17 | 30 | ic_malwarebazaar.save()
|
| 31 | + pt_threatfox.save() |
| 32 | + pt_malwarebazaar.save() |
18 | 33 |
|
19 | 34 |
|
20 | 35 | def reverse_migrate(apps, schema_editor):
|
21 | 36 | IngestorConfig = apps.get_model("ingestors_manager", "IngestorConfig")
|
22 | 37 |
|
23 | 38 | ic_threatfox = IngestorConfig.objects.get(name="ThreatFox")
|
24 | 39 | ic_malwarebazaar = IngestorConfig.objects.get(name="MalwareBazaar")
|
| 40 | + pt_threatfox = PeriodicTask.objects.get(name="ThreatFoxIngestor") |
| 41 | + pt_malwarebazaar = PeriodicTask.objects.get(name="MalwareBazaarIngestor") |
25 | 42 |
|
26 |
| - ic_threatfox.full_clean() |
27 |
| - ic_threatfox.save() |
| 43 | + ic_threatfox.routing_key = "default" |
| 44 | + ic_malwarebazaar.routing_key = "default" |
| 45 | + |
| 46 | + pt_threatfox.queue = "default" |
| 47 | + pt_malwarebazaar.queue = "default" |
28 | 48 |
|
| 49 | + ic_threatfox.full_clean() |
29 | 50 | ic_malwarebazaar.full_clean()
|
| 51 | + pt_threatfox.full_clean() |
| 52 | + pt_malwarebazaar.full_clean() |
| 53 | + |
| 54 | + ic_threatfox.save() |
30 | 55 | ic_malwarebazaar.save()
|
| 56 | + pt_threatfox.save() |
| 57 | + pt_malwarebazaar.save() |
31 | 58 |
|
32 | 59 |
|
33 | 60 | class Migration(migrations.Migration):
|
|
0 commit comments