netbox-plugin-dns 0.22.8__py3-none-any.whl → 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of netbox-plugin-dns might be problematic. Click here for more details.
- netbox_dns/__init__.py +4 -15
- netbox_dns/api/nested_serializers.py +4 -60
- netbox_dns/api/serializers.py +8 -314
- netbox_dns/api/serializers_/__init__.py +0 -0
- netbox_dns/api/serializers_/contact.py +37 -0
- netbox_dns/api/serializers_/nameserver.py +39 -0
- netbox_dns/api/serializers_/record.py +90 -0
- netbox_dns/api/serializers_/registrar.py +31 -0
- netbox_dns/api/serializers_/view.py +34 -0
- netbox_dns/api/serializers_/zone.py +159 -0
- netbox_dns/api/views.py +13 -13
- netbox_dns/fields/network.py +21 -22
- netbox_dns/fields/rfc2317.py +3 -3
- netbox_dns/{filters → filtersets}/contact.py +2 -1
- netbox_dns/filtersets/nameserver.py +37 -0
- netbox_dns/{filters → filtersets}/record.py +51 -6
- netbox_dns/{filters → filtersets}/registrar.py +2 -1
- netbox_dns/{filters → filtersets}/view.py +2 -2
- netbox_dns/filtersets/zone.py +205 -0
- netbox_dns/forms/contact.py +61 -33
- netbox_dns/forms/nameserver.py +21 -8
- netbox_dns/forms/record.py +65 -38
- netbox_dns/forms/registrar.py +45 -15
- netbox_dns/forms/view.py +23 -9
- netbox_dns/forms/zone.py +182 -188
- netbox_dns/graphql/__init__.py +17 -27
- netbox_dns/graphql/filters.py +49 -0
- netbox_dns/graphql/schema.py +66 -7
- netbox_dns/graphql/types.py +143 -0
- netbox_dns/management/commands/cleanup_database.py +0 -4
- netbox_dns/management/commands/cleanup_rrset_ttl.py +3 -5
- netbox_dns/management/commands/setup_coupling.py +15 -15
- netbox_dns/management/commands/update_soa.py +1 -1
- netbox_dns/migrations/0001_squashed_netbox_dns_0_15.py +0 -27
- netbox_dns/migrations/0001_squashed_netbox_dns_0_22.py +558 -0
- netbox_dns/migrations/{0013_add_nameserver_zone_record_description.py → 0002_contact_description_registrar_description.py} +4 -9
- netbox_dns/migrations/0003_default_view.py +15 -0
- netbox_dns/migrations/0004_create_and_assign_default_view.py +26 -0
- netbox_dns/migrations/0005_alter_zone_view_not_null.py +18 -0
- netbox_dns/migrations/0020_netbox_3_4.py +1 -1
- netbox_dns/models/contact.py +6 -1
- netbox_dns/models/nameserver.py +5 -1
- netbox_dns/models/record.py +32 -34
- netbox_dns/models/registrar.py +5 -1
- netbox_dns/models/view.py +54 -1
- netbox_dns/models/zone.py +68 -54
- netbox_dns/navigation.py +1 -15
- netbox_dns/signals/ipam_coupling.py +3 -9
- netbox_dns/tables/contact.py +1 -0
- netbox_dns/tables/nameserver.py +0 -2
- netbox_dns/tables/registrar.py +1 -0
- netbox_dns/tables/view.py +9 -2
- netbox_dns/template_content.py +4 -8
- netbox_dns/templates/netbox_dns/contact.html +60 -56
- netbox_dns/templates/netbox_dns/nameserver.html +27 -27
- netbox_dns/templates/netbox_dns/record.html +92 -94
- netbox_dns/templates/netbox_dns/registrar.html +38 -36
- netbox_dns/templates/netbox_dns/view.html +25 -21
- netbox_dns/templates/netbox_dns/zone/base.html +5 -3
- netbox_dns/templates/netbox_dns/zone/child.html +3 -3
- netbox_dns/templates/netbox_dns/zone/managed_record.html +1 -1
- netbox_dns/templates/netbox_dns/zone/record.html +3 -3
- netbox_dns/templates/netbox_dns/zone/registration.html +26 -27
- netbox_dns/templates/netbox_dns/zone/rfc2317_child_zone.html +1 -1
- netbox_dns/templates/netbox_dns/zone.html +148 -149
- netbox_dns/urls/__init__.py +17 -0
- netbox_dns/urls/contact.py +51 -0
- netbox_dns/urls/nameserver.py +69 -0
- netbox_dns/urls/record.py +41 -0
- netbox_dns/urls/registrar.py +63 -0
- netbox_dns/urls/view.py +39 -0
- netbox_dns/urls/zone.py +57 -0
- netbox_dns/utilities/__init__.py +1 -6
- netbox_dns/utilities/ipam_coupling.py +2 -7
- netbox_dns/validators/dns_name.py +4 -9
- netbox_dns/validators/rfc2317.py +2 -2
- netbox_dns/views/contact.py +4 -4
- netbox_dns/views/nameserver.py +5 -5
- netbox_dns/views/record.py +14 -29
- netbox_dns/views/registrar.py +4 -4
- netbox_dns/views/view.py +4 -4
- netbox_dns/views/zone.py +7 -8
- {netbox_plugin_dns-0.22.8.dist-info → netbox_plugin_dns-1.0.0.dist-info}/METADATA +27 -13
- netbox_plugin_dns-1.0.0.dist-info/RECORD +112 -0
- netbox_dns/filters/nameserver.py +0 -18
- netbox_dns/filters/zone.py +0 -112
- netbox_dns/graphql/contact.py +0 -19
- netbox_dns/graphql/nameserver.py +0 -19
- netbox_dns/graphql/record.py +0 -19
- netbox_dns/graphql/registrar.py +0 -19
- netbox_dns/graphql/view.py +0 -19
- netbox_dns/graphql/zone.py +0 -19
- netbox_dns/migrations/0001_initial.py +0 -115
- netbox_dns/migrations/0002_zone_default_ttl.py +0 -18
- netbox_dns/migrations/0003_soa_managed_records.py +0 -112
- netbox_dns/migrations/0004_create_ptr_for_a_aaaa_records.py +0 -80
- netbox_dns/migrations/0005_update_ns_records.py +0 -41
- netbox_dns/migrations/0006_zone_soa_serial_auto.py +0 -29
- netbox_dns/migrations/0007_alter_zone_soa_serial_auto.py +0 -17
- netbox_dns/migrations/0008_zone_status_names.py +0 -21
- netbox_dns/migrations/0009_netbox32.py +0 -71
- netbox_dns/migrations/0010_update_soa_records.py +0 -58
- netbox_dns/migrations/0011_add_view_model.py +0 -70
- netbox_dns/migrations/0012_adjust_zone_and_record.py +0 -17
- netbox_dns/migrations/0014_add_view_description.py +0 -16
- netbox_dns/migrations/0015_add_record_status.py +0 -17
- netbox_dns/migrations/0016_cleanup_ptr_records.py +0 -38
- netbox_dns/migrations/0017_alter_record_ttl.py +0 -17
- netbox_dns/migrations/0018_zone_arpa_network.py +0 -51
- netbox_dns/migrations/0019_update_ns_ttl.py +0 -19
- netbox_dns/urls.py +0 -297
- netbox_plugin_dns-0.22.8.dist-info/RECORD +0 -117
- /netbox_dns/{filters → filtersets}/__init__.py +0 -0
- {netbox_plugin_dns-0.22.8.dist-info → netbox_plugin_dns-1.0.0.dist-info}/LICENSE +0 -0
- {netbox_plugin_dns-0.22.8.dist-info → netbox_plugin_dns-1.0.0.dist-info}/WHEEL +0 -0
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
# Generated by Django 3.2.9 on 2021-11-04 20:48
|
|
2
|
-
|
|
3
|
-
import django.core.validators
|
|
4
|
-
from django.db import migrations, models
|
|
5
|
-
import django.db.models.deletion
|
|
6
|
-
import taggit.managers
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class Migration(migrations.Migration):
|
|
10
|
-
dependencies = [
|
|
11
|
-
("extras", "0062_clear_secrets_changelog"),
|
|
12
|
-
("netbox_dns", "0002_zone_default_ttl"),
|
|
13
|
-
]
|
|
14
|
-
|
|
15
|
-
operations = [
|
|
16
|
-
migrations.AddField(
|
|
17
|
-
model_name="record",
|
|
18
|
-
name="managed",
|
|
19
|
-
field=models.BooleanField(default=False),
|
|
20
|
-
),
|
|
21
|
-
migrations.AddField(
|
|
22
|
-
model_name="zone",
|
|
23
|
-
name="soa_expire",
|
|
24
|
-
field=models.PositiveIntegerField(
|
|
25
|
-
default=2592000,
|
|
26
|
-
validators=[django.core.validators.MinValueValidator(1)],
|
|
27
|
-
),
|
|
28
|
-
preserve_default=False,
|
|
29
|
-
),
|
|
30
|
-
migrations.AddField(
|
|
31
|
-
model_name="zone",
|
|
32
|
-
name="soa_minimum",
|
|
33
|
-
field=models.PositiveIntegerField(
|
|
34
|
-
default=3600, validators=[django.core.validators.MinValueValidator(1)]
|
|
35
|
-
),
|
|
36
|
-
preserve_default=False,
|
|
37
|
-
),
|
|
38
|
-
migrations.AddField(
|
|
39
|
-
model_name="zone",
|
|
40
|
-
name="soa_mname",
|
|
41
|
-
field=models.ForeignKey(
|
|
42
|
-
default=1,
|
|
43
|
-
on_delete=django.db.models.deletion.PROTECT,
|
|
44
|
-
related_name="zones_soa",
|
|
45
|
-
to="netbox_dns.nameserver",
|
|
46
|
-
),
|
|
47
|
-
preserve_default=False,
|
|
48
|
-
),
|
|
49
|
-
migrations.AddField(
|
|
50
|
-
model_name="zone",
|
|
51
|
-
name="soa_refresh",
|
|
52
|
-
field=models.PositiveIntegerField(
|
|
53
|
-
default=172800, validators=[django.core.validators.MinValueValidator(1)]
|
|
54
|
-
),
|
|
55
|
-
preserve_default=False,
|
|
56
|
-
),
|
|
57
|
-
migrations.AddField(
|
|
58
|
-
model_name="zone",
|
|
59
|
-
name="soa_retry",
|
|
60
|
-
field=models.PositiveIntegerField(
|
|
61
|
-
default=7200, validators=[django.core.validators.MinValueValidator(1)]
|
|
62
|
-
),
|
|
63
|
-
preserve_default=False,
|
|
64
|
-
),
|
|
65
|
-
migrations.AddField(
|
|
66
|
-
model_name="zone",
|
|
67
|
-
name="soa_rname",
|
|
68
|
-
field=models.CharField(default="hostmaster.example.com", max_length=255),
|
|
69
|
-
preserve_default=False,
|
|
70
|
-
),
|
|
71
|
-
migrations.AddField(
|
|
72
|
-
model_name="zone",
|
|
73
|
-
name="soa_serial",
|
|
74
|
-
field=models.PositiveIntegerField(
|
|
75
|
-
default=1,
|
|
76
|
-
validators=[
|
|
77
|
-
django.core.validators.MinValueValidator(1),
|
|
78
|
-
django.core.validators.MaxValueValidator(2147483647),
|
|
79
|
-
],
|
|
80
|
-
),
|
|
81
|
-
preserve_default=False,
|
|
82
|
-
),
|
|
83
|
-
migrations.AddField(
|
|
84
|
-
model_name="zone",
|
|
85
|
-
name="soa_ttl",
|
|
86
|
-
field=models.PositiveIntegerField(
|
|
87
|
-
default=86400, validators=[django.core.validators.MinValueValidator(1)]
|
|
88
|
-
),
|
|
89
|
-
preserve_default=False,
|
|
90
|
-
),
|
|
91
|
-
migrations.AlterField(
|
|
92
|
-
model_name="nameserver",
|
|
93
|
-
name="tags",
|
|
94
|
-
field=taggit.managers.TaggableManager(
|
|
95
|
-
blank=True, through="extras.TaggedItem", to="extras.Tag"
|
|
96
|
-
),
|
|
97
|
-
),
|
|
98
|
-
migrations.AlterField(
|
|
99
|
-
model_name="record",
|
|
100
|
-
name="tags",
|
|
101
|
-
field=taggit.managers.TaggableManager(
|
|
102
|
-
blank=True, through="extras.TaggedItem", to="extras.Tag"
|
|
103
|
-
),
|
|
104
|
-
),
|
|
105
|
-
migrations.AlterField(
|
|
106
|
-
model_name="zone",
|
|
107
|
-
name="default_ttl",
|
|
108
|
-
field=models.PositiveIntegerField(
|
|
109
|
-
blank=True, validators=[django.core.validators.MinValueValidator(1)]
|
|
110
|
-
),
|
|
111
|
-
),
|
|
112
|
-
]
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
# Generated by Django 3.2.9 on 2021-11-06 18:53
|
|
2
|
-
|
|
3
|
-
import logging
|
|
4
|
-
|
|
5
|
-
from django.db import migrations, models
|
|
6
|
-
from django.db.models import Q, deletion
|
|
7
|
-
|
|
8
|
-
from netbox_dns.models import RecordTypeChoices
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def cleanup_disable_ptr(apps, schema_editor):
|
|
12
|
-
logger = logging.getLogger("django")
|
|
13
|
-
|
|
14
|
-
Record = apps.get_model("netbox_dns", "Record")
|
|
15
|
-
|
|
16
|
-
unique_ptr_qs = Q(
|
|
17
|
-
Q(disable_ptr=False),
|
|
18
|
-
Q(Q(type=RecordTypeChoices.A) | Q(type=RecordTypeChoices.AAAA)),
|
|
19
|
-
)
|
|
20
|
-
|
|
21
|
-
for record in Record.objects.filter(unique_ptr_qs):
|
|
22
|
-
logger.warning(
|
|
23
|
-
"Disabling PTR generation for record %s:%s in zone %s",
|
|
24
|
-
record.type,
|
|
25
|
-
record.name,
|
|
26
|
-
record.zone.name,
|
|
27
|
-
)
|
|
28
|
-
record.disable_ptr = True
|
|
29
|
-
record.save()
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
class Migration(migrations.Migration):
|
|
33
|
-
atomic = False
|
|
34
|
-
|
|
35
|
-
dependencies = [
|
|
36
|
-
("netbox_dns", "0003_soa_managed_records"),
|
|
37
|
-
]
|
|
38
|
-
|
|
39
|
-
operations = [
|
|
40
|
-
migrations.AlterModelOptions(
|
|
41
|
-
name="nameserver",
|
|
42
|
-
options={"ordering": ("name",)},
|
|
43
|
-
),
|
|
44
|
-
migrations.AlterModelOptions(
|
|
45
|
-
name="record",
|
|
46
|
-
options={"ordering": ("zone", "name", "type", "value")},
|
|
47
|
-
),
|
|
48
|
-
migrations.AddField(
|
|
49
|
-
model_name="record",
|
|
50
|
-
name="disable_ptr",
|
|
51
|
-
field=models.BooleanField(default=False),
|
|
52
|
-
),
|
|
53
|
-
migrations.AddField(
|
|
54
|
-
model_name="record",
|
|
55
|
-
name="ptr_record",
|
|
56
|
-
field=models.OneToOneField(
|
|
57
|
-
blank=True,
|
|
58
|
-
null=True,
|
|
59
|
-
on_delete=deletion.SET_NULL,
|
|
60
|
-
related_name="address_record",
|
|
61
|
-
to="netbox_dns.record",
|
|
62
|
-
),
|
|
63
|
-
),
|
|
64
|
-
migrations.RunPython(cleanup_disable_ptr),
|
|
65
|
-
migrations.AddConstraint(
|
|
66
|
-
model_name="record",
|
|
67
|
-
constraint=models.UniqueConstraint(
|
|
68
|
-
condition=Q(
|
|
69
|
-
Q(("disable_ptr", False)),
|
|
70
|
-
Q(
|
|
71
|
-
("type", RecordTypeChoices.A),
|
|
72
|
-
("type", RecordTypeChoices.AAAA),
|
|
73
|
-
_connector="OR",
|
|
74
|
-
),
|
|
75
|
-
),
|
|
76
|
-
fields=("type", "value"),
|
|
77
|
-
name="unique_pointer_for_address",
|
|
78
|
-
),
|
|
79
|
-
),
|
|
80
|
-
]
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
# Generated by Django 3.2.9 on 2021-11-26 07:01
|
|
2
|
-
|
|
3
|
-
from django.db import migrations
|
|
4
|
-
from netbox_dns.models import Record, RecordTypeChoices
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def create_initial_ns_records(apps, schema_editor):
|
|
8
|
-
Zone = apps.get_model("netbox_dns", "Zone")
|
|
9
|
-
|
|
10
|
-
for zone in Zone.objects.all():
|
|
11
|
-
nameservers = zone.nameservers.all()
|
|
12
|
-
nameserver_names = [f'{ns.name.rstrip(".")}.' for ns in nameservers]
|
|
13
|
-
|
|
14
|
-
ns_name = "@"
|
|
15
|
-
ns_ttl = zone.default_ttl
|
|
16
|
-
|
|
17
|
-
delete_ns = zone.record_set.filter(
|
|
18
|
-
type=RecordTypeChoices.NS, managed=True
|
|
19
|
-
).exclude(value__in=nameserver_names)
|
|
20
|
-
for record in delete_ns:
|
|
21
|
-
record.delete()
|
|
22
|
-
|
|
23
|
-
for ns in nameserver_names:
|
|
24
|
-
Record.objects.update_or_create(
|
|
25
|
-
zone_id=zone.pk,
|
|
26
|
-
type=RecordTypeChoices.NS,
|
|
27
|
-
name=ns_name,
|
|
28
|
-
ttl=ns_ttl,
|
|
29
|
-
value=ns,
|
|
30
|
-
managed=True,
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
class Migration(migrations.Migration):
|
|
35
|
-
dependencies = [
|
|
36
|
-
("netbox_dns", "0007_alter_zone_soa_serial_auto"),
|
|
37
|
-
]
|
|
38
|
-
|
|
39
|
-
operations = [
|
|
40
|
-
migrations.RunPython(create_initial_ns_records),
|
|
41
|
-
]
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# Generated by Django 3.2.9 on 2021-11-26 16:54
|
|
2
|
-
|
|
3
|
-
import django.core.validators
|
|
4
|
-
from django.db import migrations, models
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class Migration(migrations.Migration):
|
|
8
|
-
dependencies = [("netbox_dns", "0004_create_ptr_for_a_aaaa_records")]
|
|
9
|
-
|
|
10
|
-
operations = [
|
|
11
|
-
migrations.AddField(
|
|
12
|
-
model_name="zone",
|
|
13
|
-
name="soa_serial_auto",
|
|
14
|
-
field=models.BooleanField(default=False),
|
|
15
|
-
preserve_default=False,
|
|
16
|
-
),
|
|
17
|
-
migrations.AlterField(
|
|
18
|
-
model_name="zone",
|
|
19
|
-
name="soa_serial",
|
|
20
|
-
field=models.BigIntegerField(
|
|
21
|
-
blank=True,
|
|
22
|
-
null=True,
|
|
23
|
-
validators=[
|
|
24
|
-
django.core.validators.MinValueValidator(1),
|
|
25
|
-
django.core.validators.MaxValueValidator(4294967295),
|
|
26
|
-
],
|
|
27
|
-
),
|
|
28
|
-
),
|
|
29
|
-
]
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# Generated by Django 3.2.9 on 2021-12-13 20:44
|
|
2
|
-
|
|
3
|
-
from django.db import migrations, models
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class Migration(migrations.Migration):
|
|
7
|
-
dependencies = [
|
|
8
|
-
("netbox_dns", "0006_zone_soa_serial_auto"),
|
|
9
|
-
]
|
|
10
|
-
|
|
11
|
-
operations = [
|
|
12
|
-
migrations.AlterField(
|
|
13
|
-
model_name="zone",
|
|
14
|
-
name="soa_serial_auto",
|
|
15
|
-
field=models.BooleanField(default=True),
|
|
16
|
-
),
|
|
17
|
-
]
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
from django.db import migrations
|
|
2
|
-
|
|
3
|
-
from netbox_dns.models import ZoneStatusChoices
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def rename_passive_status_to_parked(apps, schema_editor):
|
|
7
|
-
Zone = apps.get_model("netbox_dns", "Zone")
|
|
8
|
-
|
|
9
|
-
for zone in Zone.objects.filter(status="passive"):
|
|
10
|
-
zone.status = ZoneStatusChoices.STATUS_PARKED
|
|
11
|
-
zone.save()
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class Migration(migrations.Migration):
|
|
15
|
-
dependencies = [
|
|
16
|
-
("netbox_dns", "0005_update_ns_records"),
|
|
17
|
-
]
|
|
18
|
-
|
|
19
|
-
operations = [
|
|
20
|
-
migrations.RunPython(rename_passive_status_to_parked),
|
|
21
|
-
]
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
# Generated by Django 4.0.2 on 2022-02-09 15:44
|
|
2
|
-
|
|
3
|
-
from django.db import migrations, models
|
|
4
|
-
import taggit.managers
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class Migration(migrations.Migration):
|
|
8
|
-
dependencies = [
|
|
9
|
-
("extras", "0072_created_datetimefield"),
|
|
10
|
-
("netbox_dns", "0008_zone_status_names"),
|
|
11
|
-
]
|
|
12
|
-
|
|
13
|
-
operations = [
|
|
14
|
-
migrations.AlterField(
|
|
15
|
-
model_name="nameserver",
|
|
16
|
-
name="created",
|
|
17
|
-
field=models.DateTimeField(auto_now_add=True, null=True),
|
|
18
|
-
),
|
|
19
|
-
migrations.AlterField(
|
|
20
|
-
model_name="nameserver",
|
|
21
|
-
name="id",
|
|
22
|
-
field=models.BigAutoField(
|
|
23
|
-
auto_created=True, primary_key=True, serialize=False
|
|
24
|
-
),
|
|
25
|
-
),
|
|
26
|
-
migrations.AlterField(
|
|
27
|
-
model_name="nameserver",
|
|
28
|
-
name="tags",
|
|
29
|
-
field=taggit.managers.TaggableManager(
|
|
30
|
-
through="extras.TaggedItem", to="extras.Tag"
|
|
31
|
-
),
|
|
32
|
-
),
|
|
33
|
-
migrations.AlterField(
|
|
34
|
-
model_name="record",
|
|
35
|
-
name="created",
|
|
36
|
-
field=models.DateTimeField(auto_now_add=True, null=True),
|
|
37
|
-
),
|
|
38
|
-
migrations.AlterField(
|
|
39
|
-
model_name="record",
|
|
40
|
-
name="id",
|
|
41
|
-
field=models.BigAutoField(
|
|
42
|
-
auto_created=True, primary_key=True, serialize=False
|
|
43
|
-
),
|
|
44
|
-
),
|
|
45
|
-
migrations.AlterField(
|
|
46
|
-
model_name="record",
|
|
47
|
-
name="tags",
|
|
48
|
-
field=taggit.managers.TaggableManager(
|
|
49
|
-
through="extras.TaggedItem", to="extras.Tag"
|
|
50
|
-
),
|
|
51
|
-
),
|
|
52
|
-
migrations.AlterField(
|
|
53
|
-
model_name="zone",
|
|
54
|
-
name="created",
|
|
55
|
-
field=models.DateTimeField(auto_now_add=True, null=True),
|
|
56
|
-
),
|
|
57
|
-
migrations.AlterField(
|
|
58
|
-
model_name="zone",
|
|
59
|
-
name="id",
|
|
60
|
-
field=models.BigAutoField(
|
|
61
|
-
auto_created=True, primary_key=True, serialize=False
|
|
62
|
-
),
|
|
63
|
-
),
|
|
64
|
-
migrations.AlterField(
|
|
65
|
-
model_name="zone",
|
|
66
|
-
name="tags",
|
|
67
|
-
field=taggit.managers.TaggableManager(
|
|
68
|
-
through="extras.TaggedItem", to="extras.Tag"
|
|
69
|
-
),
|
|
70
|
-
),
|
|
71
|
-
]
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
from django.db import migrations
|
|
2
|
-
from netbox_dns.models import Record, RecordTypeChoices
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
def absolute_name(name):
|
|
6
|
-
if name.endswith("."):
|
|
7
|
-
return name
|
|
8
|
-
return f"{name}."
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def update_soa_record(zone):
|
|
12
|
-
soa_name = "@"
|
|
13
|
-
soa_ttl = zone.soa_ttl
|
|
14
|
-
soa_value = (
|
|
15
|
-
f"({absolute_name(zone.soa_mname.name)} {absolute_name(zone.soa_rname)}"
|
|
16
|
-
f" {zone.soa_serial}"
|
|
17
|
-
f" {zone.soa_refresh} {zone.soa_retry} {zone.soa_expire}"
|
|
18
|
-
f" {zone.soa_minimum})"
|
|
19
|
-
)
|
|
20
|
-
|
|
21
|
-
old_soa_records = zone.record_set.filter(type=RecordTypeChoices.SOA, name=soa_name)
|
|
22
|
-
|
|
23
|
-
if len(old_soa_records):
|
|
24
|
-
for index, record in enumerate(old_soa_records):
|
|
25
|
-
if index > 0:
|
|
26
|
-
record.delete()
|
|
27
|
-
continue
|
|
28
|
-
|
|
29
|
-
if record.ttl != soa_ttl or record.value != soa_value:
|
|
30
|
-
record.ttl = soa_ttl
|
|
31
|
-
record.value = soa_value
|
|
32
|
-
record.managed = True
|
|
33
|
-
record.save()
|
|
34
|
-
else:
|
|
35
|
-
Record.objects.create(
|
|
36
|
-
zone_id=zone.pk,
|
|
37
|
-
type=RecordTypeChoices.SOA,
|
|
38
|
-
name=soa_name,
|
|
39
|
-
ttl=soa_ttl,
|
|
40
|
-
value=soa_value,
|
|
41
|
-
managed=True,
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
def update_soa_records(apps, schema_editor):
|
|
46
|
-
Zone = apps.get_model("netbox_dns", "Zone")
|
|
47
|
-
|
|
48
|
-
for zone in Zone.objects.all():
|
|
49
|
-
update_soa_record(zone)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
class Migration(migrations.Migration):
|
|
53
|
-
dependencies = [
|
|
54
|
-
("netbox_dns", "0009_netbox32"),
|
|
55
|
-
]
|
|
56
|
-
operations = [
|
|
57
|
-
migrations.RunPython(update_soa_records),
|
|
58
|
-
]
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
# Generated by Django 4.0.4 on 2022-04-22 17:18
|
|
2
|
-
|
|
3
|
-
import django.core.serializers.json
|
|
4
|
-
from django.db import migrations, models
|
|
5
|
-
import django.db.models.deletion
|
|
6
|
-
import taggit.managers
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class Migration(migrations.Migration):
|
|
10
|
-
dependencies = [
|
|
11
|
-
("extras", "0073_journalentry_tags_custom_fields"),
|
|
12
|
-
("netbox_dns", "0001_initial"),
|
|
13
|
-
]
|
|
14
|
-
|
|
15
|
-
operations = [
|
|
16
|
-
migrations.AlterModelOptions(
|
|
17
|
-
name="zone",
|
|
18
|
-
options={"ordering": ("view", "name")},
|
|
19
|
-
),
|
|
20
|
-
migrations.AlterField(
|
|
21
|
-
model_name="zone",
|
|
22
|
-
name="name",
|
|
23
|
-
field=models.CharField(max_length=255),
|
|
24
|
-
),
|
|
25
|
-
migrations.CreateModel(
|
|
26
|
-
name="View",
|
|
27
|
-
fields=[
|
|
28
|
-
(
|
|
29
|
-
"id",
|
|
30
|
-
models.BigAutoField(
|
|
31
|
-
auto_created=True, primary_key=True, serialize=False
|
|
32
|
-
),
|
|
33
|
-
),
|
|
34
|
-
("created", models.DateTimeField(auto_now_add=True, null=True)),
|
|
35
|
-
("last_updated", models.DateTimeField(auto_now=True, null=True)),
|
|
36
|
-
(
|
|
37
|
-
"custom_field_data",
|
|
38
|
-
models.JSONField(
|
|
39
|
-
blank=True,
|
|
40
|
-
default=dict,
|
|
41
|
-
encoder=django.core.serializers.json.DjangoJSONEncoder,
|
|
42
|
-
),
|
|
43
|
-
),
|
|
44
|
-
("name", models.CharField(max_length=255, unique=True)),
|
|
45
|
-
(
|
|
46
|
-
"tags",
|
|
47
|
-
taggit.managers.TaggableManager(
|
|
48
|
-
through="extras.TaggedItem", to="extras.Tag"
|
|
49
|
-
),
|
|
50
|
-
),
|
|
51
|
-
],
|
|
52
|
-
options={
|
|
53
|
-
"ordering": ("name",),
|
|
54
|
-
},
|
|
55
|
-
),
|
|
56
|
-
migrations.AddField(
|
|
57
|
-
model_name="zone",
|
|
58
|
-
name="view",
|
|
59
|
-
field=models.ForeignKey(
|
|
60
|
-
blank=True,
|
|
61
|
-
null=True,
|
|
62
|
-
on_delete=django.db.models.deletion.PROTECT,
|
|
63
|
-
to="netbox_dns.view",
|
|
64
|
-
),
|
|
65
|
-
),
|
|
66
|
-
migrations.AlterUniqueTogether(
|
|
67
|
-
name="zone",
|
|
68
|
-
unique_together={("view", "name")},
|
|
69
|
-
),
|
|
70
|
-
]
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# Generated by Django 4.0.4 on 2022-04-26 17:51
|
|
2
|
-
|
|
3
|
-
from django.db import migrations
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class Migration(migrations.Migration):
|
|
7
|
-
dependencies = [
|
|
8
|
-
("netbox_dns", "0010_update_soa_records"),
|
|
9
|
-
("netbox_dns", "0011_add_view_model"),
|
|
10
|
-
]
|
|
11
|
-
|
|
12
|
-
operations = [
|
|
13
|
-
migrations.RemoveConstraint(
|
|
14
|
-
model_name="record",
|
|
15
|
-
name="unique_pointer_for_address",
|
|
16
|
-
),
|
|
17
|
-
]
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
from django.db import migrations, models
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class Migration(migrations.Migration):
|
|
5
|
-
dependencies = [
|
|
6
|
-
("netbox_dns", "0012_adjust_zone_and_record"),
|
|
7
|
-
("netbox_dns", "0013_add_nameserver_zone_record_description"),
|
|
8
|
-
]
|
|
9
|
-
|
|
10
|
-
operations = [
|
|
11
|
-
migrations.AddField(
|
|
12
|
-
model_name="view",
|
|
13
|
-
name="description",
|
|
14
|
-
field=models.CharField(blank=True, max_length=200),
|
|
15
|
-
),
|
|
16
|
-
]
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# Generated by Django 4.0.3 on 2022-07-28 15:48
|
|
2
|
-
|
|
3
|
-
from django.db import migrations, models
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class Migration(migrations.Migration):
|
|
7
|
-
dependencies = [
|
|
8
|
-
("netbox_dns", "0001_initial"),
|
|
9
|
-
]
|
|
10
|
-
|
|
11
|
-
operations = [
|
|
12
|
-
migrations.AddField(
|
|
13
|
-
model_name="record",
|
|
14
|
-
name="status",
|
|
15
|
-
field=models.CharField(default="active", max_length=50),
|
|
16
|
-
),
|
|
17
|
-
]
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import logging
|
|
2
|
-
|
|
3
|
-
from django.db import migrations
|
|
4
|
-
from django.db.models import Q
|
|
5
|
-
|
|
6
|
-
from netbox_dns.models import ZoneStatusChoices
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def delete_ptr_records_for_inactive_zones(apps, schema_editor):
|
|
10
|
-
logger = logging.getLogger("django")
|
|
11
|
-
|
|
12
|
-
Record = apps.get_model("netbox_dns", "Record")
|
|
13
|
-
|
|
14
|
-
for record in Record.objects.exclude(
|
|
15
|
-
Q(Q(ptr_record__isnull=True) | Q(zone__status=ZoneStatusChoices.STATUS_ACTIVE))
|
|
16
|
-
):
|
|
17
|
-
logger.warning(
|
|
18
|
-
"Deleting PTR for record %s:%s in zone %s",
|
|
19
|
-
record.type,
|
|
20
|
-
record.name,
|
|
21
|
-
record.zone.name,
|
|
22
|
-
)
|
|
23
|
-
record.ptr_record.delete()
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
class Migration(migrations.Migration):
|
|
27
|
-
dependencies = [
|
|
28
|
-
("netbox_dns", "0014_add_view_description"),
|
|
29
|
-
("netbox_dns", "0015_add_record_status"),
|
|
30
|
-
]
|
|
31
|
-
|
|
32
|
-
operations = [
|
|
33
|
-
migrations.AlterModelOptions(
|
|
34
|
-
name="record",
|
|
35
|
-
options={"ordering": ("zone", "name", "type", "value", "status")},
|
|
36
|
-
),
|
|
37
|
-
migrations.RunPython(delete_ptr_records_for_inactive_zones),
|
|
38
|
-
]
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# Generated by Django 4.0.8 on 2022-10-18 07:53
|
|
2
|
-
|
|
3
|
-
from django.db import migrations, models
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class Migration(migrations.Migration):
|
|
7
|
-
dependencies = [
|
|
8
|
-
("netbox_dns", "0016_cleanup_ptr_records"),
|
|
9
|
-
]
|
|
10
|
-
|
|
11
|
-
operations = [
|
|
12
|
-
migrations.AlterField(
|
|
13
|
-
model_name="record",
|
|
14
|
-
name="ttl",
|
|
15
|
-
field=models.PositiveIntegerField(blank=True, null=True),
|
|
16
|
-
),
|
|
17
|
-
]
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
# Generated by Django 4.0.8 on 2022-10-26 18:55
|
|
2
|
-
|
|
3
|
-
from netaddr import IPNetwork, AddrFormatError
|
|
4
|
-
|
|
5
|
-
from django.db import migrations
|
|
6
|
-
import netbox_dns.fields.network
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def update_zone_arpa_network(apps, schema_editor):
|
|
10
|
-
Zone = apps.get_model("netbox_dns", "Zone")
|
|
11
|
-
|
|
12
|
-
for zone in Zone.objects.filter(name__endswith=".arpa"):
|
|
13
|
-
name = zone.name
|
|
14
|
-
|
|
15
|
-
if name.endswith(".in-addr.arpa"):
|
|
16
|
-
address = ".".join(reversed(name.replace(".in-addr.arpa", "").split(".")))
|
|
17
|
-
mask = len(address.split(".")) * 8
|
|
18
|
-
|
|
19
|
-
try:
|
|
20
|
-
zone.arpa_network = IPNetwork(f"{address}/{mask}")
|
|
21
|
-
except AddrFormatError:
|
|
22
|
-
zone.arpa_network = None
|
|
23
|
-
|
|
24
|
-
elif name.endswith("ip6.arpa"):
|
|
25
|
-
address = "".join(reversed(name.replace(".ip6.arpa", "").split(".")))
|
|
26
|
-
mask = len(address)
|
|
27
|
-
address = address + "0" * (32 - mask)
|
|
28
|
-
|
|
29
|
-
try:
|
|
30
|
-
zone.arpa_network = IPNetwork(
|
|
31
|
-
f"{':'.join([(address[i:i+4]) for i in range(0, mask, 4)])}::/{mask*4}"
|
|
32
|
-
)
|
|
33
|
-
except AddrFormatError:
|
|
34
|
-
zone.arpa_network = None
|
|
35
|
-
|
|
36
|
-
zone.save()
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
class Migration(migrations.Migration):
|
|
40
|
-
dependencies = [
|
|
41
|
-
("netbox_dns", "0017_alter_record_ttl"),
|
|
42
|
-
]
|
|
43
|
-
|
|
44
|
-
operations = [
|
|
45
|
-
migrations.AddField(
|
|
46
|
-
model_name="zone",
|
|
47
|
-
name="arpa_network",
|
|
48
|
-
field=netbox_dns.fields.network.NetworkField(blank=True, null=True),
|
|
49
|
-
),
|
|
50
|
-
migrations.RunPython(update_zone_arpa_network),
|
|
51
|
-
]
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
from django.db import migrations
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def update_ns_ttl(apps, schema_editor):
|
|
5
|
-
Zone = apps.get_model("netbox_dns", "Zone")
|
|
6
|
-
|
|
7
|
-
for zone in Zone.objects.all():
|
|
8
|
-
for nameserver in zone.nameservers.all():
|
|
9
|
-
nameserver.ttl = None
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class Migration(migrations.Migration):
|
|
13
|
-
dependencies = [
|
|
14
|
-
("netbox_dns", "0018_zone_arpa_network"),
|
|
15
|
-
]
|
|
16
|
-
|
|
17
|
-
operations = [
|
|
18
|
-
migrations.RunPython(update_ns_ttl),
|
|
19
|
-
]
|