netbox-plugin-dns 1.2.4__py3-none-any.whl → 1.2.5__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 +2 -1
- netbox_dns/forms/record_template.py +4 -0
- netbox_dns/forms/zone.py +13 -0
- netbox_dns/forms/zone_template.py +8 -0
- netbox_dns/migrations/0014_alter_unique_constraints_lowercase.py +42 -0
- netbox_dns/models/nameserver.py +19 -2
- netbox_dns/models/record.py +19 -10
- netbox_dns/models/record_template.py +5 -2
- netbox_dns/models/zone.py +28 -12
- netbox_dns/utilities/conversions.py +5 -0
- netbox_dns/utilities/dns.py +1 -2
- netbox_dns/utilities/ipam_dnssync.py +5 -2
- netbox_dns/views/record.py +17 -7
- {netbox_plugin_dns-1.2.4.dist-info → netbox_plugin_dns-1.2.5.dist-info}/METADATA +1 -1
- {netbox_plugin_dns-1.2.4.dist-info → netbox_plugin_dns-1.2.5.dist-info}/RECORD +18 -17
- {netbox_plugin_dns-1.2.4.dist-info → netbox_plugin_dns-1.2.5.dist-info}/WHEEL +1 -1
- {netbox_plugin_dns-1.2.4.dist-info → netbox_plugin_dns-1.2.5.dist-info}/LICENSE +0 -0
- {netbox_plugin_dns-1.2.4.dist-info → netbox_plugin_dns-1.2.5.dist-info}/top_level.txt +0 -0
netbox_dns/__init__.py
CHANGED
|
@@ -7,7 +7,7 @@ from ipam.choices import IPAddressStatusChoices
|
|
|
7
7
|
|
|
8
8
|
from netbox_dns.choices import RecordTypeChoices, RecordStatusChoices, ZoneStatusChoices
|
|
9
9
|
|
|
10
|
-
__version__ = "1.2.
|
|
10
|
+
__version__ = "1.2.5"
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
def _check_list(setting):
|
|
@@ -64,6 +64,7 @@ class DNSConfig(PluginConfig):
|
|
|
64
64
|
"enforce_unique_rrset_ttl": True,
|
|
65
65
|
"menu_name": "DNS",
|
|
66
66
|
"top_level_menu": True,
|
|
67
|
+
"convert_names_to_lowercase": False,
|
|
67
68
|
}
|
|
68
69
|
base_url = "netbox-dns"
|
|
69
70
|
|
|
@@ -191,6 +191,10 @@ class RecordTemplateImportForm(NetBoxModelImportForm):
|
|
|
191
191
|
class RecordTemplateBulkEditForm(NetBoxModelBulkEditForm):
|
|
192
192
|
model = RecordTemplate
|
|
193
193
|
|
|
194
|
+
record_name = forms.CharField(
|
|
195
|
+
required=False,
|
|
196
|
+
label=_("Record Name"),
|
|
197
|
+
)
|
|
194
198
|
type = forms.ChoiceField(
|
|
195
199
|
choices=add_blank_choice(RecordSelectableTypeChoices),
|
|
196
200
|
required=False,
|
netbox_dns/forms/zone.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from packaging.version import Version
|
|
2
|
+
|
|
1
3
|
from django import forms
|
|
2
4
|
from django.db import transaction
|
|
3
5
|
from django.conf import settings
|
|
@@ -20,6 +22,7 @@ from utilities.forms.fields import (
|
|
|
20
22
|
CSVModelMultipleChoiceField,
|
|
21
23
|
DynamicModelChoiceField,
|
|
22
24
|
)
|
|
25
|
+
from utilities.release import load_release_data
|
|
23
26
|
from utilities.forms.widgets import BulkEditNullBooleanSelect
|
|
24
27
|
from utilities.forms.rendering import FieldSet
|
|
25
28
|
from utilities.forms import BOOLEAN_WITH_BLANK_CHOICES, add_blank_choice
|
|
@@ -47,6 +50,8 @@ __all__ = (
|
|
|
47
50
|
"ZoneBulkEditForm",
|
|
48
51
|
)
|
|
49
52
|
|
|
53
|
+
QUICK_ADD = Version(load_release_data().version) >= Version("4.2.5")
|
|
54
|
+
|
|
50
55
|
|
|
51
56
|
class RollbackTransaction(Exception):
|
|
52
57
|
pass
|
|
@@ -140,6 +145,12 @@ class ZoneTemplateUpdateMixin:
|
|
|
140
145
|
|
|
141
146
|
|
|
142
147
|
class ZoneForm(ZoneTemplateUpdateMixin, TenancyForm, NetBoxModelForm):
|
|
148
|
+
view = DynamicModelChoiceField(
|
|
149
|
+
queryset=View.objects.all(),
|
|
150
|
+
required=True,
|
|
151
|
+
label=_("View"),
|
|
152
|
+
quick_add=QUICK_ADD,
|
|
153
|
+
)
|
|
143
154
|
name = forms.CharField(
|
|
144
155
|
required=True,
|
|
145
156
|
label=_("Name"),
|
|
@@ -158,6 +169,7 @@ class ZoneForm(ZoneTemplateUpdateMixin, TenancyForm, NetBoxModelForm):
|
|
|
158
169
|
queryset=NameServer.objects.all(),
|
|
159
170
|
required=False,
|
|
160
171
|
label=_("Nameservers"),
|
|
172
|
+
quick_add=QUICK_ADD,
|
|
161
173
|
)
|
|
162
174
|
default_ttl = forms.IntegerField(
|
|
163
175
|
required=False,
|
|
@@ -180,6 +192,7 @@ class ZoneForm(ZoneTemplateUpdateMixin, TenancyForm, NetBoxModelForm):
|
|
|
180
192
|
help_text=_("Primary nameserver this zone"),
|
|
181
193
|
required=False,
|
|
182
194
|
label=_("SOA MName"),
|
|
195
|
+
quick_add=QUICK_ADD,
|
|
183
196
|
)
|
|
184
197
|
soa_rname = forms.CharField(
|
|
185
198
|
required=False,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from packaging.version import Version
|
|
2
|
+
|
|
1
3
|
from django import forms
|
|
2
4
|
from django.utils.translation import gettext_lazy as _
|
|
3
5
|
|
|
@@ -7,6 +9,7 @@ from netbox.forms import (
|
|
|
7
9
|
NetBoxModelImportForm,
|
|
8
10
|
NetBoxModelForm,
|
|
9
11
|
)
|
|
12
|
+
from utilities.release import load_release_data
|
|
10
13
|
from utilities.forms.fields import (
|
|
11
14
|
DynamicModelMultipleChoiceField,
|
|
12
15
|
TagFilterField,
|
|
@@ -34,20 +37,25 @@ __all__ = (
|
|
|
34
37
|
"ZoneTemplateBulkEditForm",
|
|
35
38
|
)
|
|
36
39
|
|
|
40
|
+
QUICK_ADD = Version(load_release_data().version) >= Version("4.2.5")
|
|
41
|
+
|
|
37
42
|
|
|
38
43
|
class ZoneTemplateForm(TenancyForm, NetBoxModelForm):
|
|
39
44
|
nameservers = DynamicModelMultipleChoiceField(
|
|
40
45
|
queryset=NameServer.objects.all(),
|
|
41
46
|
required=False,
|
|
47
|
+
quick_add=QUICK_ADD,
|
|
42
48
|
)
|
|
43
49
|
soa_mname = DynamicModelChoiceField(
|
|
44
50
|
queryset=NameServer.objects.all(),
|
|
45
51
|
required=False,
|
|
46
52
|
label=_("MName"),
|
|
53
|
+
quick_add=QUICK_ADD,
|
|
47
54
|
)
|
|
48
55
|
record_templates = DynamicModelMultipleChoiceField(
|
|
49
56
|
queryset=RecordTemplate.objects.all(),
|
|
50
57
|
required=False,
|
|
58
|
+
quick_add=QUICK_ADD,
|
|
51
59
|
)
|
|
52
60
|
|
|
53
61
|
fieldsets = (
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Generated by Django 5.1.6 on 2025-02-27 19:36
|
|
2
|
+
|
|
3
|
+
import django.db.models.functions.text
|
|
4
|
+
from django.db import migrations, models
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Migration(migrations.Migration):
|
|
8
|
+
|
|
9
|
+
dependencies = [
|
|
10
|
+
("extras", "0122_charfield_null_choices"),
|
|
11
|
+
("netbox_dns", "0013_zonetemplate_soa_mname_zonetemplate_soa_rname"),
|
|
12
|
+
("tenancy", "0017_natural_ordering"),
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
operations = [
|
|
16
|
+
migrations.AlterUniqueTogether(
|
|
17
|
+
name="zone",
|
|
18
|
+
unique_together=set(),
|
|
19
|
+
),
|
|
20
|
+
migrations.AlterField(
|
|
21
|
+
model_name="nameserver",
|
|
22
|
+
name="name",
|
|
23
|
+
field=models.CharField(db_collation="natural_sort", max_length=255),
|
|
24
|
+
),
|
|
25
|
+
migrations.AddConstraint(
|
|
26
|
+
model_name="nameserver",
|
|
27
|
+
constraint=models.UniqueConstraint(
|
|
28
|
+
django.db.models.functions.text.Lower("name"),
|
|
29
|
+
name="name_unique_ci",
|
|
30
|
+
violation_error_message="There is already a nameserver with this name",
|
|
31
|
+
),
|
|
32
|
+
),
|
|
33
|
+
migrations.AddConstraint(
|
|
34
|
+
model_name="zone",
|
|
35
|
+
constraint=models.UniqueConstraint(
|
|
36
|
+
django.db.models.functions.text.Lower("name"),
|
|
37
|
+
models.F("view"),
|
|
38
|
+
name="name_view_unique_ci",
|
|
39
|
+
violation_error_message="There is already a zone with the same name in this view",
|
|
40
|
+
),
|
|
41
|
+
),
|
|
42
|
+
]
|
netbox_dns/models/nameserver.py
CHANGED
|
@@ -2,13 +2,15 @@ from dns import name as dns_name
|
|
|
2
2
|
|
|
3
3
|
from django.core.exceptions import ValidationError
|
|
4
4
|
from django.db import models, transaction
|
|
5
|
-
from django.db.models import Q
|
|
5
|
+
from django.db.models import Q, UniqueConstraint
|
|
6
|
+
from django.db.models.functions import Lower
|
|
6
7
|
from django.urls import reverse
|
|
7
8
|
from django.utils.translation import gettext_lazy as _
|
|
8
9
|
|
|
9
10
|
from netbox.models import NetBoxModel
|
|
10
11
|
from netbox.search import SearchIndex, register_search
|
|
11
12
|
from netbox.models.features import ContactsMixin
|
|
13
|
+
from netbox.plugins.utils import get_plugin_config
|
|
12
14
|
|
|
13
15
|
from netbox_dns.utilities import (
|
|
14
16
|
name_to_unicode,
|
|
@@ -29,7 +31,6 @@ __all__ = (
|
|
|
29
31
|
class NameServer(ObjectModificationMixin, ContactsMixin, NetBoxModel):
|
|
30
32
|
name = models.CharField(
|
|
31
33
|
verbose_name=_("Name"),
|
|
32
|
-
unique=True,
|
|
33
34
|
max_length=255,
|
|
34
35
|
db_collation="natural_sort",
|
|
35
36
|
)
|
|
@@ -59,6 +60,16 @@ class NameServer(ObjectModificationMixin, ContactsMixin, NetBoxModel):
|
|
|
59
60
|
|
|
60
61
|
ordering = ("name",)
|
|
61
62
|
|
|
63
|
+
constraints = [
|
|
64
|
+
UniqueConstraint(
|
|
65
|
+
Lower("name"),
|
|
66
|
+
name="name_unique_ci",
|
|
67
|
+
violation_error_message=_(
|
|
68
|
+
"There is already a nameserver with this name"
|
|
69
|
+
),
|
|
70
|
+
),
|
|
71
|
+
]
|
|
72
|
+
|
|
62
73
|
def __str__(self):
|
|
63
74
|
try:
|
|
64
75
|
return dns_name.from_text(self.name, origin=None).to_unicode()
|
|
@@ -73,6 +84,12 @@ class NameServer(ObjectModificationMixin, ContactsMixin, NetBoxModel):
|
|
|
73
84
|
def get_absolute_url(self):
|
|
74
85
|
return reverse("plugins:netbox_dns:nameserver", kwargs={"pk": self.pk})
|
|
75
86
|
|
|
87
|
+
def clean_fields(self, exclude=None):
|
|
88
|
+
if get_plugin_config("netbox_dns", "convert_names_to_lowercase", False):
|
|
89
|
+
self.name = self.name.lower()
|
|
90
|
+
|
|
91
|
+
super().clean_fields(exclude=exclude)
|
|
92
|
+
|
|
76
93
|
def clean(self, *args, **kwargs):
|
|
77
94
|
try:
|
|
78
95
|
self.name = normalize_name(self.name)
|
netbox_dns/models/record.py
CHANGED
|
@@ -371,9 +371,11 @@ class Record(ObjectModificationMixin, ContactsMixin, NetBoxModel):
|
|
|
371
371
|
if ptr_zone.is_rfc2317_zone:
|
|
372
372
|
ptr_name = self.rfc2317_ptr_name
|
|
373
373
|
else:
|
|
374
|
-
ptr_name =
|
|
375
|
-
ipaddress.ip_address(self.value).reverse_pointer
|
|
376
|
-
|
|
374
|
+
ptr_name = (
|
|
375
|
+
dns_name.from_text(ipaddress.ip_address(self.value).reverse_pointer)
|
|
376
|
+
.relativize(dns_name.from_text(ptr_zone.name))
|
|
377
|
+
.to_text()
|
|
378
|
+
)
|
|
377
379
|
|
|
378
380
|
ptr_value = self.fqdn
|
|
379
381
|
ptr_record = self.ptr_record
|
|
@@ -440,12 +442,16 @@ class Record(ObjectModificationMixin, ContactsMixin, NetBoxModel):
|
|
|
440
442
|
|
|
441
443
|
def update_rfc2317_cname_record(self, save_zone_serial=True):
|
|
442
444
|
if self.zone.rfc2317_parent_managed:
|
|
443
|
-
cname_name =
|
|
444
|
-
|
|
445
|
-
|
|
445
|
+
cname_name = (
|
|
446
|
+
dns_name.from_text(
|
|
447
|
+
ipaddress.ip_address(self.ip_address).reverse_pointer
|
|
448
|
+
)
|
|
449
|
+
.relativize(dns_name.from_text(self.zone.rfc2317_parent_zone.name))
|
|
450
|
+
.to_text()
|
|
451
|
+
)
|
|
446
452
|
|
|
447
453
|
if self.rfc2317_cname_record is not None:
|
|
448
|
-
if self.rfc2317_cname_record.name == cname_name
|
|
454
|
+
if self.rfc2317_cname_record.name == cname_name:
|
|
449
455
|
self.rfc2317_cname_record.zone = self.zone.rfc2317_parent_zone
|
|
450
456
|
self.rfc2317_cname_record.value = self.fqdn
|
|
451
457
|
self.rfc2317_cname_record.ttl = min_ttl(
|
|
@@ -613,7 +619,7 @@ class Record(ObjectModificationMixin, ContactsMixin, NetBoxModel):
|
|
|
613
619
|
new_zone = self.zone
|
|
614
620
|
|
|
615
621
|
records = new_zone.records.filter(
|
|
616
|
-
|
|
622
|
+
name__iexact=self.name,
|
|
617
623
|
type=self.type,
|
|
618
624
|
value=self.value,
|
|
619
625
|
status__in=RECORD_ACTIVE_STATUS_LIST,
|
|
@@ -770,9 +776,12 @@ class Record(ObjectModificationMixin, ContactsMixin, NetBoxModel):
|
|
|
770
776
|
record.ttl = ttl
|
|
771
777
|
record.save(update_fields=["ttl"], update_rrset_ttl=False)
|
|
772
778
|
|
|
773
|
-
def clean_fields(self,
|
|
779
|
+
def clean_fields(self, exclude=None):
|
|
774
780
|
self.type = self.type.upper()
|
|
775
|
-
|
|
781
|
+
if get_plugin_config("netbox_dns", "convert_names_to_lowercase", False):
|
|
782
|
+
self.name = self.name.lower()
|
|
783
|
+
|
|
784
|
+
super().clean_fields(exclude=exclude)
|
|
776
785
|
|
|
777
786
|
def clean(self, *args, new_zone=None, **kwargs):
|
|
778
787
|
self.validate_name(new_zone=new_zone)
|
|
@@ -174,9 +174,12 @@ class RecordTemplate(NetBoxModel):
|
|
|
174
174
|
if tags := self.tags.all():
|
|
175
175
|
record.tags.set(tags)
|
|
176
176
|
|
|
177
|
-
def clean_fields(self,
|
|
177
|
+
def clean_fields(self, exclude=None):
|
|
178
178
|
self.type = self.type.upper()
|
|
179
|
-
|
|
179
|
+
if get_plugin_config("netbox_dns", "convert_names_to_lowercase", False):
|
|
180
|
+
self.record_name = self.record_name.lower()
|
|
181
|
+
|
|
182
|
+
super().clean_fields(exclude=exclude)
|
|
180
183
|
|
|
181
184
|
def clean(self, *args, **kwargs):
|
|
182
185
|
self.validate_name()
|
netbox_dns/models/zone.py
CHANGED
|
@@ -11,8 +11,8 @@ from django.core.validators import (
|
|
|
11
11
|
)
|
|
12
12
|
from django.core.exceptions import ObjectDoesNotExist, ValidationError
|
|
13
13
|
from django.db import models, transaction
|
|
14
|
-
from django.db.models import Q, Max, ExpressionWrapper, BooleanField
|
|
15
|
-
from django.db.models.functions import Length
|
|
14
|
+
from django.db.models import Q, Max, ExpressionWrapper, BooleanField, UniqueConstraint
|
|
15
|
+
from django.db.models.functions import Length, Lower
|
|
16
16
|
from django.db.models.signals import m2m_changed
|
|
17
17
|
from django.urls import reverse
|
|
18
18
|
from django.dispatch import receiver
|
|
@@ -36,6 +36,7 @@ from netbox_dns.utilities import (
|
|
|
36
36
|
name_to_unicode,
|
|
37
37
|
normalize_name,
|
|
38
38
|
get_parent_zone_names,
|
|
39
|
+
regex_from_list,
|
|
39
40
|
NameFormatError,
|
|
40
41
|
)
|
|
41
42
|
from netbox_dns.validators import (
|
|
@@ -282,10 +283,16 @@ class Zone(ObjectModificationMixin, ContactsMixin, NetBoxModel):
|
|
|
282
283
|
"view",
|
|
283
284
|
"name",
|
|
284
285
|
)
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
286
|
+
constraints = [
|
|
287
|
+
UniqueConstraint(
|
|
288
|
+
Lower("name"),
|
|
289
|
+
"view",
|
|
290
|
+
name="name_view_unique_ci",
|
|
291
|
+
violation_error_message=_(
|
|
292
|
+
"There is already a zone with the same name in this view"
|
|
293
|
+
),
|
|
294
|
+
),
|
|
295
|
+
]
|
|
289
296
|
|
|
290
297
|
def __str__(self):
|
|
291
298
|
if self.name == "." and get_plugin_config("netbox_dns", "enable_root_zones"):
|
|
@@ -399,12 +406,14 @@ class Zone(ObjectModificationMixin, ContactsMixin, NetBoxModel):
|
|
|
399
406
|
|
|
400
407
|
@property
|
|
401
408
|
def descendant_zones(self):
|
|
402
|
-
return self.view.zones.filter(
|
|
409
|
+
return self.view.zones.filter(name__iendswith=f".{self.name}")
|
|
403
410
|
|
|
404
411
|
@property
|
|
405
412
|
def parent_zone(self):
|
|
406
413
|
try:
|
|
407
|
-
return self.view.zones.get(
|
|
414
|
+
return self.view.zones.get(
|
|
415
|
+
name__iexact=get_parent_zone_names(self.name)[-1]
|
|
416
|
+
)
|
|
408
417
|
except (Zone.DoesNotExist, IndexError):
|
|
409
418
|
return None
|
|
410
419
|
|
|
@@ -412,20 +421,24 @@ class Zone(ObjectModificationMixin, ContactsMixin, NetBoxModel):
|
|
|
412
421
|
def ancestor_zones(self):
|
|
413
422
|
return (
|
|
414
423
|
self.view.zones.annotate(name_length=Length("name"))
|
|
415
|
-
.filter(
|
|
424
|
+
.filter(name__iregex=regex_from_list(get_parent_zone_names(self.name)))
|
|
416
425
|
.order_by("name_length")
|
|
417
426
|
)
|
|
418
427
|
|
|
419
428
|
@property
|
|
420
429
|
def delegation_records(self):
|
|
421
430
|
descendant_zone_names = [
|
|
422
|
-
|
|
431
|
+
rf"{name}."
|
|
432
|
+
for name in (
|
|
433
|
+
name.lower()
|
|
434
|
+
for name in self.descendant_zones.values_list("name", flat=True)
|
|
435
|
+
)
|
|
423
436
|
]
|
|
424
437
|
|
|
425
438
|
ns_records = (
|
|
426
439
|
self.records.filter(type=RecordTypeChoices.NS)
|
|
427
|
-
.exclude(
|
|
428
|
-
.filter(
|
|
440
|
+
.exclude(fqdn__iexact=self.fqdn)
|
|
441
|
+
.filter(fqdn__iregex=regex_from_list(descendant_zone_names))
|
|
429
442
|
)
|
|
430
443
|
ns_values = [record.value_fqdn for record in ns_records]
|
|
431
444
|
|
|
@@ -663,6 +676,9 @@ class Zone(ObjectModificationMixin, ContactsMixin, NetBoxModel):
|
|
|
663
676
|
def clean_fields(self, exclude=None):
|
|
664
677
|
defaults = settings.PLUGINS_CONFIG.get("netbox_dns")
|
|
665
678
|
|
|
679
|
+
if get_plugin_config("netbox_dns", "convert_names_to_lowercase", False):
|
|
680
|
+
self.name = self.name.lower()
|
|
681
|
+
|
|
666
682
|
if self.view_id is None:
|
|
667
683
|
self.view_id = View.get_default_view().pk
|
|
668
684
|
|
|
@@ -14,6 +14,7 @@ __all__ = (
|
|
|
14
14
|
"value_to_unicode",
|
|
15
15
|
"normalize_name",
|
|
16
16
|
"network_to_reverse",
|
|
17
|
+
"regex_from_list",
|
|
17
18
|
)
|
|
18
19
|
|
|
19
20
|
|
|
@@ -106,3 +107,7 @@ def network_to_reverse(network):
|
|
|
106
107
|
|
|
107
108
|
if labels:
|
|
108
109
|
return ".".join(ip_network[0].reverse_dns.split(".")[-labels:])
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def regex_from_list(names):
|
|
113
|
+
return f"^({'|'.join(re.escape(name) for name in names)})$"
|
netbox_dns/utilities/dns.py
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
from dns import name as dns_name
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
__all__ = ("get_parent_zone_names",)
|
|
5
4
|
|
|
6
5
|
|
|
7
6
|
def get_parent_zone_names(name, min_labels=1, include_self=False):
|
|
8
|
-
fqdn = dns_name.from_text(name)
|
|
7
|
+
fqdn = dns_name.from_text(name.lower())
|
|
9
8
|
return [
|
|
10
9
|
fqdn.split(i)[1].to_text().rstrip(".")
|
|
11
10
|
for i in range(min_labels + 1, len(fqdn.labels) + include_self)
|
|
@@ -13,6 +13,7 @@ from ipam.models import IPAddress, Prefix
|
|
|
13
13
|
from netbox_dns.choices import RecordStatusChoices
|
|
14
14
|
|
|
15
15
|
from .dns import get_parent_zone_names
|
|
16
|
+
from .conversions import regex_from_list
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
__all__ = (
|
|
@@ -90,8 +91,10 @@ def get_zones(ip_address, view=None, old_zone=None):
|
|
|
90
91
|
|
|
91
92
|
zones = Zone.objects.filter(
|
|
92
93
|
view__in=views,
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
name__iregex=regex_from_list(
|
|
95
|
+
get_parent_zone_names(
|
|
96
|
+
ip_address.dns_name, min_labels=min_labels, include_self=True
|
|
97
|
+
)
|
|
95
98
|
),
|
|
96
99
|
active=True,
|
|
97
100
|
)
|
netbox_dns/views/record.py
CHANGED
|
@@ -16,7 +16,11 @@ from netbox_dns.forms import (
|
|
|
16
16
|
from netbox_dns.models import Record, Zone
|
|
17
17
|
from netbox_dns.choices import RecordTypeChoices
|
|
18
18
|
from netbox_dns.tables import RecordTable, ManagedRecordTable, RelatedRecordTable
|
|
19
|
-
from netbox_dns.utilities import
|
|
19
|
+
from netbox_dns.utilities import (
|
|
20
|
+
value_to_unicode,
|
|
21
|
+
get_parent_zone_names,
|
|
22
|
+
regex_from_list,
|
|
23
|
+
)
|
|
20
24
|
|
|
21
25
|
|
|
22
26
|
__all__ = (
|
|
@@ -74,7 +78,9 @@ class RecordView(generic.ObjectView):
|
|
|
74
78
|
)
|
|
75
79
|
|
|
76
80
|
if instance.zone.view.zones.filter(
|
|
77
|
-
|
|
81
|
+
name__iregex=regex_from_list(
|
|
82
|
+
get_parent_zone_names(instance.value_fqdn, min_labels=1)
|
|
83
|
+
),
|
|
78
84
|
active=True,
|
|
79
85
|
).exists():
|
|
80
86
|
raise (
|
|
@@ -97,7 +103,9 @@ class RecordView(generic.ObjectView):
|
|
|
97
103
|
)
|
|
98
104
|
|
|
99
105
|
parent_zones = instance.zone.view.zones.filter(
|
|
100
|
-
|
|
106
|
+
name__iregex=regex_from_list(
|
|
107
|
+
get_parent_zone_names(instance.fqdn, include_self=True)
|
|
108
|
+
),
|
|
101
109
|
)
|
|
102
110
|
|
|
103
111
|
for parent_zone in parent_zones:
|
|
@@ -148,10 +156,12 @@ class RecordView(generic.ObjectView):
|
|
|
148
156
|
|
|
149
157
|
if Zone.objects.filter(
|
|
150
158
|
active=True,
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
159
|
+
name__iregex=regex_from_list(
|
|
160
|
+
get_parent_zone_names(
|
|
161
|
+
instance.fqdn,
|
|
162
|
+
min_labels=len(fqdn) - len(name),
|
|
163
|
+
include_self=True,
|
|
164
|
+
)
|
|
155
165
|
),
|
|
156
166
|
).exists():
|
|
157
167
|
context["mask_warning"] = _(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
netbox_dns/__init__.py,sha256=
|
|
1
|
+
netbox_dns/__init__.py,sha256=nnD4iq2_TUmMshut8Z3viAIlrY0RSc9YH6fllV11R4E,3098
|
|
2
2
|
netbox_dns/apps.py,sha256=JCW5eS-AQBUubDJve1DjP-IRFKTFGQh1NLGWzJpC5MI,151
|
|
3
3
|
netbox_dns/navigation.py,sha256=36clAzlWftW94_VZ3EHu8_btzzA_dah50CLTfoov-O4,6226
|
|
4
4
|
netbox_dns/template_content.py,sha256=T06L7-m4eGrLMeGsCvPpQLAGfn3S2FL7z0Cd1hhbisY,4225
|
|
@@ -37,12 +37,12 @@ netbox_dns/filtersets/zone_template.py,sha256=So-sxWeDhlm-DTtujYp5B_gDbnAVUHnLdR
|
|
|
37
37
|
netbox_dns/forms/__init__.py,sha256=axENVF9vX9BtDKCNxrapRjye1NnygUg9BS0BBj6a0io,209
|
|
38
38
|
netbox_dns/forms/nameserver.py,sha256=GJe3ece4yIGwMtLZ6wQihBrJu1dk_ZSiwX-vSU0fRa0,3397
|
|
39
39
|
netbox_dns/forms/record.py,sha256=QNGLqWprhsGFTSlH2YAe-SHmCx1K1QbT_osAhCegyJg,8252
|
|
40
|
-
netbox_dns/forms/record_template.py,sha256=
|
|
40
|
+
netbox_dns/forms/record_template.py,sha256=UcB-AlK-ZDoNmIMJhUrxfr76oGkwJ8d7JhkDj9vbMDI,6337
|
|
41
41
|
netbox_dns/forms/registrar.py,sha256=GaRH3w5zlhrpwy_U0pxlrl1DrAEaMB78MUlnGxBRwZI,3949
|
|
42
42
|
netbox_dns/forms/registration_contact.py,sha256=IhNAqElY7hOdpDG0jwWMdy3y2mB43xmjUhj3lsgJ3SE,5906
|
|
43
43
|
netbox_dns/forms/view.py,sha256=GacwKHXSDvxQEs-d3ys7rietqA_MzpSd0XjWaSsIbU0,10339
|
|
44
|
-
netbox_dns/forms/zone.py,sha256=
|
|
45
|
-
netbox_dns/forms/zone_template.py,sha256=
|
|
44
|
+
netbox_dns/forms/zone.py,sha256=b63kCukS4uFgkxGnQ_h-i8d-d8GaSINfppDJlrBuXJA,26195
|
|
45
|
+
netbox_dns/forms/zone_template.py,sha256=P7jdEz0MI_tjD_fuVDuKOIFCInqGI4opf7l_qaDmG1g,10098
|
|
46
46
|
netbox_dns/graphql/__init__.py,sha256=jghYD6uOSAis6YyLbtI3YJGZfwPw1uL2FBRsHs1EhNk,514
|
|
47
47
|
netbox_dns/graphql/filters.py,sha256=fHCjFIwbPBJJMk2W7HI8LhrfFhCtQtCM9IE8ZMgVafc,1766
|
|
48
48
|
netbox_dns/graphql/schema.py,sha256=q9DQ_hfRB0e6Znq4-IS6UEeTOfMkZmrWkwxcAql1uOA,2270
|
|
@@ -68,6 +68,7 @@ netbox_dns/migrations/0010_view_ip_address_filter.py,sha256=uARQADJB7u1vpx0TBlOf
|
|
|
68
68
|
netbox_dns/migrations/0011_rename_related_fields.py,sha256=j9lI-QBmTSzOrAxDl02SdgHZtv9nRfJ3cZX_wjj5urM,1881
|
|
69
69
|
netbox_dns/migrations/0012_natural_ordering.py,sha256=h5XVSmRwisUqz5OJzkBW41dwHIBlu08zqG2-1mxiiw4,2725
|
|
70
70
|
netbox_dns/migrations/0013_zonetemplate_soa_mname_zonetemplate_soa_rname.py,sha256=Y6TdD_dUZ-Pb1kuRR3l3kSwObn_Cpcmp3tm75qSkc5g,795
|
|
71
|
+
netbox_dns/migrations/0014_alter_unique_constraints_lowercase.py,sha256=Ueesv7uoB2ZQ1-7kG_qsMlPv0mn3mdDeI8OoAKIschM,1409
|
|
71
72
|
netbox_dns/migrations/0020_netbox_3_4.py,sha256=UMcHdn8ZAuQjUaM_3rEGpktYrM0TuvhccD7Jt7WQnPs,1271
|
|
72
73
|
netbox_dns/migrations/0021_record_ip_address.py,sha256=EqdhWXmq7aiK4X79xTRUZng3zFncCl-8JoO65HqlJKw,3244
|
|
73
74
|
netbox_dns/migrations/0022_search.py,sha256=KW1ffEZ4-0dppGQ_KD1EN7iw8eQJOnDco-xfJFRZqKQ,172
|
|
@@ -82,13 +83,13 @@ netbox_dns/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
|
|
|
82
83
|
netbox_dns/mixins/__init__.py,sha256=LxTEfpod_RHCyMtnzDljv0_dwqp2z3Q6tqbXW8LTGD8,35
|
|
83
84
|
netbox_dns/mixins/object_modification.py,sha256=AR64fU5f7g-scNAj9b54eSoS9dpjyOpqrxXVXPcOhY8,1807
|
|
84
85
|
netbox_dns/models/__init__.py,sha256=iTTJNgUfPAmU4n41usqDSGPvncd4Wpsb9f43ryVDDOs,209
|
|
85
|
-
netbox_dns/models/nameserver.py,sha256=
|
|
86
|
-
netbox_dns/models/record.py,sha256=
|
|
87
|
-
netbox_dns/models/record_template.py,sha256=
|
|
86
|
+
netbox_dns/models/nameserver.py,sha256=ivZpIVfgQLdDhrtqYPi-zRbygVgl3aff2FMsq1M3qA8,4044
|
|
87
|
+
netbox_dns/models/record.py,sha256=ot2f5LVxj4ZjNanE29y-30iUK4YZS7-0-37ds3hWtjo,29716
|
|
88
|
+
netbox_dns/models/record_template.py,sha256=kt-_sMFSMKmuKU8voVqz1-Lh7Wi7lPcA2ExPFQYLoxM,5345
|
|
88
89
|
netbox_dns/models/registrar.py,sha256=L5tbO8rtOa0VCs_y90nHYLKSRKBnnUhh_6sxZ3Mm2kk,1942
|
|
89
90
|
netbox_dns/models/registration_contact.py,sha256=O7T1clUjuilZnDjvhJKaHZdmNEF4aLg2h8K5p4llWOs,3825
|
|
90
91
|
netbox_dns/models/view.py,sha256=gQvKNr_FmhG2EMz2T8kWbdK4b8CyqI-Qc67-Dgrx2SI,4808
|
|
91
|
-
netbox_dns/models/zone.py,sha256=
|
|
92
|
+
netbox_dns/models/zone.py,sha256=GhFtsOkA0zPB0VMfXtqFgJZrnrLul-SqgouZbMBcc50,33465
|
|
92
93
|
netbox_dns/models/zone_template.py,sha256=QjjOvSZktH_6l64bCZzVudnL1s9qU6_ZVDkhrhW1zqc,4970
|
|
93
94
|
netbox_dns/signals/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
94
95
|
netbox_dns/signals/ipam_dnssync.py,sha256=1zhlf4cMcJLlFosX7YzyqVYdFFHV4MFwTz5KCdL8xQc,7730
|
|
@@ -126,24 +127,24 @@ netbox_dns/templates/netbox_dns/zone/rfc2317_child_zone.html,sha256=rWlmb3zRQbLY
|
|
|
126
127
|
netbox_dns/templatetags/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
127
128
|
netbox_dns/templatetags/netbox_dns.py,sha256=DND1DMPzv636Rak3M6Hor_Vw6pjqUfSTquofIw4dIsA,223
|
|
128
129
|
netbox_dns/utilities/__init__.py,sha256=cSGf-nGaRWx9b-Xrh3dLMJYoWNsZ6FF-qdmV4F1uOgg,74
|
|
129
|
-
netbox_dns/utilities/conversions.py,sha256=
|
|
130
|
-
netbox_dns/utilities/dns.py,sha256=
|
|
131
|
-
netbox_dns/utilities/ipam_dnssync.py,sha256=
|
|
130
|
+
netbox_dns/utilities/conversions.py,sha256=eKA17FSU-Us3cfda9DAgtZgmr3r2o5UbJ_1giD3LLvE,2713
|
|
131
|
+
netbox_dns/utilities/dns.py,sha256=UBiyQe8thiOTnKOmU9e2iRHHnGF9toVLe4efU623kX4,322
|
|
132
|
+
netbox_dns/utilities/ipam_dnssync.py,sha256=_yuHoah_QN-opsZB51yGCkwjkij7nrmTgKHUZ-bQrBI,9625
|
|
132
133
|
netbox_dns/validators/__init__.py,sha256=Mr8TvmcJTa8Pubj8TzbFBKfbHhEmGcr5JdQvczEJ39A,72
|
|
133
134
|
netbox_dns/validators/dns_name.py,sha256=Sil68Av49jfZPzgFMV_1qEcLnuuAWXmbxfAJPDXUsGg,3766
|
|
134
135
|
netbox_dns/validators/dns_value.py,sha256=-mc62mth-hlbPUPe_RlCR7vo1KSD6_gQDXiE8rjB-Cc,5206
|
|
135
136
|
netbox_dns/validators/rfc2317.py,sha256=uKkwxpakiFFKdYA0qy8WSlEnbFwJD4MDw6gGV4F6skg,706
|
|
136
137
|
netbox_dns/views/__init__.py,sha256=axENVF9vX9BtDKCNxrapRjye1NnygUg9BS0BBj6a0io,209
|
|
137
138
|
netbox_dns/views/nameserver.py,sha256=6lHg8fqBjc_SoITzFj1FiRARpPF7nSn9knAZxe9x5Rg,3932
|
|
138
|
-
netbox_dns/views/record.py,sha256=
|
|
139
|
+
netbox_dns/views/record.py,sha256=6tOTC7BbQ5XOC7wr94LjFMR3epOi47HP5qIETNvj5sE,6715
|
|
139
140
|
netbox_dns/views/record_template.py,sha256=CbSyckBvyEvcZCeZgK3q0fJsa1_5HbwUflh_iM7JjH0,3134
|
|
140
141
|
netbox_dns/views/registrar.py,sha256=Um_2wnzmP2bqbdMUhBPhny2My0R8fMXScQ9GLiTCrvg,2808
|
|
141
142
|
netbox_dns/views/registration_contact.py,sha256=c9KrNkfFNsb55pL74A5rN1CNx32M82V6mdwBYduNxas,3596
|
|
142
143
|
netbox_dns/views/view.py,sha256=VfrKaLC9D_KNZNmRyFVohRlmMlMbtblAuPgNg0LNyf8,3421
|
|
143
144
|
netbox_dns/views/zone.py,sha256=W66Miyaf4RKW-8z5wMrerrtmHclhht3h-lPqTWFpiOw,7163
|
|
144
145
|
netbox_dns/views/zone_template.py,sha256=IIW1lr6RQmhShtqJu6A6LnHdxdBrkkZQHxIDSTqQeyc,2705
|
|
145
|
-
netbox_plugin_dns-1.2.
|
|
146
|
-
netbox_plugin_dns-1.2.
|
|
147
|
-
netbox_plugin_dns-1.2.
|
|
148
|
-
netbox_plugin_dns-1.2.
|
|
149
|
-
netbox_plugin_dns-1.2.
|
|
146
|
+
netbox_plugin_dns-1.2.5.dist-info/LICENSE,sha256=I3tDu11bZfhFm3EkV4zOD5TmWgLjnUNLEFwrdjniZYs,1112
|
|
147
|
+
netbox_plugin_dns-1.2.5.dist-info/METADATA,sha256=CmCyW64s9xmp49ADdEBc48ns2IOYXysCOA8zL9-Ad_0,7636
|
|
148
|
+
netbox_plugin_dns-1.2.5.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
|
|
149
|
+
netbox_plugin_dns-1.2.5.dist-info/top_level.txt,sha256=sA1Rwl1mRKvMC6XHe2ylZ1GF-Q1NGd08XedK9Y4xZc4,11
|
|
150
|
+
netbox_plugin_dns-1.2.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|