netbox-plugin-dns 1.1.0__py3-none-any.whl → 1.1.0b2__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 +6 -8
- netbox_dns/api/nested_serializers.py +16 -17
- netbox_dns/api/serializers.py +1 -1
- netbox_dns/api/serializers_/{registration_contact.py → contact.py} +5 -5
- netbox_dns/api/serializers_/record.py +0 -1
- netbox_dns/api/serializers_/zone.py +5 -5
- netbox_dns/api/serializers_/zone_template.py +5 -5
- netbox_dns/api/urls.py +2 -2
- netbox_dns/api/views.py +35 -9
- netbox_dns/fields/ipam.py +3 -0
- netbox_dns/filtersets/__init__.py +1 -1
- netbox_dns/filtersets/{registration_contact.py → contact.py} +4 -4
- netbox_dns/filtersets/record.py +1 -1
- 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/{registration_contact.py → contact.py} +16 -16
- netbox_dns/forms/view.py +4 -91
- netbox_dns/forms/zone.py +17 -22
- 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 +44 -24
- netbox_dns/graphql/types.py +12 -40
- netbox_dns/management/commands/{setup_dnssync.py → setup_autodns.py} +15 -19
- netbox_dns/migrations/{0008_view_prefixes.py → 0007_view_prefixes.py} +1 -1
- netbox_dns/models/__init__.py +1 -1
- netbox_dns/models/{registration_contact.py → contact.py} +9 -15
- netbox_dns/models/nameserver.py +3 -8
- netbox_dns/models/record.py +29 -60
- netbox_dns/models/record_template.py +1 -4
- netbox_dns/models/registrar.py +1 -7
- netbox_dns/models/view.py +2 -9
- netbox_dns/models/zone.py +28 -51
- netbox_dns/models/zone_template.py +9 -12
- netbox_dns/navigation.py +7 -7
- netbox_dns/signals/{ipam_dnssync.py → ipam_autodns.py} +24 -78
- netbox_dns/tables/__init__.py +1 -1
- netbox_dns/tables/{registration_contact.py → contact.py} +6 -5
- netbox_dns/tables/nameserver.py +7 -1
- netbox_dns/tables/record.py +30 -43
- netbox_dns/tables/record_template.py +17 -0
- netbox_dns/tables/registrar.py +2 -0
- netbox_dns/tables/view.py +8 -1
- netbox_dns/tables/zone.py +15 -0
- netbox_dns/tables/zone_template.py +16 -2
- netbox_dns/template_content.py +2 -14
- netbox_dns/templates/netbox_dns/{registrationcontact.html → contact.html} +1 -1
- netbox_dns/templates/netbox_dns/view.html +1 -1
- netbox_dns/urls/__init__.py +2 -2
- netbox_dns/urls/contact.py +51 -0
- netbox_dns/urls/nameserver.py +38 -14
- netbox_dns/urls/record.py +19 -7
- netbox_dns/urls/record_template.py +27 -18
- netbox_dns/urls/registrar.py +35 -11
- netbox_dns/urls/view.py +20 -12
- netbox_dns/urls/zone.py +46 -8
- netbox_dns/urls/zone_template.py +26 -16
- netbox_dns/utilities/__init__.py +1 -1
- netbox_dns/utilities/{ipam_dnssync.py → ipam_autodns.py} +41 -80
- netbox_dns/validators/dns_name.py +0 -9
- netbox_dns/views/__init__.py +1 -1
- netbox_dns/views/contact.py +95 -0
- netbox_dns/views/nameserver.py +3 -7
- netbox_dns/views/record.py +7 -12
- netbox_dns/views/record_template.py +1 -1
- netbox_dns/views/registrar.py +1 -0
- netbox_dns/views/view.py +2 -32
- netbox_dns/views/zone.py +6 -7
- netbox_dns/views/zone_template.py +2 -2
- {netbox_plugin_dns-1.1.0.dist-info → netbox_plugin_dns-1.1.0b2.dist-info}/METADATA +1 -2
- netbox_plugin_dns-1.1.0b2.dist-info/RECORD +140 -0
- netbox_dns/management/commands/rebuild_dnssync.py +0 -18
- netbox_dns/migrations/0007_alter_ordering_options.py +0 -25
- netbox_dns/migrations/0009_rename_contact_registrationcontact.py +0 -27
- netbox_dns/tables/ipam_dnssync.py +0 -11
- netbox_dns/templates/netbox_dns/view/button.html +0 -9
- netbox_dns/templates/netbox_dns/view/prefix.html +0 -41
- netbox_dns/urls/registration_contact.py +0 -60
- netbox_dns/views/registration_contact.py +0 -94
- netbox_plugin_dns-1.1.0.dist-info/RECORD +0 -146
- {netbox_plugin_dns-1.1.0.dist-info → netbox_plugin_dns-1.1.0b2.dist-info}/LICENSE +0 -0
- {netbox_plugin_dns-1.1.0.dist-info → netbox_plugin_dns-1.1.0b2.dist-info}/WHEEL +0 -0
netbox_dns/urls/zone_template.py
CHANGED
|
@@ -1,31 +1,21 @@
|
|
|
1
|
-
from django.urls import
|
|
1
|
+
from django.urls import path
|
|
2
2
|
|
|
3
|
-
from
|
|
3
|
+
from netbox.views.generic import ObjectChangeLogView, ObjectJournalView
|
|
4
4
|
|
|
5
|
+
from netbox_dns.models import ZoneTemplate
|
|
5
6
|
from netbox_dns.views import (
|
|
6
|
-
ZoneTemplateView,
|
|
7
7
|
ZoneTemplateListView,
|
|
8
|
-
|
|
8
|
+
ZoneTemplateView,
|
|
9
9
|
ZoneTemplateDeleteView,
|
|
10
|
+
ZoneTemplateEditView,
|
|
10
11
|
ZoneTemplateBulkImportView,
|
|
11
12
|
ZoneTemplateBulkEditView,
|
|
12
13
|
ZoneTemplateBulkDeleteView,
|
|
13
14
|
)
|
|
14
15
|
|
|
15
16
|
zonetemplate_urlpatterns = [
|
|
16
|
-
path("zonetemplates/<int:pk>/", ZoneTemplateView.as_view(), name="zonetemplate"),
|
|
17
17
|
path("zonetemplates/", ZoneTemplateListView.as_view(), name="zonetemplate_list"),
|
|
18
18
|
path("zonetemplates/add/", ZoneTemplateEditView.as_view(), name="zonetemplate_add"),
|
|
19
|
-
path(
|
|
20
|
-
"zonetemplates/<int:pk>/edit/",
|
|
21
|
-
ZoneTemplateEditView.as_view(),
|
|
22
|
-
name="zonetemplate_edit",
|
|
23
|
-
),
|
|
24
|
-
path(
|
|
25
|
-
"zonetemplates/<int:pk>/delete/",
|
|
26
|
-
ZoneTemplateDeleteView.as_view(),
|
|
27
|
-
name="zonetemplate_delete",
|
|
28
|
-
),
|
|
29
19
|
path(
|
|
30
20
|
"zonetemplates/import/",
|
|
31
21
|
ZoneTemplateBulkImportView.as_view(),
|
|
@@ -41,7 +31,27 @@ zonetemplate_urlpatterns = [
|
|
|
41
31
|
ZoneTemplateBulkDeleteView.as_view(),
|
|
42
32
|
name="zonetemplate_bulk_delete",
|
|
43
33
|
),
|
|
34
|
+
path("zonetemplates/<int:pk>/", ZoneTemplateView.as_view(), name="zonetemplate"),
|
|
35
|
+
path(
|
|
36
|
+
"zonetemplates/<int:pk>/delete/",
|
|
37
|
+
ZoneTemplateDeleteView.as_view(),
|
|
38
|
+
name="zonetemplate_delete",
|
|
39
|
+
),
|
|
40
|
+
path(
|
|
41
|
+
"zonetemplates/<int:pk>/edit/",
|
|
42
|
+
ZoneTemplateEditView.as_view(),
|
|
43
|
+
name="zonetemplate_edit",
|
|
44
|
+
),
|
|
45
|
+
path(
|
|
46
|
+
"zonetemplates/<int:pk>/journal/",
|
|
47
|
+
ObjectJournalView.as_view(),
|
|
48
|
+
name="zonetemplate_journal",
|
|
49
|
+
kwargs={"model": ZoneTemplate},
|
|
50
|
+
),
|
|
44
51
|
path(
|
|
45
|
-
"zonetemplates/<int:pk>/",
|
|
52
|
+
"zonetemplates/<int:pk>/changelog/",
|
|
53
|
+
ObjectChangeLogView.as_view(),
|
|
54
|
+
name="zonetemplate_changelog",
|
|
55
|
+
kwargs={"model": ZoneTemplate},
|
|
46
56
|
),
|
|
47
57
|
]
|
netbox_dns/utilities/__init__.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
from .conversions import *
|
|
2
|
-
from .
|
|
2
|
+
from .ipam_autodns import *
|
|
@@ -13,7 +13,6 @@ from ipam.models import IPAddress, Prefix
|
|
|
13
13
|
from netbox_dns.models import zone as _zone
|
|
14
14
|
from netbox_dns.models import record as _record
|
|
15
15
|
from netbox_dns.models import view as _view
|
|
16
|
-
from netbox_dns.choices import RecordStatusChoices
|
|
17
16
|
|
|
18
17
|
|
|
19
18
|
__all__ = (
|
|
@@ -44,36 +43,16 @@ def _get_assigned_views(ip_address):
|
|
|
44
43
|
|
|
45
44
|
def _get_record_status(ip_address):
|
|
46
45
|
return (
|
|
47
|
-
RecordStatusChoices.
|
|
46
|
+
RecordStatusChoices.STATE_ACTIVE
|
|
48
47
|
if ip_address.status
|
|
49
48
|
in settings.PLUGINS_CONFIG["netbox_dns"].get(
|
|
50
|
-
"
|
|
49
|
+
"autodns_ipaddress_active_status", []
|
|
51
50
|
)
|
|
52
51
|
else RecordStatusChoices.STATUS_INACTIVE
|
|
53
52
|
)
|
|
54
53
|
|
|
55
54
|
|
|
56
|
-
def
|
|
57
|
-
return zone.view in _get_assigned_views(ip_address) and dns_name.from_text(
|
|
58
|
-
ip_address.dns_name
|
|
59
|
-
).is_subdomain(dns_name.from_text(zone.name))
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
def _match_data(ip_address, record):
|
|
63
|
-
cf_disable_ptr = ip_address.custom_field_data.get(
|
|
64
|
-
"ipaddress_dns_record_disable_ptr"
|
|
65
|
-
)
|
|
66
|
-
|
|
67
|
-
return (
|
|
68
|
-
record.fqdn.rstrip(".") == ip_address.dns_name.rstrip(".")
|
|
69
|
-
and record.value == str(ip_address.address.ip)
|
|
70
|
-
and record.status == _get_record_status(ip_address)
|
|
71
|
-
and record.ttl == ip_address.custom_field_data.get("ipaddress_dns_record_ttl")
|
|
72
|
-
and (cf_disable_ptr is None or record.disable_ptr == cf_disable_ptr)
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
def get_zones(ip_address, view=None, old_zone=None):
|
|
55
|
+
def get_zones(ip_address, view=None):
|
|
77
56
|
if view is None:
|
|
78
57
|
views = _get_assigned_views(ip_address)
|
|
79
58
|
if not views:
|
|
@@ -82,13 +61,9 @@ def get_zones(ip_address, view=None, old_zone=None):
|
|
|
82
61
|
else:
|
|
83
62
|
views = [view]
|
|
84
63
|
|
|
85
|
-
min_labels = settings.PLUGINS_CONFIG["netbox_dns"].get(
|
|
86
|
-
"dnssync_minimum_zone_labels", 2
|
|
87
|
-
)
|
|
88
64
|
fqdn = dns_name.from_text(ip_address.dns_name)
|
|
89
65
|
zone_name_candidates = [
|
|
90
|
-
fqdn.split(i)[1].to_text().rstrip(".")
|
|
91
|
-
for i in range(min_labels + 1, len(fqdn.labels))
|
|
66
|
+
fqdn.split(i)[1].to_text().rstrip(".") for i in range(3, len(fqdn.labels))
|
|
92
67
|
]
|
|
93
68
|
|
|
94
69
|
zones = _zone.Zone.objects.filter(
|
|
@@ -97,13 +72,10 @@ def get_zones(ip_address, view=None, old_zone=None):
|
|
|
97
72
|
active=True,
|
|
98
73
|
)
|
|
99
74
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if old_zone is not None:
|
|
103
|
-
zones = zones.exclude(pk=old_zone.pk)
|
|
104
|
-
if _valid_entry(ip_address, old_zone):
|
|
105
|
-
zone_map[old_zone.view].append(old_zone)
|
|
75
|
+
if not zones:
|
|
76
|
+
return []
|
|
106
77
|
|
|
78
|
+
zone_map = defaultdict(list)
|
|
107
79
|
for zone in zones:
|
|
108
80
|
zone_map[zone.view].append(zone)
|
|
109
81
|
|
|
@@ -119,43 +91,35 @@ def check_dns_records(ip_address, zone=None, view=None):
|
|
|
119
91
|
|
|
120
92
|
if zone is None:
|
|
121
93
|
zones = get_zones(ip_address, view=view)
|
|
94
|
+
else:
|
|
95
|
+
zones = [zone]
|
|
122
96
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
97
|
+
if ip_address.pk is not None:
|
|
98
|
+
for record in ip_address.netbox_dns_records.filter(zone__in=zones):
|
|
99
|
+
if (
|
|
100
|
+
record.fqdn != ip_address.dns_name
|
|
101
|
+
or record.value != ip_address.address.ip
|
|
102
|
+
or record.status != _get_record_status(ip_address)
|
|
103
|
+
):
|
|
104
|
+
record.update_from_ip_address(ip_address)
|
|
130
105
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
).exclude(
|
|
134
|
-
pk__in=set(ip_address.netbox_dns_records.values_list("zone", flat=True))
|
|
135
|
-
)
|
|
106
|
+
if record is not None:
|
|
107
|
+
record.clean()
|
|
136
108
|
|
|
137
|
-
for zone in zones
|
|
138
|
-
|
|
139
|
-
ip_address,
|
|
140
|
-
zone,
|
|
109
|
+
zones = _zone.Zone.objects.filter(pk__in=[zone.pk for zone in zones]).exclude(
|
|
110
|
+
pk__in=set(
|
|
111
|
+
ip_address.netbox_dns_records.all().values_list("zone", flat=True)
|
|
141
112
|
)
|
|
113
|
+
)
|
|
142
114
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
try:
|
|
150
|
-
new_zone = get_zones(ip_address, old_zone=zone)[0]
|
|
151
|
-
except IndexError:
|
|
152
|
-
return
|
|
153
|
-
|
|
154
|
-
for record in ip_address.netbox_dns_records.filter(zone=zone):
|
|
155
|
-
record.update_from_ip_address(ip_address, new_zone)
|
|
115
|
+
for zone in zones:
|
|
116
|
+
record = _record.Record.create_from_ip_address(
|
|
117
|
+
ip_address,
|
|
118
|
+
zone,
|
|
119
|
+
)
|
|
156
120
|
|
|
157
121
|
if record is not None:
|
|
158
|
-
record.clean(
|
|
122
|
+
record.clean()
|
|
159
123
|
|
|
160
124
|
|
|
161
125
|
def update_dns_records(ip_address):
|
|
@@ -167,14 +131,15 @@ def update_dns_records(ip_address):
|
|
|
167
131
|
|
|
168
132
|
if ip_address.pk is not None:
|
|
169
133
|
for record in ip_address.netbox_dns_records.all():
|
|
170
|
-
if record.zone not in zones
|
|
171
|
-
"ipaddress_dns_disabled"
|
|
172
|
-
):
|
|
134
|
+
if record.zone not in zones:
|
|
173
135
|
record.delete()
|
|
174
136
|
continue
|
|
175
137
|
|
|
176
|
-
|
|
177
|
-
|
|
138
|
+
if (
|
|
139
|
+
record.fqdn != ip_address.dns_name
|
|
140
|
+
or record.value != ip_address.address.ip
|
|
141
|
+
or record.status != _get_record_status(ip_address)
|
|
142
|
+
):
|
|
178
143
|
record.update_from_ip_address(ip_address)
|
|
179
144
|
|
|
180
145
|
if record is not None:
|
|
@@ -228,9 +193,7 @@ def get_ip_addresses_by_prefix(prefix, check_view=True):
|
|
|
228
193
|
vrf=prefix.vrf, address__net_host_contained=prefix.prefix
|
|
229
194
|
)
|
|
230
195
|
|
|
231
|
-
for exclude_child in (
|
|
232
|
-
prefix.get_children().filter(netbox_dns_views__isnull=False).distinct()
|
|
233
|
-
):
|
|
196
|
+
for exclude_child in prefix.get_children().filter(netbox_dns_views__isnull=False):
|
|
234
197
|
queryset = queryset.exclude(
|
|
235
198
|
vrf=exclude_child.vrf,
|
|
236
199
|
address__net_host_contained=exclude_child.prefix,
|
|
@@ -271,15 +234,13 @@ def get_ip_addresses_by_zone(zone):
|
|
|
271
234
|
are the IPAddress objects in prefixes assigned to the same view, if the
|
|
272
235
|
'dns_name' attribute of the IPAddress object ends in the zone's name.
|
|
273
236
|
"""
|
|
274
|
-
queryset = get_ip_addresses_by_view(zone.view)
|
|
275
|
-
dns_name__regex=rf"\.{re.escape(zone.name)}\.?$"
|
|
276
|
-
)
|
|
237
|
+
queryset = get_ip_addresses_by_view(zone.view)
|
|
277
238
|
|
|
278
|
-
return queryset
|
|
239
|
+
return queryset.filter(dns_name__regex=rf"\.{re.escape(zone.name)}\.?$")
|
|
279
240
|
|
|
280
241
|
|
|
281
242
|
def check_record_permission(add=True, change=True, delete=True):
|
|
282
|
-
checks = locals()
|
|
243
|
+
checks = locals()
|
|
283
244
|
|
|
284
245
|
request = current_request.get()
|
|
285
246
|
|
|
@@ -288,8 +249,8 @@ def check_record_permission(add=True, change=True, delete=True):
|
|
|
288
249
|
|
|
289
250
|
return all(
|
|
290
251
|
(
|
|
291
|
-
request.user.has_perm(f"
|
|
292
|
-
for perm, check in
|
|
252
|
+
request.user.has_perm(f"nebox_dns.{perm}_record")
|
|
253
|
+
for perm, check in locals().items()
|
|
293
254
|
if check
|
|
294
255
|
)
|
|
295
256
|
)
|
|
@@ -7,7 +7,6 @@ from netbox.plugins.utils import get_plugin_config
|
|
|
7
7
|
|
|
8
8
|
__all__ = (
|
|
9
9
|
"validate_fqdn",
|
|
10
|
-
"validate_rname",
|
|
11
10
|
"validate_generic_name",
|
|
12
11
|
"validate_domain_name",
|
|
13
12
|
)
|
|
@@ -58,14 +57,6 @@ def validate_fqdn(name, always_tolerant=False):
|
|
|
58
57
|
raise ValidationError(f"{name} is not a valid fully qualified DNS host name")
|
|
59
58
|
|
|
60
59
|
|
|
61
|
-
def validate_rname(name, always_tolerant=False):
|
|
62
|
-
label, zone_label = _get_label(always_tolerant=always_tolerant)
|
|
63
|
-
regex = rf"^(\*|{label})(\\\.{label})*(\.{zone_label}){{2,}}\.?$"
|
|
64
|
-
|
|
65
|
-
if not re.match(regex, name, flags=re.IGNORECASE) or _has_invalid_double_dash(name):
|
|
66
|
-
raise ValidationError(f"{name} is not a valid RNAME")
|
|
67
|
-
|
|
68
|
-
|
|
69
60
|
def validate_generic_name(
|
|
70
61
|
name, tolerate_leading_underscores=False, always_tolerant=False
|
|
71
62
|
):
|
netbox_dns/views/__init__.py
CHANGED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
from django.db.models import Q
|
|
2
|
+
|
|
3
|
+
from netbox.views import generic
|
|
4
|
+
|
|
5
|
+
from utilities.views import ViewTab, register_model_view
|
|
6
|
+
|
|
7
|
+
from netbox_dns.models import Contact, Zone
|
|
8
|
+
from netbox_dns.filtersets import ContactFilterSet, ZoneFilterSet
|
|
9
|
+
from netbox_dns.forms import (
|
|
10
|
+
ContactForm,
|
|
11
|
+
ContactFilterForm,
|
|
12
|
+
ContactImportForm,
|
|
13
|
+
ContactBulkEditForm,
|
|
14
|
+
)
|
|
15
|
+
from netbox_dns.tables import ContactTable, ZoneTable
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
__all__ = (
|
|
19
|
+
"ContactView",
|
|
20
|
+
"ContactEditView",
|
|
21
|
+
"ContactListView",
|
|
22
|
+
"ContactDeleteView",
|
|
23
|
+
"ContactBulkImportView",
|
|
24
|
+
"ContactBulkEditView",
|
|
25
|
+
"ContactBulkDeleteView",
|
|
26
|
+
"ContactZoneListView",
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class ContactView(generic.ObjectView):
|
|
31
|
+
queryset = Contact.objects.all()
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class ContactListView(generic.ObjectListView):
|
|
35
|
+
queryset = Contact.objects.all()
|
|
36
|
+
table = ContactTable
|
|
37
|
+
filterset = ContactFilterSet
|
|
38
|
+
filterset_form = ContactFilterForm
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class ContactEditView(generic.ObjectEditView):
|
|
42
|
+
queryset = Contact.objects.all()
|
|
43
|
+
form = ContactForm
|
|
44
|
+
default_return_url = "plugins:netbox_dns:contact_list"
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class ContactDeleteView(generic.ObjectDeleteView):
|
|
48
|
+
queryset = Contact.objects.all()
|
|
49
|
+
default_return_url = "plugins:netbox_dns:contact_list"
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class ContactBulkImportView(generic.BulkImportView):
|
|
53
|
+
queryset = Contact.objects.all()
|
|
54
|
+
model_form = ContactImportForm
|
|
55
|
+
table = ContactTable
|
|
56
|
+
default_return_url = "plugins:netbox_dns:contact_list"
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class ContactBulkEditView(generic.BulkEditView):
|
|
60
|
+
queryset = Contact.objects.all()
|
|
61
|
+
filterset = ContactFilterSet
|
|
62
|
+
table = ContactTable
|
|
63
|
+
form = ContactBulkEditForm
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class ContactBulkDeleteView(generic.BulkDeleteView):
|
|
67
|
+
queryset = Contact.objects.all()
|
|
68
|
+
table = ContactTable
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
@register_model_view(Contact, "zones")
|
|
72
|
+
class ContactZoneListView(generic.ObjectChildrenView):
|
|
73
|
+
queryset = Contact.objects.all().prefetch_related(
|
|
74
|
+
"zone_set", "admin_c_zones", "tech_c_zones", "billing_c_zones"
|
|
75
|
+
)
|
|
76
|
+
child_model = Zone
|
|
77
|
+
table = ZoneTable
|
|
78
|
+
filterset = ZoneFilterSet
|
|
79
|
+
template_name = "netbox_dns/zone/child.html"
|
|
80
|
+
hide_if_empty = True
|
|
81
|
+
|
|
82
|
+
tab = ViewTab(
|
|
83
|
+
label="Zones",
|
|
84
|
+
permission="netbox_dns.view_zone",
|
|
85
|
+
badge=lambda obj: len(obj.zones),
|
|
86
|
+
hide_if_empty=True,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
def get_children(self, request, parent):
|
|
90
|
+
return Zone.objects.filter(
|
|
91
|
+
Q(registrant=parent)
|
|
92
|
+
| Q(admin_c=parent)
|
|
93
|
+
| Q(tech_c=parent)
|
|
94
|
+
| Q(billing_c=parent)
|
|
95
|
+
)
|
netbox_dns/views/nameserver.py
CHANGED
|
@@ -2,7 +2,6 @@ from dns import name as dns_name
|
|
|
2
2
|
|
|
3
3
|
from netbox.views import generic
|
|
4
4
|
from utilities.views import ViewTab, register_model_view
|
|
5
|
-
from tenancy.views import ObjectContactsView
|
|
6
5
|
|
|
7
6
|
from netbox_dns.filtersets import NameServerFilterSet, ZoneFilterSet
|
|
8
7
|
from netbox_dns.forms import (
|
|
@@ -16,13 +15,15 @@ from netbox_dns.tables import NameServerTable, ZoneTable
|
|
|
16
15
|
|
|
17
16
|
|
|
18
17
|
__all__ = (
|
|
19
|
-
"NameServerView",
|
|
20
18
|
"NameServerListView",
|
|
19
|
+
"NameServerView",
|
|
21
20
|
"NameServerEditView",
|
|
22
21
|
"NameServerDeleteView",
|
|
23
22
|
"NameServerBulkEditView",
|
|
24
23
|
"NameServerBulkImportView",
|
|
25
24
|
"NameServerBulkDeleteView",
|
|
25
|
+
"NameServerZoneListView",
|
|
26
|
+
"NameServerSOAZoneListView",
|
|
26
27
|
)
|
|
27
28
|
|
|
28
29
|
|
|
@@ -76,11 +77,6 @@ class NameServerBulkDeleteView(generic.BulkDeleteView):
|
|
|
76
77
|
table = NameServerTable
|
|
77
78
|
|
|
78
79
|
|
|
79
|
-
@register_model_view(NameServer, "contacts")
|
|
80
|
-
class NameServerContactsView(ObjectContactsView):
|
|
81
|
-
queryset = NameServer.objects.all()
|
|
82
|
-
|
|
83
|
-
|
|
84
80
|
@register_model_view(NameServer, "zones")
|
|
85
81
|
class NameServerZoneListView(generic.ObjectChildrenView):
|
|
86
82
|
queryset = NameServer.objects.all().prefetch_related("zones")
|
netbox_dns/views/record.py
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
from dns import name as dns_name
|
|
2
2
|
|
|
3
3
|
from netbox.views import generic
|
|
4
|
-
from utilities.views import register_model_view
|
|
5
|
-
from tenancy.views import ObjectContactsView
|
|
6
4
|
|
|
7
5
|
from netbox_dns.filtersets import RecordFilterSet
|
|
8
6
|
from netbox_dns.forms import (
|
|
@@ -18,14 +16,14 @@ from netbox_dns.utilities import value_to_unicode
|
|
|
18
16
|
|
|
19
17
|
|
|
20
18
|
__all__ = (
|
|
21
|
-
"RecordView",
|
|
22
19
|
"RecordListView",
|
|
20
|
+
"ManagedRecordListView",
|
|
21
|
+
"RecordView",
|
|
23
22
|
"RecordEditView",
|
|
24
23
|
"RecordDeleteView",
|
|
25
24
|
"RecordBulkImportView",
|
|
26
25
|
"RecordBulkEditView",
|
|
27
26
|
"RecordBulkDeleteView",
|
|
28
|
-
"ManagedRecordListView",
|
|
29
27
|
)
|
|
30
28
|
|
|
31
29
|
|
|
@@ -39,7 +37,9 @@ class RecordListView(generic.ObjectListView):
|
|
|
39
37
|
|
|
40
38
|
|
|
41
39
|
class ManagedRecordListView(generic.ObjectListView):
|
|
42
|
-
queryset = Record.objects.prefetch_related(
|
|
40
|
+
queryset = Record.objects.filter(managed=True).prefetch_related(
|
|
41
|
+
"zone", "address_record"
|
|
42
|
+
)
|
|
43
43
|
filterset = RecordFilterSet
|
|
44
44
|
filterset_form = RecordFilterForm
|
|
45
45
|
table = ManagedRecordTable
|
|
@@ -90,11 +90,11 @@ class RecordView(generic.ObjectView):
|
|
|
90
90
|
zone=parent_zone,
|
|
91
91
|
)
|
|
92
92
|
cname_records = cname_records.union(
|
|
93
|
-
|
|
93
|
+
set(
|
|
94
94
|
record
|
|
95
95
|
for record in parent_cname_records
|
|
96
96
|
if record.value_fqdn == instance.fqdn
|
|
97
|
-
|
|
97
|
+
)
|
|
98
98
|
)
|
|
99
99
|
|
|
100
100
|
if cname_records:
|
|
@@ -155,8 +155,3 @@ class RecordBulkEditView(generic.BulkEditView):
|
|
|
155
155
|
class RecordBulkDeleteView(generic.BulkDeleteView):
|
|
156
156
|
queryset = Record.objects.filter(managed=False)
|
|
157
157
|
table = RecordTable
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
@register_model_view(Record, "contacts")
|
|
161
|
-
class RecordContactsView(ObjectContactsView):
|
|
162
|
-
queryset = Record.objects.all()
|
netbox_dns/views/registrar.py
CHANGED
netbox_dns/views/view.py
CHANGED
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
from utilities.views import ViewTab, register_model_view
|
|
2
2
|
|
|
3
3
|
from netbox.views import generic
|
|
4
|
-
from tenancy.views import ObjectContactsView
|
|
5
|
-
from ipam.models import Prefix
|
|
6
4
|
|
|
7
5
|
from netbox_dns.models import View, Zone
|
|
8
6
|
from netbox_dns.filtersets import ViewFilterSet, ZoneFilterSet
|
|
9
|
-
from netbox_dns.forms import
|
|
10
|
-
ViewForm,
|
|
11
|
-
ViewFilterForm,
|
|
12
|
-
ViewImportForm,
|
|
13
|
-
ViewBulkEditForm,
|
|
14
|
-
ViewPrefixEditForm,
|
|
15
|
-
)
|
|
7
|
+
from netbox_dns.forms import ViewForm, ViewFilterForm, ViewImportForm, ViewBulkEditForm
|
|
16
8
|
from netbox_dns.tables import ViewTable, ZoneTable
|
|
17
|
-
from netbox_dns.utilities import get_views_by_prefix
|
|
18
9
|
|
|
19
10
|
|
|
20
11
|
__all__ = (
|
|
@@ -25,7 +16,7 @@ __all__ = (
|
|
|
25
16
|
"ViewBulkImportView",
|
|
26
17
|
"ViewBulkEditView",
|
|
27
18
|
"ViewBulkDeleteView",
|
|
28
|
-
"
|
|
19
|
+
"ViewZoneListView",
|
|
29
20
|
)
|
|
30
21
|
|
|
31
22
|
|
|
@@ -70,22 +61,6 @@ class ViewBulkDeleteView(generic.BulkDeleteView):
|
|
|
70
61
|
table = ViewTable
|
|
71
62
|
|
|
72
63
|
|
|
73
|
-
class ViewPrefixEditView(generic.ObjectEditView):
|
|
74
|
-
queryset = Prefix.objects.all()
|
|
75
|
-
form = ViewPrefixEditForm
|
|
76
|
-
template_name = "netbox_dns/view/prefix.html"
|
|
77
|
-
|
|
78
|
-
def get_extra_context(self, request, instance):
|
|
79
|
-
parents = instance.get_parents()
|
|
80
|
-
if parents:
|
|
81
|
-
return {
|
|
82
|
-
"inherited_views": get_views_by_prefix(parents.last()),
|
|
83
|
-
"inherited_from": parents.filter(netbox_dns_views__isnull=False).last(),
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return {}
|
|
87
|
-
|
|
88
|
-
|
|
89
64
|
@register_model_view(View, "zones")
|
|
90
65
|
class ViewZoneListView(generic.ObjectChildrenView):
|
|
91
66
|
queryset = View.objects.all().prefetch_related("zone_set")
|
|
@@ -104,8 +79,3 @@ class ViewZoneListView(generic.ObjectChildrenView):
|
|
|
104
79
|
|
|
105
80
|
def get_children(self, request, parent):
|
|
106
81
|
return parent.zone_set
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
@register_model_view(View, "contacts")
|
|
110
|
-
class ViewContactsView(ObjectContactsView):
|
|
111
|
-
queryset = View.objects.all()
|
netbox_dns/views/zone.py
CHANGED
|
@@ -2,7 +2,6 @@ from dns import name as dns_name
|
|
|
2
2
|
|
|
3
3
|
from netbox.views import generic
|
|
4
4
|
from utilities.views import ViewTab, register_model_view
|
|
5
|
-
from tenancy.views import ObjectContactsView
|
|
6
5
|
|
|
7
6
|
from netbox_dns.filtersets import ZoneFilterSet, RecordFilterSet
|
|
8
7
|
from netbox_dns.forms import (
|
|
@@ -20,13 +19,18 @@ from netbox_dns.tables import (
|
|
|
20
19
|
|
|
21
20
|
|
|
22
21
|
__all__ = (
|
|
23
|
-
"ZoneView",
|
|
24
22
|
"ZoneListView",
|
|
23
|
+
"ZoneView",
|
|
25
24
|
"ZoneEditView",
|
|
26
25
|
"ZoneDeleteView",
|
|
27
26
|
"ZoneBulkImportView",
|
|
28
27
|
"ZoneBulkEditView",
|
|
29
28
|
"ZoneBulkDeleteView",
|
|
29
|
+
"ZoneRegistrationView",
|
|
30
|
+
"ZoneRecordListView",
|
|
31
|
+
"ZoneManagedRecordListView",
|
|
32
|
+
"ZoneRFC2317ChildZoneListView",
|
|
33
|
+
"ZoneChildZoneListView",
|
|
30
34
|
)
|
|
31
35
|
|
|
32
36
|
|
|
@@ -197,8 +201,3 @@ class ZoneChildZoneListView(generic.ObjectChildrenView):
|
|
|
197
201
|
|
|
198
202
|
def get_children(self, request, parent):
|
|
199
203
|
return parent.child_zones
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
@register_model_view(Zone, "contacts")
|
|
203
|
-
class ZoneContactsView(ObjectContactsView):
|
|
204
|
-
queryset = Zone.objects.all()
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
from netbox.views import generic
|
|
2
2
|
|
|
3
|
-
from netbox_dns.models import ZoneTemplate
|
|
4
3
|
from netbox_dns.filtersets import ZoneTemplateFilterSet
|
|
5
4
|
from netbox_dns.forms import (
|
|
6
5
|
ZoneTemplateImportForm,
|
|
@@ -8,12 +7,13 @@ from netbox_dns.forms import (
|
|
|
8
7
|
ZoneTemplateFilterForm,
|
|
9
8
|
ZoneTemplateBulkEditForm,
|
|
10
9
|
)
|
|
10
|
+
from netbox_dns.models import ZoneTemplate
|
|
11
11
|
from netbox_dns.tables import ZoneTemplateTable, RecordTemplateDisplayTable
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
__all__ = (
|
|
15
|
-
"ZoneTemplateView",
|
|
16
15
|
"ZoneTemplateListView",
|
|
16
|
+
"ZoneTemplateView",
|
|
17
17
|
"ZoneTemplateEditView",
|
|
18
18
|
"ZoneTemplateDeleteView",
|
|
19
19
|
"ZoneTemplateBulkImportView",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: netbox-plugin-dns
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.0b2
|
|
4
4
|
Summary: NetBox DNS is a NetBox plugin for managing DNS data.
|
|
5
5
|
Home-page: https://github.com/peteeckel/netbox-plugin-dns
|
|
6
6
|
License: MIT
|
|
@@ -48,7 +48,6 @@ The main focus of the plugin is to ensure the quality of the data stored in it.
|
|
|
48
48
|
* Validation of record types such as CNAME and singletons, to ensure DNS zone validity
|
|
49
49
|
* Support for [RFC 2317](https://datatracker.ietf.org/doc/html/rfc2317) delegation of PTR zones for IPv4 subnets longer than 24 bits
|
|
50
50
|
* Templating for zones and records enables faster creations of zones with given boilerplate object relations, such as name servers, tags, tenants or registration information, or records like standard SPF or MX records that are the same for a subset of zones
|
|
51
|
-
* IPAM DNSsync can be used to automatically create address and pointer records for IP addresses by assigning prefixes to DNS views. When an IP address has a DNS name assigned and there are zones with matching names in the DNS views linked to the IP address' prefix, a matching DNS record will be created in these zones
|
|
52
51
|
|
|
53
52
|
Other main features include:
|
|
54
53
|
|