netbox-plugin-dns 1.2.9__py3-none-any.whl → 1.3b2__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 +1 -1
- netbox_dns/api/nested_serializers.py +54 -49
- netbox_dns/api/serializers_/dnssec_key_template.py +21 -13
- netbox_dns/api/serializers_/dnssec_policy.py +88 -40
- netbox_dns/api/serializers_/nameserver.py +21 -13
- netbox_dns/api/serializers_/record.py +45 -37
- netbox_dns/api/serializers_/record_template.py +21 -12
- netbox_dns/api/serializers_/registrar.py +14 -5
- netbox_dns/api/serializers_/registration_contact.py +13 -5
- netbox_dns/api/serializers_/view.py +28 -19
- netbox_dns/api/serializers_/zone.py +87 -63
- netbox_dns/api/serializers_/zone_template.py +40 -34
- netbox_dns/choices/dnssec_key_template.py +4 -0
- netbox_dns/filtersets/dnssec_key_template.py +10 -4
- netbox_dns/filtersets/dnssec_policy.py +1 -0
- netbox_dns/filtersets/nameserver.py +9 -4
- netbox_dns/filtersets/record.py +14 -13
- netbox_dns/filtersets/record_template.py +13 -12
- netbox_dns/filtersets/registrar.py +1 -0
- netbox_dns/filtersets/registration_contact.py +1 -0
- netbox_dns/filtersets/view.py +10 -4
- netbox_dns/filtersets/zone.py +22 -21
- netbox_dns/filtersets/zone_template.py +10 -9
- netbox_dns/forms/dnssec_key_template.py +97 -46
- netbox_dns/forms/dnssec_policy.py +130 -110
- netbox_dns/forms/nameserver.py +71 -36
- netbox_dns/forms/record.py +96 -78
- netbox_dns/forms/record_template.py +87 -59
- netbox_dns/forms/registrar.py +55 -39
- netbox_dns/forms/registration_contact.py +64 -41
- netbox_dns/forms/view.py +98 -51
- netbox_dns/forms/zone.py +259 -250
- netbox_dns/forms/zone_template.py +151 -101
- netbox_dns/graphql/enums.py +41 -0
- netbox_dns/graphql/filter_lookups.py +13 -0
- netbox_dns/graphql/filters/__init__.py +12 -0
- netbox_dns/graphql/filters/dnssec_key_template.py +63 -0
- netbox_dns/graphql/filters/dnssec_policy.py +123 -0
- netbox_dns/graphql/filters/nameserver.py +32 -0
- netbox_dns/graphql/filters/record.py +89 -0
- netbox_dns/graphql/filters/record_template.py +55 -0
- netbox_dns/graphql/filters/registrar.py +30 -0
- netbox_dns/graphql/filters/registration_contact.py +27 -0
- netbox_dns/graphql/filters/view.py +28 -0
- netbox_dns/graphql/filters/zone.py +146 -0
- netbox_dns/graphql/filters/zone_template.py +97 -0
- netbox_dns/models/dnssec_key_template.py +24 -27
- netbox_dns/models/dnssec_policy.py +17 -21
- netbox_dns/models/nameserver.py +26 -30
- netbox_dns/models/record.py +42 -46
- netbox_dns/models/record_template.py +30 -34
- netbox_dns/models/registrar.py +13 -17
- netbox_dns/models/registration_contact.py +33 -37
- netbox_dns/models/view.py +16 -20
- netbox_dns/models/zone.py +75 -77
- netbox_dns/models/zone_template.py +35 -39
- netbox_dns/tables/dnssec_key_template.py +13 -12
- netbox_dns/tables/dnssec_policy.py +18 -15
- netbox_dns/tables/nameserver.py +10 -8
- netbox_dns/tables/record.py +29 -21
- netbox_dns/tables/record_template.py +21 -17
- netbox_dns/tables/registrar.py +15 -9
- netbox_dns/tables/registration_contact.py +15 -9
- netbox_dns/tables/view.py +24 -12
- netbox_dns/tables/zone.py +23 -21
- netbox_dns/tables/zone_template.py +17 -13
- netbox_dns/views/dnssec_key_template.py +0 -9
- netbox_dns/views/dnssec_policy.py +0 -9
- netbox_dns/views/nameserver.py +0 -9
- netbox_dns/views/record.py +0 -9
- netbox_dns/views/record_template.py +0 -3
- netbox_dns/views/registrar.py +0 -3
- netbox_dns/views/registration_contact.py +0 -3
- netbox_dns/views/view.py +0 -9
- netbox_dns/views/zone.py +0 -10
- netbox_dns/views/zone_template.py +0 -4
- {netbox_plugin_dns-1.2.9.dist-info → netbox_plugin_dns-1.3b2.dist-info}/METADATA +4 -3
- {netbox_plugin_dns-1.2.9.dist-info → netbox_plugin_dns-1.3b2.dist-info}/RECORD +81 -69
- netbox_dns/graphql/filters.py +0 -88
- {netbox_plugin_dns-1.2.9.dist-info → netbox_plugin_dns-1.3b2.dist-info}/WHEEL +0 -0
- {netbox_plugin_dns-1.2.9.dist-info → netbox_plugin_dns-1.3b2.dist-info}/licenses/LICENSE +0 -0
- {netbox_plugin_dns-1.2.9.dist-info → netbox_plugin_dns-1.3b2.dist-info}/top_level.txt +0 -0
netbox_dns/models/nameserver.py
CHANGED
|
@@ -4,7 +4,6 @@ from django.core.exceptions import ValidationError
|
|
|
4
4
|
from django.db import models, transaction
|
|
5
5
|
from django.db.models import Q, UniqueConstraint
|
|
6
6
|
from django.db.models.functions import Lower
|
|
7
|
-
from django.urls import reverse
|
|
8
7
|
from django.utils.translation import gettext_lazy as _
|
|
9
8
|
|
|
10
9
|
from netbox.models import NetBoxModel
|
|
@@ -29,31 +28,6 @@ __all__ = (
|
|
|
29
28
|
|
|
30
29
|
|
|
31
30
|
class NameServer(ObjectModificationMixin, ContactsMixin, NetBoxModel):
|
|
32
|
-
name = models.CharField(
|
|
33
|
-
verbose_name=_("Name"),
|
|
34
|
-
max_length=255,
|
|
35
|
-
db_collation="natural_sort",
|
|
36
|
-
)
|
|
37
|
-
description = models.CharField(
|
|
38
|
-
verbose_name=_("Description"),
|
|
39
|
-
max_length=200,
|
|
40
|
-
blank=True,
|
|
41
|
-
)
|
|
42
|
-
tenant = models.ForeignKey(
|
|
43
|
-
verbose_name=_("Tenant"),
|
|
44
|
-
to="tenancy.Tenant",
|
|
45
|
-
on_delete=models.PROTECT,
|
|
46
|
-
related_name="netbox_dns_nameservers",
|
|
47
|
-
blank=True,
|
|
48
|
-
null=True,
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
clone_fields = (
|
|
52
|
-
"name",
|
|
53
|
-
"description",
|
|
54
|
-
"tenant",
|
|
55
|
-
)
|
|
56
|
-
|
|
57
31
|
class Meta:
|
|
58
32
|
verbose_name = _("Nameserver")
|
|
59
33
|
verbose_name_plural = _("Nameservers")
|
|
@@ -70,20 +44,41 @@ class NameServer(ObjectModificationMixin, ContactsMixin, NetBoxModel):
|
|
|
70
44
|
),
|
|
71
45
|
]
|
|
72
46
|
|
|
47
|
+
clone_fields = (
|
|
48
|
+
"name",
|
|
49
|
+
"description",
|
|
50
|
+
"tenant",
|
|
51
|
+
)
|
|
52
|
+
|
|
73
53
|
def __str__(self):
|
|
74
54
|
try:
|
|
75
55
|
return dns_name.from_text(self.name, origin=None).to_unicode()
|
|
76
56
|
except dns_name.IDNAException:
|
|
77
57
|
return self.name
|
|
78
58
|
|
|
59
|
+
name = models.CharField(
|
|
60
|
+
verbose_name=_("Name"),
|
|
61
|
+
max_length=255,
|
|
62
|
+
db_collation="natural_sort",
|
|
63
|
+
)
|
|
64
|
+
description = models.CharField(
|
|
65
|
+
verbose_name=_("Description"),
|
|
66
|
+
max_length=200,
|
|
67
|
+
blank=True,
|
|
68
|
+
)
|
|
69
|
+
tenant = models.ForeignKey(
|
|
70
|
+
verbose_name=_("Tenant"),
|
|
71
|
+
to="tenancy.Tenant",
|
|
72
|
+
on_delete=models.PROTECT,
|
|
73
|
+
related_name="netbox_dns_nameservers",
|
|
74
|
+
blank=True,
|
|
75
|
+
null=True,
|
|
76
|
+
)
|
|
77
|
+
|
|
79
78
|
@property
|
|
80
79
|
def display_name(self):
|
|
81
80
|
return name_to_unicode(self.name)
|
|
82
81
|
|
|
83
|
-
# TODO: Remove in version 1.3.0 (NetBox #18555)
|
|
84
|
-
def get_absolute_url(self):
|
|
85
|
-
return reverse("plugins:netbox_dns:nameserver", kwargs={"pk": self.pk})
|
|
86
|
-
|
|
87
82
|
def clean_fields(self, exclude=None):
|
|
88
83
|
if get_plugin_config("netbox_dns", "convert_names_to_lowercase", False):
|
|
89
84
|
self.name = self.name.lower()
|
|
@@ -143,6 +138,7 @@ class NameServer(ObjectModificationMixin, ContactsMixin, NetBoxModel):
|
|
|
143
138
|
@register_search
|
|
144
139
|
class NameServerIndex(SearchIndex):
|
|
145
140
|
model = NameServer
|
|
141
|
+
|
|
146
142
|
fields = (
|
|
147
143
|
("name", 100),
|
|
148
144
|
("description", 500),
|
netbox_dns/models/record.py
CHANGED
|
@@ -8,7 +8,6 @@ from dns import rdata
|
|
|
8
8
|
from django.core.exceptions import ValidationError
|
|
9
9
|
from django.db import transaction, models
|
|
10
10
|
from django.db.models import Q, ExpressionWrapper, BooleanField, Min
|
|
11
|
-
from django.urls import reverse
|
|
12
11
|
from django.conf import settings
|
|
13
12
|
from django.utils.translation import gettext_lazy as _
|
|
14
13
|
|
|
@@ -116,6 +115,47 @@ class RecordManager(models.Manager.from_queryset(RestrictedQuerySet)):
|
|
|
116
115
|
|
|
117
116
|
|
|
118
117
|
class Record(ObjectModificationMixin, ContactsMixin, NetBoxModel):
|
|
118
|
+
class Meta:
|
|
119
|
+
verbose_name = _("Record")
|
|
120
|
+
verbose_name_plural = _("Records")
|
|
121
|
+
|
|
122
|
+
ordering = (
|
|
123
|
+
"fqdn",
|
|
124
|
+
"zone",
|
|
125
|
+
"name",
|
|
126
|
+
"type",
|
|
127
|
+
"value",
|
|
128
|
+
"status",
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
objects = RecordManager()
|
|
132
|
+
raw_objects = RestrictedQuerySet.as_manager()
|
|
133
|
+
|
|
134
|
+
clone_fields = (
|
|
135
|
+
"zone",
|
|
136
|
+
"type",
|
|
137
|
+
"name",
|
|
138
|
+
"value",
|
|
139
|
+
"status",
|
|
140
|
+
"ttl",
|
|
141
|
+
"disable_ptr",
|
|
142
|
+
"description",
|
|
143
|
+
"tenant",
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
def __str__(self):
|
|
147
|
+
try:
|
|
148
|
+
fqdn = dns_name.from_text(
|
|
149
|
+
self.name, origin=dns_name.from_text(self.zone.name)
|
|
150
|
+
).relativize(dns_name.root)
|
|
151
|
+
name = fqdn.to_unicode()
|
|
152
|
+
except dns_name.IDNAException:
|
|
153
|
+
name = fqdn.to_text()
|
|
154
|
+
except dns_name.LabelTooLong:
|
|
155
|
+
name = f"{self.name[:59]}..."
|
|
156
|
+
|
|
157
|
+
return f"{name} [{self.type}]"
|
|
158
|
+
|
|
119
159
|
unique_ptr_qs = Q(
|
|
120
160
|
Q(disable_ptr=False),
|
|
121
161
|
Q(Q(type=RecordTypeChoices.A) | Q(type=RecordTypeChoices.AAAA)),
|
|
@@ -215,47 +255,6 @@ class Record(ObjectModificationMixin, ContactsMixin, NetBoxModel):
|
|
|
215
255
|
blank=True,
|
|
216
256
|
)
|
|
217
257
|
|
|
218
|
-
objects = RecordManager()
|
|
219
|
-
raw_objects = RestrictedQuerySet.as_manager()
|
|
220
|
-
|
|
221
|
-
clone_fields = (
|
|
222
|
-
"zone",
|
|
223
|
-
"type",
|
|
224
|
-
"name",
|
|
225
|
-
"value",
|
|
226
|
-
"status",
|
|
227
|
-
"ttl",
|
|
228
|
-
"disable_ptr",
|
|
229
|
-
"description",
|
|
230
|
-
"tenant",
|
|
231
|
-
)
|
|
232
|
-
|
|
233
|
-
class Meta:
|
|
234
|
-
verbose_name = _("Record")
|
|
235
|
-
verbose_name_plural = _("Records")
|
|
236
|
-
|
|
237
|
-
ordering = (
|
|
238
|
-
"fqdn",
|
|
239
|
-
"zone",
|
|
240
|
-
"name",
|
|
241
|
-
"type",
|
|
242
|
-
"value",
|
|
243
|
-
"status",
|
|
244
|
-
)
|
|
245
|
-
|
|
246
|
-
def __str__(self):
|
|
247
|
-
try:
|
|
248
|
-
fqdn = dns_name.from_text(
|
|
249
|
-
self.name, origin=dns_name.from_text(self.zone.name)
|
|
250
|
-
).relativize(dns_name.root)
|
|
251
|
-
name = fqdn.to_unicode()
|
|
252
|
-
except dns_name.IDNAException:
|
|
253
|
-
name = fqdn.to_text()
|
|
254
|
-
except dns_name.LabelTooLong:
|
|
255
|
-
name = f"{self.name[:59]}..."
|
|
256
|
-
|
|
257
|
-
return f"{name} [{self.type}]"
|
|
258
|
-
|
|
259
258
|
@property
|
|
260
259
|
def display_name(self):
|
|
261
260
|
return name_to_unicode(self.name)
|
|
@@ -263,10 +262,6 @@ class Record(ObjectModificationMixin, ContactsMixin, NetBoxModel):
|
|
|
263
262
|
def get_status_color(self):
|
|
264
263
|
return RecordStatusChoices.colors.get(self.status)
|
|
265
264
|
|
|
266
|
-
# TODO: Remove in version 1.3.0 (NetBox #18555)
|
|
267
|
-
def get_absolute_url(self):
|
|
268
|
-
return reverse("plugins:netbox_dns:record", kwargs={"pk": self.pk})
|
|
269
|
-
|
|
270
265
|
@property
|
|
271
266
|
def value_fqdn(self):
|
|
272
267
|
if self.type not in (RecordTypeChoices.CNAME, RecordTypeChoices.NS):
|
|
@@ -937,6 +932,7 @@ class Record(ObjectModificationMixin, ContactsMixin, NetBoxModel):
|
|
|
937
932
|
@register_search
|
|
938
933
|
class RecordIndex(SearchIndex):
|
|
939
934
|
model = Record
|
|
935
|
+
|
|
940
936
|
fields = (
|
|
941
937
|
("fqdn", 100),
|
|
942
938
|
("name", 120),
|
|
@@ -3,7 +3,6 @@ from dns import name as dns_name
|
|
|
3
3
|
|
|
4
4
|
from django.core.exceptions import ValidationError
|
|
5
5
|
from django.db import models
|
|
6
|
-
from django.urls import reverse
|
|
7
6
|
from django.utils.translation import gettext_lazy as _
|
|
8
7
|
|
|
9
8
|
from netbox.models import NetBoxModel
|
|
@@ -23,6 +22,35 @@ __all__ = (
|
|
|
23
22
|
|
|
24
23
|
|
|
25
24
|
class RecordTemplate(NetBoxModel):
|
|
25
|
+
class Meta:
|
|
26
|
+
verbose_name = _("Record Template")
|
|
27
|
+
verbose_name_plural = _("Record Templates")
|
|
28
|
+
|
|
29
|
+
ordering = ("name",)
|
|
30
|
+
|
|
31
|
+
clone_fields = (
|
|
32
|
+
"record_name",
|
|
33
|
+
"description",
|
|
34
|
+
"type",
|
|
35
|
+
"value",
|
|
36
|
+
"status",
|
|
37
|
+
"ttl",
|
|
38
|
+
"disable_ptr",
|
|
39
|
+
"tenant",
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
template_fields = (
|
|
43
|
+
"type",
|
|
44
|
+
"value",
|
|
45
|
+
"status",
|
|
46
|
+
"ttl",
|
|
47
|
+
"disable_ptr",
|
|
48
|
+
"tenant",
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
def __str__(self):
|
|
52
|
+
return str(self.name)
|
|
53
|
+
|
|
26
54
|
name = models.CharField(
|
|
27
55
|
verbose_name=_("Template Name"),
|
|
28
56
|
unique=True,
|
|
@@ -72,42 +100,9 @@ class RecordTemplate(NetBoxModel):
|
|
|
72
100
|
null=True,
|
|
73
101
|
)
|
|
74
102
|
|
|
75
|
-
clone_fields = (
|
|
76
|
-
"record_name",
|
|
77
|
-
"description",
|
|
78
|
-
"type",
|
|
79
|
-
"value",
|
|
80
|
-
"status",
|
|
81
|
-
"ttl",
|
|
82
|
-
"disable_ptr",
|
|
83
|
-
"tenant",
|
|
84
|
-
)
|
|
85
|
-
|
|
86
|
-
template_fields = (
|
|
87
|
-
"type",
|
|
88
|
-
"value",
|
|
89
|
-
"status",
|
|
90
|
-
"ttl",
|
|
91
|
-
"disable_ptr",
|
|
92
|
-
"tenant",
|
|
93
|
-
)
|
|
94
|
-
|
|
95
|
-
class Meta:
|
|
96
|
-
verbose_name = _("Record Template")
|
|
97
|
-
verbose_name_plural = _("Record Templates")
|
|
98
|
-
|
|
99
|
-
ordering = ("name",)
|
|
100
|
-
|
|
101
|
-
def __str__(self):
|
|
102
|
-
return str(self.name)
|
|
103
|
-
|
|
104
103
|
def get_status_color(self):
|
|
105
104
|
return RecordStatusChoices.colors.get(self.status)
|
|
106
105
|
|
|
107
|
-
# TODO: Remove in version 1.3.0 (NetBox #18555)
|
|
108
|
-
def get_absolute_url(self):
|
|
109
|
-
return reverse("plugins:netbox_dns:recordtemplate", kwargs={"pk": self.pk})
|
|
110
|
-
|
|
111
106
|
def validate_name(self):
|
|
112
107
|
try:
|
|
113
108
|
name = dns_name.from_text(self.record_name, origin=None)
|
|
@@ -191,6 +186,7 @@ class RecordTemplate(NetBoxModel):
|
|
|
191
186
|
@register_search
|
|
192
187
|
class RecordTemplateIndex(SearchIndex):
|
|
193
188
|
model = RecordTemplate
|
|
189
|
+
|
|
194
190
|
fields = (
|
|
195
191
|
("name", 100),
|
|
196
192
|
("record_name", 120),
|
netbox_dns/models/registrar.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
from django.db import models
|
|
2
|
-
from django.urls import reverse
|
|
3
2
|
from django.utils.translation import gettext_lazy as _
|
|
4
3
|
|
|
5
4
|
from netbox.models import NetBoxModel
|
|
@@ -13,6 +12,18 @@ __all__ = (
|
|
|
13
12
|
|
|
14
13
|
|
|
15
14
|
class Registrar(NetBoxModel):
|
|
15
|
+
class Meta:
|
|
16
|
+
verbose_name = _("Registrar")
|
|
17
|
+
verbose_name_plural = _("Registrars")
|
|
18
|
+
|
|
19
|
+
ordering = (
|
|
20
|
+
"name",
|
|
21
|
+
"iana_id",
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
def __str__(self):
|
|
25
|
+
return str(self.name)
|
|
26
|
+
|
|
16
27
|
# +
|
|
17
28
|
# Data fields according to https://www.icann.org/resources/pages/rdds-labeling-policy-2017-02-01-en
|
|
18
29
|
# -
|
|
@@ -57,26 +68,11 @@ class Registrar(NetBoxModel):
|
|
|
57
68
|
blank=True,
|
|
58
69
|
)
|
|
59
70
|
|
|
60
|
-
# TODO: Remove in version 1.3.0 (NetBox #18555)
|
|
61
|
-
def get_absolute_url(self):
|
|
62
|
-
return reverse("plugins:netbox_dns:registrar", kwargs={"pk": self.pk})
|
|
63
|
-
|
|
64
|
-
def __str__(self):
|
|
65
|
-
return str(self.name)
|
|
66
|
-
|
|
67
|
-
class Meta:
|
|
68
|
-
verbose_name = _("Registrar")
|
|
69
|
-
verbose_name_plural = _("Registrars")
|
|
70
|
-
|
|
71
|
-
ordering = (
|
|
72
|
-
"name",
|
|
73
|
-
"iana_id",
|
|
74
|
-
)
|
|
75
|
-
|
|
76
71
|
|
|
77
72
|
@register_search
|
|
78
73
|
class RegistrarIndex(SearchIndex):
|
|
79
74
|
model = Registrar
|
|
75
|
+
|
|
80
76
|
fields = (
|
|
81
77
|
("name", 100),
|
|
82
78
|
("iana_id", 100),
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
from django.db import models
|
|
2
|
-
from django.urls import reverse
|
|
3
2
|
from django.utils.translation import gettext_lazy as _
|
|
4
3
|
|
|
5
4
|
from netbox.models import NetBoxModel
|
|
@@ -15,6 +14,38 @@ __all__ = (
|
|
|
15
14
|
|
|
16
15
|
|
|
17
16
|
class RegistrationContact(NetBoxModel):
|
|
17
|
+
class Meta:
|
|
18
|
+
verbose_name = _("Registration Contact")
|
|
19
|
+
verbose_name_plural = _("Registration Contacts")
|
|
20
|
+
|
|
21
|
+
ordering = (
|
|
22
|
+
"name",
|
|
23
|
+
"contact_id",
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
clone_fields = (
|
|
27
|
+
"name",
|
|
28
|
+
"description",
|
|
29
|
+
"organization",
|
|
30
|
+
"street",
|
|
31
|
+
"city",
|
|
32
|
+
"state_province",
|
|
33
|
+
"postal_code",
|
|
34
|
+
"country",
|
|
35
|
+
"phone",
|
|
36
|
+
"phone_ext",
|
|
37
|
+
"fax",
|
|
38
|
+
"fax_ext",
|
|
39
|
+
"email",
|
|
40
|
+
"tags",
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
def __str__(self):
|
|
44
|
+
if self.name is not None:
|
|
45
|
+
return f"{self.contact_id} ({self.name})"
|
|
46
|
+
|
|
47
|
+
return self.contact_id
|
|
48
|
+
|
|
18
49
|
# +
|
|
19
50
|
# Data fields according to https://www.icann.org/resources/pages/rdds-labeling-policy-2017-02-01-en
|
|
20
51
|
# -
|
|
@@ -101,42 +132,6 @@ class RegistrationContact(NetBoxModel):
|
|
|
101
132
|
related_name="netbox_dns_contact_set",
|
|
102
133
|
)
|
|
103
134
|
|
|
104
|
-
clone_fields = (
|
|
105
|
-
"name",
|
|
106
|
-
"description",
|
|
107
|
-
"organization",
|
|
108
|
-
"street",
|
|
109
|
-
"city",
|
|
110
|
-
"state_province",
|
|
111
|
-
"postal_code",
|
|
112
|
-
"country",
|
|
113
|
-
"phone",
|
|
114
|
-
"phone_ext",
|
|
115
|
-
"fax",
|
|
116
|
-
"fax_ext",
|
|
117
|
-
"email",
|
|
118
|
-
"tags",
|
|
119
|
-
)
|
|
120
|
-
|
|
121
|
-
# TODO: Remove in version 1.3.0 (NetBox #18555)
|
|
122
|
-
def get_absolute_url(self):
|
|
123
|
-
return reverse("plugins:netbox_dns:registrationcontact", kwargs={"pk": self.pk})
|
|
124
|
-
|
|
125
|
-
def __str__(self):
|
|
126
|
-
if self.name is not None:
|
|
127
|
-
return f"{self.contact_id} ({self.name})"
|
|
128
|
-
|
|
129
|
-
return self.contact_id
|
|
130
|
-
|
|
131
|
-
class Meta:
|
|
132
|
-
verbose_name = _("Registration Contact")
|
|
133
|
-
verbose_name_plural = _("Registration Contacts")
|
|
134
|
-
|
|
135
|
-
ordering = (
|
|
136
|
-
"name",
|
|
137
|
-
"contact_id",
|
|
138
|
-
)
|
|
139
|
-
|
|
140
135
|
@property
|
|
141
136
|
def zones(self):
|
|
142
137
|
return (
|
|
@@ -150,6 +145,7 @@ class RegistrationContact(NetBoxModel):
|
|
|
150
145
|
@register_search
|
|
151
146
|
class RegistrationContactIndex(SearchIndex):
|
|
152
147
|
model = RegistrationContact
|
|
148
|
+
|
|
153
149
|
fields = (
|
|
154
150
|
("name", 100),
|
|
155
151
|
("contact_id", 100),
|
netbox_dns/models/view.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
from django.db import models
|
|
2
|
-
from django.urls import reverse
|
|
3
2
|
from django.core.exceptions import ValidationError
|
|
4
3
|
from django.utils.translation import gettext_lazy as _
|
|
5
4
|
|
|
@@ -26,6 +25,21 @@ __all__ = (
|
|
|
26
25
|
|
|
27
26
|
|
|
28
27
|
class View(ObjectModificationMixin, ContactsMixin, NetBoxModel):
|
|
28
|
+
class Meta:
|
|
29
|
+
verbose_name = _("View")
|
|
30
|
+
verbose_name_plural = _("Views")
|
|
31
|
+
|
|
32
|
+
ordering = ("name",)
|
|
33
|
+
|
|
34
|
+
clone_fields = (
|
|
35
|
+
"name",
|
|
36
|
+
"description",
|
|
37
|
+
"tenant",
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
def __str__(self):
|
|
41
|
+
return str(self.name)
|
|
42
|
+
|
|
29
43
|
name = models.CharField(
|
|
30
44
|
verbose_name=_("Name"),
|
|
31
45
|
unique=True,
|
|
@@ -61,29 +75,10 @@ class View(ObjectModificationMixin, ContactsMixin, NetBoxModel):
|
|
|
61
75
|
null=True,
|
|
62
76
|
)
|
|
63
77
|
|
|
64
|
-
clone_fields = (
|
|
65
|
-
"name",
|
|
66
|
-
"description",
|
|
67
|
-
"tenant",
|
|
68
|
-
)
|
|
69
|
-
|
|
70
78
|
@classmethod
|
|
71
79
|
def get_default_view(cls):
|
|
72
80
|
return cls.objects.get(default_view=True)
|
|
73
81
|
|
|
74
|
-
# TODO: Remove in version 1.3.0 (NetBox #18555)
|
|
75
|
-
def get_absolute_url(self):
|
|
76
|
-
return reverse("plugins:netbox_dns:view", kwargs={"pk": self.pk})
|
|
77
|
-
|
|
78
|
-
def __str__(self):
|
|
79
|
-
return str(self.name)
|
|
80
|
-
|
|
81
|
-
class Meta:
|
|
82
|
-
verbose_name = _("View")
|
|
83
|
-
verbose_name_plural = _("Views")
|
|
84
|
-
|
|
85
|
-
ordering = ("name",)
|
|
86
|
-
|
|
87
82
|
def delete(self, *args, **kwargs):
|
|
88
83
|
if self.default_view:
|
|
89
84
|
if current_request.get() is not None:
|
|
@@ -161,6 +156,7 @@ class View(ObjectModificationMixin, ContactsMixin, NetBoxModel):
|
|
|
161
156
|
@register_search
|
|
162
157
|
class ViewIndex(SearchIndex):
|
|
163
158
|
model = View
|
|
159
|
+
|
|
164
160
|
fields = (
|
|
165
161
|
("name", 100),
|
|
166
162
|
("description", 500),
|
netbox_dns/models/zone.py
CHANGED
|
@@ -14,7 +14,6 @@ from django.db import models, transaction
|
|
|
14
14
|
from django.db.models import Q, Max, ExpressionWrapper, BooleanField, UniqueConstraint
|
|
15
15
|
from django.db.models.functions import Length, Lower
|
|
16
16
|
from django.db.models.signals import m2m_changed
|
|
17
|
-
from django.urls import reverse
|
|
18
17
|
from django.dispatch import receiver
|
|
19
18
|
from django.conf import settings
|
|
20
19
|
from django.contrib.postgres.fields import ArrayField
|
|
@@ -83,6 +82,80 @@ class ZoneManager(models.Manager.from_queryset(RestrictedQuerySet)):
|
|
|
83
82
|
|
|
84
83
|
|
|
85
84
|
class Zone(ObjectModificationMixin, ContactsMixin, NetBoxModel):
|
|
85
|
+
class Meta:
|
|
86
|
+
verbose_name = _("Zone")
|
|
87
|
+
verbose_name_plural = _("Zones")
|
|
88
|
+
|
|
89
|
+
ordering = (
|
|
90
|
+
"view",
|
|
91
|
+
"name",
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
constraints = [
|
|
95
|
+
UniqueConstraint(
|
|
96
|
+
Lower("name"),
|
|
97
|
+
"view",
|
|
98
|
+
name="name_view_unique_ci",
|
|
99
|
+
violation_error_message=_(
|
|
100
|
+
"There is already a zone with the same name in this view"
|
|
101
|
+
),
|
|
102
|
+
),
|
|
103
|
+
]
|
|
104
|
+
|
|
105
|
+
clone_fields = (
|
|
106
|
+
"view",
|
|
107
|
+
"name",
|
|
108
|
+
"description",
|
|
109
|
+
"status",
|
|
110
|
+
"nameservers",
|
|
111
|
+
"default_ttl",
|
|
112
|
+
"soa_ttl",
|
|
113
|
+
"soa_mname",
|
|
114
|
+
"soa_rname",
|
|
115
|
+
"soa_refresh",
|
|
116
|
+
"soa_retry",
|
|
117
|
+
"soa_expire",
|
|
118
|
+
"soa_minimum",
|
|
119
|
+
"tenant",
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
soa_clean_fields = {
|
|
123
|
+
"description",
|
|
124
|
+
"status",
|
|
125
|
+
"dnssec_policy",
|
|
126
|
+
"inline_signing",
|
|
127
|
+
"parental_agents",
|
|
128
|
+
"registrar",
|
|
129
|
+
"registry_domain_id",
|
|
130
|
+
"expiration_date",
|
|
131
|
+
"domain_status",
|
|
132
|
+
"registrant",
|
|
133
|
+
"admin_c",
|
|
134
|
+
"tech_c",
|
|
135
|
+
"billing_c",
|
|
136
|
+
"rfc2317_parent_managed",
|
|
137
|
+
"tenant",
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
objects = ZoneManager()
|
|
141
|
+
|
|
142
|
+
def __str__(self):
|
|
143
|
+
if self.name == "." and get_plugin_config("netbox_dns", "enable_root_zones"):
|
|
144
|
+
name = ". (root zone)"
|
|
145
|
+
else:
|
|
146
|
+
try:
|
|
147
|
+
name = dns_name.from_text(self.name, origin=None).to_unicode()
|
|
148
|
+
except DNSException:
|
|
149
|
+
name = self.name
|
|
150
|
+
|
|
151
|
+
try:
|
|
152
|
+
if not self.view.default_view:
|
|
153
|
+
return f"[{self.view}] {name}"
|
|
154
|
+
except ObjectDoesNotExist:
|
|
155
|
+
return f"[<no view assigned>] {name}"
|
|
156
|
+
|
|
157
|
+
return str(name)
|
|
158
|
+
|
|
86
159
|
def __init__(self, *args, **kwargs):
|
|
87
160
|
kwargs.pop("template", None)
|
|
88
161
|
|
|
@@ -295,78 +368,6 @@ class Zone(ObjectModificationMixin, ContactsMixin, NetBoxModel):
|
|
|
295
368
|
null=True,
|
|
296
369
|
)
|
|
297
370
|
|
|
298
|
-
objects = ZoneManager()
|
|
299
|
-
|
|
300
|
-
clone_fields = (
|
|
301
|
-
"view",
|
|
302
|
-
"name",
|
|
303
|
-
"description",
|
|
304
|
-
"status",
|
|
305
|
-
"nameservers",
|
|
306
|
-
"default_ttl",
|
|
307
|
-
"soa_ttl",
|
|
308
|
-
"soa_mname",
|
|
309
|
-
"soa_rname",
|
|
310
|
-
"soa_refresh",
|
|
311
|
-
"soa_retry",
|
|
312
|
-
"soa_expire",
|
|
313
|
-
"soa_minimum",
|
|
314
|
-
"tenant",
|
|
315
|
-
)
|
|
316
|
-
|
|
317
|
-
soa_clean_fields = {
|
|
318
|
-
"description",
|
|
319
|
-
"status",
|
|
320
|
-
"dnssec_policy",
|
|
321
|
-
"inline_signing",
|
|
322
|
-
"registrar",
|
|
323
|
-
"registry_domain_id",
|
|
324
|
-
"expiration_date",
|
|
325
|
-
"domain_status",
|
|
326
|
-
"registrant",
|
|
327
|
-
"admin_c",
|
|
328
|
-
"tech_c",
|
|
329
|
-
"billing_c",
|
|
330
|
-
"rfc2317_parent_managed",
|
|
331
|
-
"tenant",
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
class Meta:
|
|
335
|
-
verbose_name = _("Zone")
|
|
336
|
-
verbose_name_plural = _("Zones")
|
|
337
|
-
|
|
338
|
-
ordering = (
|
|
339
|
-
"view",
|
|
340
|
-
"name",
|
|
341
|
-
)
|
|
342
|
-
constraints = [
|
|
343
|
-
UniqueConstraint(
|
|
344
|
-
Lower("name"),
|
|
345
|
-
"view",
|
|
346
|
-
name="name_view_unique_ci",
|
|
347
|
-
violation_error_message=_(
|
|
348
|
-
"There is already a zone with the same name in this view"
|
|
349
|
-
),
|
|
350
|
-
),
|
|
351
|
-
]
|
|
352
|
-
|
|
353
|
-
def __str__(self):
|
|
354
|
-
if self.name == "." and get_plugin_config("netbox_dns", "enable_root_zones"):
|
|
355
|
-
name = ". (root zone)"
|
|
356
|
-
else:
|
|
357
|
-
try:
|
|
358
|
-
name = dns_name.from_text(self.name, origin=None).to_unicode()
|
|
359
|
-
except DNSException:
|
|
360
|
-
name = self.name
|
|
361
|
-
|
|
362
|
-
try:
|
|
363
|
-
if not self.view.default_view:
|
|
364
|
-
return f"[{self.view}] {name}"
|
|
365
|
-
except ObjectDoesNotExist:
|
|
366
|
-
return f"[<no view assigned>] {name}"
|
|
367
|
-
|
|
368
|
-
return str(name)
|
|
369
|
-
|
|
370
371
|
@property
|
|
371
372
|
def fqdn(self):
|
|
372
373
|
return f"{self.name}."
|
|
@@ -416,10 +417,6 @@ class Zone(ObjectModificationMixin, ContactsMixin, NetBoxModel):
|
|
|
416
417
|
def get_domain_status_color(self):
|
|
417
418
|
return ZoneEPPStatusChoices.colors.get(self.domain_status)
|
|
418
419
|
|
|
419
|
-
# TODO: Remove in version 1.3.0 (NetBox #18555)
|
|
420
|
-
def get_absolute_url(self):
|
|
421
|
-
return reverse("plugins:netbox_dns:zone", kwargs={"pk": self.pk})
|
|
422
|
-
|
|
423
420
|
def get_status_class(self):
|
|
424
421
|
return self.CSS_CLASSES.get(self.status)
|
|
425
422
|
|
|
@@ -1112,6 +1109,7 @@ def update_ns_records(**kwargs):
|
|
|
1112
1109
|
@register_search
|
|
1113
1110
|
class ZoneIndex(SearchIndex):
|
|
1114
1111
|
model = Zone
|
|
1112
|
+
|
|
1115
1113
|
fields = (
|
|
1116
1114
|
("name", 100),
|
|
1117
1115
|
("view", 150),
|