netbox-plugin-dns 1.0.6__py3-none-any.whl → 1.1.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 +23 -4
- netbox_dns/api/nested_serializers.py +17 -16
- netbox_dns/api/serializers.py +2 -1
- netbox_dns/api/serializers_/prefix.py +18 -0
- netbox_dns/api/serializers_/record.py +1 -0
- netbox_dns/api/serializers_/{contact.py → registration_contact.py} +5 -5
- netbox_dns/api/serializers_/view.py +34 -2
- netbox_dns/api/serializers_/zone.py +5 -5
- netbox_dns/api/serializers_/zone_template.py +5 -5
- netbox_dns/api/urls.py +5 -2
- netbox_dns/api/views.py +17 -35
- netbox_dns/fields/__init__.py +1 -0
- netbox_dns/fields/ipam.py +15 -0
- netbox_dns/filtersets/__init__.py +1 -1
- netbox_dns/filtersets/record.py +1 -1
- netbox_dns/filtersets/{contact.py → registration_contact.py} +4 -4
- netbox_dns/filtersets/view.py +16 -0
- netbox_dns/filtersets/zone.py +15 -15
- netbox_dns/filtersets/zone_template.py +15 -15
- netbox_dns/forms/__init__.py +1 -1
- netbox_dns/forms/{contact.py → registration_contact.py} +16 -16
- netbox_dns/forms/view.py +204 -4
- netbox_dns/forms/zone.py +15 -18
- netbox_dns/forms/zone_template.py +13 -13
- netbox_dns/graphql/__init__.py +2 -2
- netbox_dns/graphql/filters.py +5 -5
- netbox_dns/graphql/schema.py +24 -44
- netbox_dns/graphql/types.py +41 -12
- netbox_dns/management/commands/rebuild_dnssync.py +18 -0
- netbox_dns/management/commands/setup_dnssync.py +140 -0
- netbox_dns/migrations/0007_alter_ordering_options.py +25 -0
- netbox_dns/migrations/0008_view_prefixes.py +18 -0
- netbox_dns/migrations/0009_rename_contact_registrationcontact.py +27 -0
- netbox_dns/models/__init__.py +1 -3
- netbox_dns/models/nameserver.py +8 -3
- netbox_dns/models/record.py +154 -24
- netbox_dns/models/record_template.py +4 -1
- netbox_dns/models/registrar.py +7 -1
- netbox_dns/models/{contact.py → registration_contact.py} +15 -9
- netbox_dns/models/view.py +14 -2
- netbox_dns/models/zone.py +76 -35
- netbox_dns/models/zone_template.py +12 -9
- netbox_dns/navigation.py +7 -7
- netbox_dns/signals/ipam_dnssync.py +224 -0
- netbox_dns/tables/__init__.py +1 -1
- netbox_dns/tables/ipam_dnssync.py +11 -0
- netbox_dns/tables/nameserver.py +1 -7
- netbox_dns/tables/record.py +43 -30
- netbox_dns/tables/record_template.py +0 -17
- netbox_dns/tables/registrar.py +0 -2
- netbox_dns/tables/{contact.py → registration_contact.py} +5 -6
- netbox_dns/tables/view.py +19 -4
- netbox_dns/tables/zone.py +0 -15
- netbox_dns/tables/zone_template.py +2 -16
- netbox_dns/template_content.py +41 -40
- netbox_dns/templates/netbox_dns/record.html +6 -6
- netbox_dns/templates/netbox_dns/{contact.html → registrationcontact.html} +1 -1
- netbox_dns/templates/netbox_dns/view/button.html +9 -0
- netbox_dns/templates/netbox_dns/view/prefix.html +41 -0
- netbox_dns/templates/netbox_dns/view/related.html +17 -0
- netbox_dns/templates/netbox_dns/view.html +25 -0
- netbox_dns/urls/__init__.py +2 -2
- netbox_dns/urls/nameserver.py +14 -38
- netbox_dns/urls/record.py +7 -19
- netbox_dns/urls/record_template.py +18 -27
- netbox_dns/urls/registrar.py +11 -35
- netbox_dns/urls/registration_contact.py +60 -0
- netbox_dns/urls/view.py +12 -20
- netbox_dns/urls/zone.py +8 -46
- netbox_dns/urls/zone_template.py +16 -26
- netbox_dns/utilities/__init__.py +2 -74
- netbox_dns/utilities/conversions.py +83 -0
- netbox_dns/utilities/ipam_dnssync.py +295 -0
- netbox_dns/validators/dns_name.py +9 -0
- netbox_dns/views/__init__.py +1 -1
- netbox_dns/views/nameserver.py +7 -3
- netbox_dns/views/record.py +12 -7
- netbox_dns/views/record_template.py +1 -1
- netbox_dns/views/registrar.py +0 -1
- netbox_dns/views/registration_contact.py +94 -0
- netbox_dns/views/view.py +32 -2
- netbox_dns/views/zone.py +7 -6
- netbox_dns/views/zone_template.py +2 -2
- {netbox_plugin_dns-1.0.6.dist-info → netbox_plugin_dns-1.1.0.dist-info}/METADATA +2 -1
- netbox_plugin_dns-1.1.0.dist-info/RECORD +146 -0
- netbox_dns/management/commands/setup_coupling.py +0 -109
- netbox_dns/signals/ipam_coupling.py +0 -168
- netbox_dns/templates/netbox_dns/related_dns_objects.html +0 -21
- netbox_dns/urls/contact.py +0 -51
- netbox_dns/utilities/ipam_coupling.py +0 -112
- netbox_dns/views/contact.py +0 -95
- netbox_plugin_dns-1.0.6.dist-info/RECORD +0 -136
- {netbox_plugin_dns-1.0.6.dist-info → netbox_plugin_dns-1.1.0.dist-info}/LICENSE +0 -0
- {netbox_plugin_dns-1.0.6.dist-info → netbox_plugin_dns-1.1.0.dist-info}/WHEEL +0 -0
netbox_dns/forms/__init__.py
CHANGED
|
@@ -9,18 +9,18 @@ from netbox.forms import (
|
|
|
9
9
|
from utilities.forms.fields import TagFilterField
|
|
10
10
|
from utilities.forms.rendering import FieldSet
|
|
11
11
|
|
|
12
|
-
from netbox_dns.models import
|
|
12
|
+
from netbox_dns.models import RegistrationContact
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
__all__ = (
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
16
|
+
"RegistrationContactForm",
|
|
17
|
+
"RegistrationContactFilterForm",
|
|
18
|
+
"RegistrationContactImportForm",
|
|
19
|
+
"RegistrationContactBulkEditForm",
|
|
20
20
|
)
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
class
|
|
23
|
+
class RegistrationContactForm(NetBoxModelForm):
|
|
24
24
|
fieldsets = (
|
|
25
25
|
FieldSet(
|
|
26
26
|
"name",
|
|
@@ -37,13 +37,13 @@ class ContactForm(NetBoxModelForm):
|
|
|
37
37
|
"fax",
|
|
38
38
|
"fax_ext",
|
|
39
39
|
"email",
|
|
40
|
-
name="
|
|
40
|
+
name="RegistrationContact",
|
|
41
41
|
),
|
|
42
42
|
FieldSet("tags", name="Tags"),
|
|
43
43
|
)
|
|
44
44
|
|
|
45
45
|
class Meta:
|
|
46
|
-
model =
|
|
46
|
+
model = RegistrationContact
|
|
47
47
|
fields = (
|
|
48
48
|
"name",
|
|
49
49
|
"description",
|
|
@@ -63,8 +63,8 @@ class ContactForm(NetBoxModelForm):
|
|
|
63
63
|
)
|
|
64
64
|
|
|
65
65
|
|
|
66
|
-
class
|
|
67
|
-
model =
|
|
66
|
+
class RegistrationContactFilterForm(NetBoxModelFilterSetForm):
|
|
67
|
+
model = RegistrationContact
|
|
68
68
|
|
|
69
69
|
fieldsets = (
|
|
70
70
|
FieldSet("q", "filter_id", "tag"),
|
|
@@ -89,7 +89,7 @@ class ContactFilterForm(NetBoxModelFilterSetForm):
|
|
|
89
89
|
)
|
|
90
90
|
contact_id = forms.CharField(
|
|
91
91
|
required=False,
|
|
92
|
-
label="
|
|
92
|
+
label="RegistrationContact ID",
|
|
93
93
|
)
|
|
94
94
|
organization = forms.CharField(
|
|
95
95
|
required=False,
|
|
@@ -128,12 +128,12 @@ class ContactFilterForm(NetBoxModelFilterSetForm):
|
|
|
128
128
|
email = forms.CharField(
|
|
129
129
|
required=False,
|
|
130
130
|
)
|
|
131
|
-
tag = TagFilterField(
|
|
131
|
+
tag = TagFilterField(RegistrationContact)
|
|
132
132
|
|
|
133
133
|
|
|
134
|
-
class
|
|
134
|
+
class RegistrationContactImportForm(NetBoxModelImportForm):
|
|
135
135
|
class Meta:
|
|
136
|
-
model =
|
|
136
|
+
model = RegistrationContact
|
|
137
137
|
fields = (
|
|
138
138
|
"name",
|
|
139
139
|
"description",
|
|
@@ -153,8 +153,8 @@ class ContactImportForm(NetBoxModelImportForm):
|
|
|
153
153
|
)
|
|
154
154
|
|
|
155
155
|
|
|
156
|
-
class
|
|
157
|
-
model =
|
|
156
|
+
class RegistrationContactBulkEditForm(NetBoxModelBulkEditForm):
|
|
157
|
+
model = RegistrationContact
|
|
158
158
|
|
|
159
159
|
name = forms.CharField(
|
|
160
160
|
required=False,
|
netbox_dns/forms/view.py
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
from django import forms
|
|
2
|
+
from django.conf import settings
|
|
3
|
+
from django.core.exceptions import ValidationError
|
|
4
|
+
from django.db.models import Q, Count
|
|
2
5
|
|
|
3
6
|
from netbox.forms import (
|
|
4
7
|
NetBoxModelBulkEditForm,
|
|
@@ -9,14 +12,24 @@ from netbox.forms import (
|
|
|
9
12
|
from utilities.forms.fields import (
|
|
10
13
|
TagFilterField,
|
|
11
14
|
CSVModelChoiceField,
|
|
15
|
+
CSVModelMultipleChoiceField,
|
|
12
16
|
DynamicModelChoiceField,
|
|
17
|
+
DynamicModelMultipleChoiceField,
|
|
13
18
|
)
|
|
14
19
|
from utilities.forms import BOOLEAN_WITH_BLANK_CHOICES
|
|
15
20
|
from utilities.forms.rendering import FieldSet
|
|
16
21
|
from tenancy.models import Tenant
|
|
17
22
|
from tenancy.forms import TenancyForm, TenancyFilterForm
|
|
23
|
+
from ipam.models import Prefix
|
|
24
|
+
from netbox.context import current_request
|
|
18
25
|
|
|
19
26
|
from netbox_dns.models import View
|
|
27
|
+
from netbox_dns.fields import PrefixDynamicModelMultipleChoiceField
|
|
28
|
+
from netbox_dns.utilities import (
|
|
29
|
+
check_dns_records,
|
|
30
|
+
get_ip_addresses_by_prefix,
|
|
31
|
+
get_views_by_prefix,
|
|
32
|
+
)
|
|
20
33
|
|
|
21
34
|
|
|
22
35
|
__all__ = (
|
|
@@ -24,25 +37,121 @@ __all__ = (
|
|
|
24
37
|
"ViewFilterForm",
|
|
25
38
|
"ViewImportForm",
|
|
26
39
|
"ViewBulkEditForm",
|
|
40
|
+
"ViewPrefixEditForm",
|
|
27
41
|
)
|
|
28
42
|
|
|
29
43
|
|
|
30
|
-
class
|
|
44
|
+
class ViewPrefixUpdateMixin:
|
|
45
|
+
def clean(self, *args, **kwargs):
|
|
46
|
+
super().clean(*args, **kwargs)
|
|
47
|
+
|
|
48
|
+
if self.instance.pk is None or "prefixes" not in self.changed_data:
|
|
49
|
+
return
|
|
50
|
+
|
|
51
|
+
prefixes = self.cleaned_data.get("prefixes")
|
|
52
|
+
old_prefixes = View.objects.get(pk=self.instance.pk).prefixes.all()
|
|
53
|
+
|
|
54
|
+
for prefix in prefixes.difference(old_prefixes):
|
|
55
|
+
for ip_address in get_ip_addresses_by_prefix(prefix, check_view=False):
|
|
56
|
+
try:
|
|
57
|
+
check_dns_records(ip_address, view=self.instance)
|
|
58
|
+
except ValidationError as exc:
|
|
59
|
+
self.add_error("prefixes", exc.messages)
|
|
60
|
+
|
|
61
|
+
# +
|
|
62
|
+
# Determine the prefixes that, when removed from the view, have no direct view
|
|
63
|
+
# assignment left. These prefixes will potentially inherit from a different view,
|
|
64
|
+
# which means that they have to be validated against different zones.
|
|
65
|
+
# -
|
|
66
|
+
check_prefixes = set(
|
|
67
|
+
old_prefixes.annotate(view_count=Count("netbox_dns_views")).filter(
|
|
68
|
+
Q(view_count=1, netbox_dns_views=self.instance)
|
|
69
|
+
| Q(netbox_dns_views__isnull=True)
|
|
70
|
+
)
|
|
71
|
+
) - set(prefixes)
|
|
72
|
+
|
|
73
|
+
for check_prefix in check_prefixes:
|
|
74
|
+
# +
|
|
75
|
+
# Check whether the prefix will get a new view by inheritance from its
|
|
76
|
+
# parent. If that's the case, the IP addresses need to be checked.
|
|
77
|
+
# -
|
|
78
|
+
if (parent := check_prefix.get_parents().last()) is None:
|
|
79
|
+
continue
|
|
80
|
+
|
|
81
|
+
for view in get_views_by_prefix(parent):
|
|
82
|
+
if view == self.instance:
|
|
83
|
+
continue
|
|
84
|
+
|
|
85
|
+
for ip_address in get_ip_addresses_by_prefix(
|
|
86
|
+
check_prefix, check_view=False
|
|
87
|
+
):
|
|
88
|
+
try:
|
|
89
|
+
check_dns_records(ip_address, view=view)
|
|
90
|
+
except ValidationError as exc:
|
|
91
|
+
self.add_error("prefixes", exc.messages)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
class ViewForm(ViewPrefixUpdateMixin, TenancyForm, NetBoxModelForm):
|
|
95
|
+
def __init__(self, *args, **kwargs):
|
|
96
|
+
super().__init__(*args, **kwargs)
|
|
97
|
+
|
|
98
|
+
if settings.PLUGINS_CONFIG["netbox_dns"].get("dnssync_disabled"):
|
|
99
|
+
del self.fields["prefixes"]
|
|
100
|
+
|
|
101
|
+
if request := current_request.get():
|
|
102
|
+
if not request.user.has_perm("ipam.view_prefix"):
|
|
103
|
+
self._saved_prefixes = self.initial["prefixes"]
|
|
104
|
+
self.initial["prefixes"] = []
|
|
105
|
+
self.fields["prefixes"].disabled = True
|
|
106
|
+
self.fields["prefixes"].widget.attrs[
|
|
107
|
+
"placeholder"
|
|
108
|
+
] = "You do not have permission to modify assigned prefixes"
|
|
109
|
+
|
|
110
|
+
def clean_prefixes(self):
|
|
111
|
+
if hasattr(self, "_saved_prefixes"):
|
|
112
|
+
return self._saved_prefixes
|
|
113
|
+
|
|
114
|
+
return self.cleaned_data["prefixes"]
|
|
115
|
+
|
|
116
|
+
prefixes = PrefixDynamicModelMultipleChoiceField(
|
|
117
|
+
queryset=Prefix.objects.all(),
|
|
118
|
+
required=False,
|
|
119
|
+
label="IPAM Prefixes",
|
|
120
|
+
context={
|
|
121
|
+
"depth": None,
|
|
122
|
+
},
|
|
123
|
+
)
|
|
124
|
+
|
|
31
125
|
fieldsets = (
|
|
32
126
|
FieldSet("name", "default_view", "description", "tags", name="View"),
|
|
127
|
+
FieldSet("prefixes"),
|
|
33
128
|
FieldSet("tenant_group", "tenant", name="Tenancy"),
|
|
34
129
|
)
|
|
35
130
|
|
|
36
131
|
class Meta:
|
|
37
132
|
model = View
|
|
38
|
-
fields = (
|
|
133
|
+
fields = (
|
|
134
|
+
"name",
|
|
135
|
+
"default_view",
|
|
136
|
+
"description",
|
|
137
|
+
"tags",
|
|
138
|
+
"tenant",
|
|
139
|
+
"prefixes",
|
|
140
|
+
)
|
|
39
141
|
|
|
40
142
|
|
|
41
143
|
class ViewFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
|
|
144
|
+
def __init__(self, *args, **kwargs):
|
|
145
|
+
super().__init__(*args, **kwargs)
|
|
146
|
+
|
|
147
|
+
if settings.PLUGINS_CONFIG["netbox_dns"].get("dnssync_disabled"):
|
|
148
|
+
del self.fields["prefix_id"]
|
|
149
|
+
|
|
42
150
|
model = View
|
|
43
151
|
fieldsets = (
|
|
44
152
|
FieldSet("q", "filter_id", "tag"),
|
|
45
153
|
FieldSet("name", "default_view", "description", name="Attributes"),
|
|
154
|
+
FieldSet("prefix_id"),
|
|
46
155
|
FieldSet("tenant_group_id", "tenant_id", name="Tenancy"),
|
|
47
156
|
)
|
|
48
157
|
|
|
@@ -56,10 +165,30 @@ class ViewFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
|
|
|
56
165
|
description = forms.CharField(
|
|
57
166
|
required=False,
|
|
58
167
|
)
|
|
168
|
+
prefix_id = PrefixDynamicModelMultipleChoiceField(
|
|
169
|
+
queryset=Prefix.objects.all(),
|
|
170
|
+
required=False,
|
|
171
|
+
label="Prefix",
|
|
172
|
+
context={
|
|
173
|
+
"depth": None,
|
|
174
|
+
},
|
|
175
|
+
)
|
|
59
176
|
tag = TagFilterField(View)
|
|
60
177
|
|
|
61
178
|
|
|
62
|
-
class ViewImportForm(NetBoxModelImportForm):
|
|
179
|
+
class ViewImportForm(ViewPrefixUpdateMixin, NetBoxModelImportForm):
|
|
180
|
+
def __init__(self, *args, **kwargs):
|
|
181
|
+
super().__init__(*args, **kwargs)
|
|
182
|
+
|
|
183
|
+
if settings.PLUGINS_CONFIG["netbox_dns"].get("dnssync_disabled"):
|
|
184
|
+
del self.fields["prefixes"]
|
|
185
|
+
|
|
186
|
+
prefixes = CSVModelMultipleChoiceField(
|
|
187
|
+
queryset=Prefix.objects.all(),
|
|
188
|
+
to_field_name="id",
|
|
189
|
+
required=False,
|
|
190
|
+
help_text="Prefix IDs assigned to the view",
|
|
191
|
+
)
|
|
63
192
|
tenant = CSVModelChoiceField(
|
|
64
193
|
queryset=Tenant.objects.all(),
|
|
65
194
|
to_field_name="name",
|
|
@@ -69,7 +198,7 @@ class ViewImportForm(NetBoxModelImportForm):
|
|
|
69
198
|
|
|
70
199
|
class Meta:
|
|
71
200
|
model = View
|
|
72
|
-
fields = ("name", "description", "tenant", "tags")
|
|
201
|
+
fields = ("name", "description", "prefixes", "tenant", "tags")
|
|
73
202
|
|
|
74
203
|
|
|
75
204
|
class ViewBulkEditForm(NetBoxModelBulkEditForm):
|
|
@@ -88,3 +217,74 @@ class ViewBulkEditForm(NetBoxModelBulkEditForm):
|
|
|
88
217
|
)
|
|
89
218
|
|
|
90
219
|
nullable_fields = ("description", "tenant")
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
class ViewPrefixEditForm(forms.ModelForm):
|
|
223
|
+
views = DynamicModelMultipleChoiceField(
|
|
224
|
+
queryset=View.objects.all(),
|
|
225
|
+
required=False,
|
|
226
|
+
label="Assigned DNS Views",
|
|
227
|
+
help_text="Explicitly assigning DNS views overrides all inherited views for this prefix",
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
class Meta:
|
|
231
|
+
model = Prefix
|
|
232
|
+
fields = ("views",)
|
|
233
|
+
|
|
234
|
+
def __init__(self, *args, **kwargs):
|
|
235
|
+
super().__init__(*args, **kwargs)
|
|
236
|
+
|
|
237
|
+
self.initial["views"] = self.instance.netbox_dns_views.all()
|
|
238
|
+
self._permission_denied = False
|
|
239
|
+
|
|
240
|
+
if request := current_request.get():
|
|
241
|
+
if not request.user.has_perm("netbox_dns.change_view"):
|
|
242
|
+
self._permission_denied = True
|
|
243
|
+
self.initial["views"] = []
|
|
244
|
+
self.fields["views"].disabled = True
|
|
245
|
+
self.fields["views"].widget.attrs[
|
|
246
|
+
"placeholder"
|
|
247
|
+
] = "You do not have permission to modify assigned views"
|
|
248
|
+
|
|
249
|
+
def clean(self, *args, **kwargs):
|
|
250
|
+
if self._permission_denied:
|
|
251
|
+
return
|
|
252
|
+
|
|
253
|
+
prefix = self.instance
|
|
254
|
+
|
|
255
|
+
super().clean(*args, **kwargs)
|
|
256
|
+
|
|
257
|
+
views = self.cleaned_data.get("views")
|
|
258
|
+
old_views = prefix.netbox_dns_views.all()
|
|
259
|
+
|
|
260
|
+
check_views = View.objects.none()
|
|
261
|
+
|
|
262
|
+
if not views.exists():
|
|
263
|
+
if (parent := prefix.get_parents().last()) is not None:
|
|
264
|
+
check_views = parent.netbox_dns_views.all().difference(old_views)
|
|
265
|
+
|
|
266
|
+
else:
|
|
267
|
+
check_views = views.difference(old_views)
|
|
268
|
+
|
|
269
|
+
for view in check_views:
|
|
270
|
+
try:
|
|
271
|
+
for ip_address in get_ip_addresses_by_prefix(prefix, check_view=False):
|
|
272
|
+
check_dns_records(ip_address, view=view)
|
|
273
|
+
except ValidationError as exc:
|
|
274
|
+
self.add_error("views", exc.messages)
|
|
275
|
+
|
|
276
|
+
def save(self, *args, **kwargs):
|
|
277
|
+
prefix = self.instance
|
|
278
|
+
|
|
279
|
+
if self._permission_denied:
|
|
280
|
+
return prefix
|
|
281
|
+
|
|
282
|
+
old_views = prefix.netbox_dns_views.all()
|
|
283
|
+
views = self.cleaned_data.get("views")
|
|
284
|
+
|
|
285
|
+
for view in views.difference(old_views):
|
|
286
|
+
view.prefixes.add(prefix)
|
|
287
|
+
for view in old_views.difference(views):
|
|
288
|
+
view.prefixes.remove(prefix)
|
|
289
|
+
|
|
290
|
+
return prefix
|
netbox_dns/forms/zone.py
CHANGED
|
@@ -30,7 +30,7 @@ from netbox_dns.models import (
|
|
|
30
30
|
Zone,
|
|
31
31
|
NameServer,
|
|
32
32
|
Registrar,
|
|
33
|
-
|
|
33
|
+
RegistrationContact,
|
|
34
34
|
ZoneTemplate,
|
|
35
35
|
)
|
|
36
36
|
from netbox_dns.choices import ZoneStatusChoices
|
|
@@ -81,7 +81,7 @@ class ZoneTemplateUpdateMixin:
|
|
|
81
81
|
else:
|
|
82
82
|
zone_data = self.cleaned_data.copy()
|
|
83
83
|
|
|
84
|
-
custom_fields =
|
|
84
|
+
custom_fields = {}
|
|
85
85
|
for key, value in zone_data.copy().items():
|
|
86
86
|
if key.startswith("cf_"):
|
|
87
87
|
custom_fields[key[3:]] = value
|
|
@@ -105,10 +105,7 @@ class ZoneTemplateUpdateMixin:
|
|
|
105
105
|
raise RollbackTransaction
|
|
106
106
|
|
|
107
107
|
except ValidationError as exc:
|
|
108
|
-
|
|
109
|
-
template_error = item.value()
|
|
110
|
-
else:
|
|
111
|
-
template_error = [exc]
|
|
108
|
+
self.add_error("template", exc.messages)
|
|
112
109
|
except RollbackTransaction:
|
|
113
110
|
pass
|
|
114
111
|
|
|
@@ -424,22 +421,22 @@ class ZoneFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
|
|
|
424
421
|
label="Registry Domain ID",
|
|
425
422
|
)
|
|
426
423
|
registrant_id = DynamicModelMultipleChoiceField(
|
|
427
|
-
queryset=
|
|
424
|
+
queryset=RegistrationContact.objects.all(),
|
|
428
425
|
required=False,
|
|
429
426
|
label="Registrant",
|
|
430
427
|
)
|
|
431
428
|
admin_c_id = DynamicModelMultipleChoiceField(
|
|
432
|
-
queryset=
|
|
429
|
+
queryset=RegistrationContact.objects.all(),
|
|
433
430
|
required=False,
|
|
434
431
|
label="Admin-C",
|
|
435
432
|
)
|
|
436
433
|
tech_c_id = DynamicModelMultipleChoiceField(
|
|
437
|
-
queryset=
|
|
434
|
+
queryset=RegistrationContact.objects.all(),
|
|
438
435
|
required=False,
|
|
439
436
|
label="Tech-C",
|
|
440
437
|
)
|
|
441
438
|
billing_c_id = DynamicModelMultipleChoiceField(
|
|
442
|
-
queryset=
|
|
439
|
+
queryset=RegistrationContact.objects.all(),
|
|
443
440
|
required=False,
|
|
444
441
|
label="Billing-C",
|
|
445
442
|
)
|
|
@@ -535,7 +532,7 @@ class ZoneImportForm(ZoneTemplateUpdateMixin, NetBoxModelImportForm):
|
|
|
535
532
|
help_text="Domain ID assigned by the registry",
|
|
536
533
|
)
|
|
537
534
|
registrant = CSVModelChoiceField(
|
|
538
|
-
queryset=
|
|
535
|
+
queryset=RegistrationContact.objects.all(),
|
|
539
536
|
required=False,
|
|
540
537
|
to_field_name="contact_id",
|
|
541
538
|
help_text="Owner of the domain",
|
|
@@ -544,7 +541,7 @@ class ZoneImportForm(ZoneTemplateUpdateMixin, NetBoxModelImportForm):
|
|
|
544
541
|
},
|
|
545
542
|
)
|
|
546
543
|
admin_c = CSVModelChoiceField(
|
|
547
|
-
queryset=
|
|
544
|
+
queryset=RegistrationContact.objects.all(),
|
|
548
545
|
required=False,
|
|
549
546
|
to_field_name="contact_id",
|
|
550
547
|
help_text="Administrative contact for the domain",
|
|
@@ -553,7 +550,7 @@ class ZoneImportForm(ZoneTemplateUpdateMixin, NetBoxModelImportForm):
|
|
|
553
550
|
},
|
|
554
551
|
)
|
|
555
552
|
tech_c = CSVModelChoiceField(
|
|
556
|
-
queryset=
|
|
553
|
+
queryset=RegistrationContact.objects.all(),
|
|
557
554
|
required=False,
|
|
558
555
|
to_field_name="contact_id",
|
|
559
556
|
help_text="Technical contact for the domain",
|
|
@@ -562,7 +559,7 @@ class ZoneImportForm(ZoneTemplateUpdateMixin, NetBoxModelImportForm):
|
|
|
562
559
|
},
|
|
563
560
|
)
|
|
564
561
|
billing_c = CSVModelChoiceField(
|
|
565
|
-
queryset=
|
|
562
|
+
queryset=RegistrationContact.objects.all(),
|
|
566
563
|
required=False,
|
|
567
564
|
to_field_name="contact_id",
|
|
568
565
|
help_text="Billing contact for the domain",
|
|
@@ -722,21 +719,21 @@ class ZoneBulkEditForm(NetBoxModelBulkEditForm):
|
|
|
722
719
|
label="Registry Domain ID",
|
|
723
720
|
)
|
|
724
721
|
registrant = DynamicModelChoiceField(
|
|
725
|
-
queryset=
|
|
722
|
+
queryset=RegistrationContact.objects.all(),
|
|
726
723
|
required=False,
|
|
727
724
|
)
|
|
728
725
|
admin_c = DynamicModelChoiceField(
|
|
729
|
-
queryset=
|
|
726
|
+
queryset=RegistrationContact.objects.all(),
|
|
730
727
|
required=False,
|
|
731
728
|
label="Administrative Contact",
|
|
732
729
|
)
|
|
733
730
|
tech_c = DynamicModelChoiceField(
|
|
734
|
-
queryset=
|
|
731
|
+
queryset=RegistrationContact.objects.all(),
|
|
735
732
|
required=False,
|
|
736
733
|
label="Technical Contact",
|
|
737
734
|
)
|
|
738
735
|
billing_c = DynamicModelChoiceField(
|
|
739
|
-
queryset=
|
|
736
|
+
queryset=RegistrationContact.objects.all(),
|
|
740
737
|
required=False,
|
|
741
738
|
label="Billing Contact",
|
|
742
739
|
)
|
|
@@ -22,7 +22,7 @@ from netbox_dns.models import (
|
|
|
22
22
|
RecordTemplate,
|
|
23
23
|
NameServer,
|
|
24
24
|
Registrar,
|
|
25
|
-
|
|
25
|
+
RegistrationContact,
|
|
26
26
|
)
|
|
27
27
|
|
|
28
28
|
|
|
@@ -117,22 +117,22 @@ class ZoneTemplateFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
|
|
|
117
117
|
label="Registrar",
|
|
118
118
|
)
|
|
119
119
|
registrant_id = DynamicModelMultipleChoiceField(
|
|
120
|
-
queryset=
|
|
120
|
+
queryset=RegistrationContact.objects.all(),
|
|
121
121
|
required=False,
|
|
122
122
|
label="Registrant",
|
|
123
123
|
)
|
|
124
124
|
admin_c_id = DynamicModelMultipleChoiceField(
|
|
125
|
-
queryset=
|
|
125
|
+
queryset=RegistrationContact.objects.all(),
|
|
126
126
|
required=False,
|
|
127
127
|
label="Admin-C",
|
|
128
128
|
)
|
|
129
129
|
tech_c_id = DynamicModelMultipleChoiceField(
|
|
130
|
-
queryset=
|
|
130
|
+
queryset=RegistrationContact.objects.all(),
|
|
131
131
|
required=False,
|
|
132
132
|
label="Tech-C",
|
|
133
133
|
)
|
|
134
134
|
billing_c_id = DynamicModelMultipleChoiceField(
|
|
135
|
-
queryset=
|
|
135
|
+
queryset=RegistrationContact.objects.all(),
|
|
136
136
|
required=False,
|
|
137
137
|
label="Billing-C",
|
|
138
138
|
)
|
|
@@ -162,7 +162,7 @@ class ZoneTemplateImportForm(NetBoxModelImportForm):
|
|
|
162
162
|
},
|
|
163
163
|
)
|
|
164
164
|
registrant = CSVModelChoiceField(
|
|
165
|
-
queryset=
|
|
165
|
+
queryset=RegistrationContact.objects.all(),
|
|
166
166
|
required=False,
|
|
167
167
|
to_field_name="contact_id",
|
|
168
168
|
help_text="Owner of the domain",
|
|
@@ -171,7 +171,7 @@ class ZoneTemplateImportForm(NetBoxModelImportForm):
|
|
|
171
171
|
},
|
|
172
172
|
)
|
|
173
173
|
admin_c = CSVModelChoiceField(
|
|
174
|
-
queryset=
|
|
174
|
+
queryset=RegistrationContact.objects.all(),
|
|
175
175
|
required=False,
|
|
176
176
|
to_field_name="contact_id",
|
|
177
177
|
help_text="Administrative contact for the domain",
|
|
@@ -180,7 +180,7 @@ class ZoneTemplateImportForm(NetBoxModelImportForm):
|
|
|
180
180
|
},
|
|
181
181
|
)
|
|
182
182
|
tech_c = CSVModelChoiceField(
|
|
183
|
-
queryset=
|
|
183
|
+
queryset=RegistrationContact.objects.all(),
|
|
184
184
|
required=False,
|
|
185
185
|
to_field_name="contact_id",
|
|
186
186
|
help_text="Technical contact for the domain",
|
|
@@ -189,7 +189,7 @@ class ZoneTemplateImportForm(NetBoxModelImportForm):
|
|
|
189
189
|
},
|
|
190
190
|
)
|
|
191
191
|
billing_c = CSVModelChoiceField(
|
|
192
|
-
queryset=
|
|
192
|
+
queryset=RegistrationContact.objects.all(),
|
|
193
193
|
required=False,
|
|
194
194
|
to_field_name="contact_id",
|
|
195
195
|
help_text="Billing contact for the domain",
|
|
@@ -237,21 +237,21 @@ class ZoneTemplateBulkEditForm(NetBoxModelBulkEditForm):
|
|
|
237
237
|
required=False,
|
|
238
238
|
)
|
|
239
239
|
registrant = DynamicModelChoiceField(
|
|
240
|
-
queryset=
|
|
240
|
+
queryset=RegistrationContact.objects.all(),
|
|
241
241
|
required=False,
|
|
242
242
|
)
|
|
243
243
|
admin_c = DynamicModelChoiceField(
|
|
244
|
-
queryset=
|
|
244
|
+
queryset=RegistrationContact.objects.all(),
|
|
245
245
|
required=False,
|
|
246
246
|
label="Administrative Contact",
|
|
247
247
|
)
|
|
248
248
|
tech_c = DynamicModelChoiceField(
|
|
249
|
-
queryset=
|
|
249
|
+
queryset=RegistrationContact.objects.all(),
|
|
250
250
|
required=False,
|
|
251
251
|
label="Technical Contact",
|
|
252
252
|
)
|
|
253
253
|
billing_c = DynamicModelChoiceField(
|
|
254
|
-
queryset=
|
|
254
|
+
queryset=RegistrationContact.objects.all(),
|
|
255
255
|
required=False,
|
|
256
256
|
label="Billing Contact",
|
|
257
257
|
)
|
netbox_dns/graphql/__init__.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from .schema import (
|
|
2
2
|
NetBoxDNSViewQuery,
|
|
3
3
|
NetBoxDNSNameServerQuery,
|
|
4
|
-
|
|
4
|
+
NetBoxDNSRegistrationContactQuery,
|
|
5
5
|
NetBoxDNSRegistrarQuery,
|
|
6
6
|
NetBoxDNSZoneQuery,
|
|
7
7
|
NetBoxDNSRecordQuery,
|
|
@@ -14,7 +14,7 @@ schema = [
|
|
|
14
14
|
NetBoxDNSViewQuery,
|
|
15
15
|
NetBoxDNSZoneQuery,
|
|
16
16
|
NetBoxDNSRecordQuery,
|
|
17
|
-
|
|
17
|
+
NetBoxDNSRegistrationContactQuery,
|
|
18
18
|
NetBoxDNSRegistrarQuery,
|
|
19
19
|
NetBoxDNSZoneTemplateQuery,
|
|
20
20
|
NetBoxDNSRecordTemplateQuery,
|
netbox_dns/graphql/filters.py
CHANGED
|
@@ -7,7 +7,7 @@ from netbox_dns.models import (
|
|
|
7
7
|
View,
|
|
8
8
|
Zone,
|
|
9
9
|
Record,
|
|
10
|
-
|
|
10
|
+
RegistrationContact,
|
|
11
11
|
Registrar,
|
|
12
12
|
ZoneTemplate,
|
|
13
13
|
RecordTemplate,
|
|
@@ -17,7 +17,7 @@ from netbox_dns.filtersets import (
|
|
|
17
17
|
ViewFilterSet,
|
|
18
18
|
ZoneFilterSet,
|
|
19
19
|
RecordFilterSet,
|
|
20
|
-
|
|
20
|
+
RegistrationContactFilterSet,
|
|
21
21
|
RegistrarFilterSet,
|
|
22
22
|
ZoneTemplateFilterSet,
|
|
23
23
|
RecordTemplateFilterSet,
|
|
@@ -60,9 +60,9 @@ class NetBoxDNSRecordTemplateFilter(BaseFilterMixin):
|
|
|
60
60
|
pass
|
|
61
61
|
|
|
62
62
|
|
|
63
|
-
@strawberry_django.filter(
|
|
64
|
-
@autotype_decorator(
|
|
65
|
-
class
|
|
63
|
+
@strawberry_django.filter(RegistrationContact, lookups=True)
|
|
64
|
+
@autotype_decorator(RegistrationContactFilterSet)
|
|
65
|
+
class NetBoxDNSRegistrationContactFilter(BaseFilterMixin):
|
|
66
66
|
pass
|
|
67
67
|
|
|
68
68
|
|