Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Set TTL for the zones' NS records to None #243

Merged
merged 2 commits into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions netbox_dns/migrations/0019_update_ns_ttl.py
Original file line number Diff line number Diff line change
@@ -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", "0018_zone_arpa_network"),
]

operations = [
migrations.RunPython(update_ns_ttl),
]
2 changes: 0 additions & 2 deletions netbox_dns/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
)
Expand Down