Skip to content
This repository was archived by the owner on Nov 2, 2024. It is now read-only.

Commit a7d5261

Browse files
federicofantiniMichalsus
authored andcommitted
fixed migration ingestors (intelowlproject#2406)
1 parent 064d9b0 commit a7d5261

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

api_app/ingestors_manager/migrations/0021_ingestor_fix_malwarebazaar_threatfox.py

+31-4
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,60 @@
11
from django.db import migrations
2+
from django_celery_beat.models import PeriodicTask
23

34

45
def migrate(apps, schema_editor):
56
IngestorConfig = apps.get_model("ingestors_manager", "IngestorConfig")
67

78
ic_threatfox = IngestorConfig.objects.get(name="ThreatFox")
89
ic_malwarebazaar = IngestorConfig.objects.get(name="MalwareBazaar")
10+
pt_threatfox = PeriodicTask.objects.get(name="ThreatFoxIngestor")
11+
pt_malwarebazaar = PeriodicTask.objects.get(name="MalwareBazaarIngestor")
912

1013
ic_threatfox.disabled = True
1114
ic_malwarebazaar.disabled = True
15+
pt_threatfox.enabled = False
16+
pt_malwarebazaar.enabled = False
1217

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"
1523

24+
ic_threatfox.full_clean()
1625
ic_malwarebazaar.full_clean()
26+
pt_threatfox.full_clean()
27+
pt_malwarebazaar.full_clean()
28+
29+
ic_threatfox.save()
1730
ic_malwarebazaar.save()
31+
pt_threatfox.save()
32+
pt_malwarebazaar.save()
1833

1934

2035
def reverse_migrate(apps, schema_editor):
2136
IngestorConfig = apps.get_model("ingestors_manager", "IngestorConfig")
2237

2338
ic_threatfox = IngestorConfig.objects.get(name="ThreatFox")
2439
ic_malwarebazaar = IngestorConfig.objects.get(name="MalwareBazaar")
40+
pt_threatfox = PeriodicTask.objects.get(name="ThreatFoxIngestor")
41+
pt_malwarebazaar = PeriodicTask.objects.get(name="MalwareBazaarIngestor")
2542

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"
2848

49+
ic_threatfox.full_clean()
2950
ic_malwarebazaar.full_clean()
51+
pt_threatfox.full_clean()
52+
pt_malwarebazaar.full_clean()
53+
54+
ic_threatfox.save()
3055
ic_malwarebazaar.save()
56+
pt_threatfox.save()
57+
pt_malwarebazaar.save()
3158

3259

3360
class Migration(migrations.Migration):

0 commit comments

Comments
 (0)