From 706bbf58dd04111fdb88473dca94f2bf13ca28cc Mon Sep 17 00:00:00 2001 From: Peter Eckel Date: Fri, 28 Oct 2022 09:08:57 +0200 Subject: [PATCH 1/2] Set TTL for the zones' NS records to None --- netbox_dns/migrations/0018_update_ns_ttl.py | 20 ++++++++++++++++++++ netbox_dns/models.py | 2 -- 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 netbox_dns/migrations/0018_update_ns_ttl.py diff --git a/netbox_dns/migrations/0018_update_ns_ttl.py b/netbox_dns/migrations/0018_update_ns_ttl.py new file mode 100644 index 0000000..4db91a3 --- /dev/null +++ b/netbox_dns/migrations/0018_update_ns_ttl.py @@ -0,0 +1,20 @@ +from django.db import migrations + + +def update_ns_ttl(apps, schema_editor): + Zone = apps.get_model("netbox_dns", "Zone") + + for zone in Zone.objects.all(): + for nameserver in zone.nameservers.all(): + nameserver.ttl = None + + +class Migration(migrations.Migration): + + dependencies = [ + ("netbox_dns", "0017_alter_record_ttl"), + ] + + operations = [ + migrations.RunPython(update_ns_ttl), + ] diff --git a/netbox_dns/models.py b/netbox_dns/models.py index 59746ae..f511ead 100644 --- a/netbox_dns/models.py +++ b/netbox_dns/models.py @@ -273,7 +273,6 @@ def update_soa_record(self): def update_ns_records(self, nameservers): ns_name = "@" - ns_ttl = self.default_ttl delete_ns = self.record_set.filter( type=RecordTypeChoices.NS, managed=True @@ -286,7 +285,6 @@ def update_ns_records(self, nameservers): zone_id=self.pk, type=RecordTypeChoices.NS, name=ns_name, - ttl=ns_ttl, value=ns, managed=True, ) From 75d5c8da60278876c1aad3dafa069cc3ecac2648 Mon Sep 17 00:00:00 2001 From: Peter Eckel Date: Wed, 9 Nov 2022 14:21:49 +0100 Subject: [PATCH 2/2] Resolved merge conflict --- .../migrations/{0018_update_ns_ttl.py => 0019_update_ns_ttl.py} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename netbox_dns/migrations/{0018_update_ns_ttl.py => 0019_update_ns_ttl.py} (88%) diff --git a/netbox_dns/migrations/0018_update_ns_ttl.py b/netbox_dns/migrations/0019_update_ns_ttl.py similarity index 88% rename from netbox_dns/migrations/0018_update_ns_ttl.py rename to netbox_dns/migrations/0019_update_ns_ttl.py index 4db91a3..2c3656a 100644 --- a/netbox_dns/migrations/0018_update_ns_ttl.py +++ b/netbox_dns/migrations/0019_update_ns_ttl.py @@ -12,7 +12,7 @@ def update_ns_ttl(apps, schema_editor): class Migration(migrations.Migration): dependencies = [ - ("netbox_dns", "0017_alter_record_ttl"), + ("netbox_dns", "0018_zone_arpa_network"), ] operations = [