netbox-plugin-dns 1.0b1__py3-none-any.whl → 1.0.1__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 +3 -3
- netbox_dns/api/serializers_/view.py +6 -1
- netbox_dns/api/serializers_/zone.py +0 -11
- netbox_dns/fields/network.py +20 -21
- netbox_dns/fields/rfc2317.py +2 -2
- netbox_dns/filtersets/view.py +1 -1
- netbox_dns/filtersets/zone.py +4 -4
- netbox_dns/forms/record.py +30 -2
- netbox_dns/forms/view.py +6 -3
- netbox_dns/forms/zone.py +71 -102
- netbox_dns/graphql/types.py +1 -4
- netbox_dns/management/commands/cleanup_rrset_ttl.py +1 -1
- netbox_dns/migrations/0001_squashed_netbox_dns_0_22.py +4 -2
- netbox_dns/migrations/0003_default_view.py +15 -0
- netbox_dns/migrations/0004_create_and_assign_default_view.py +26 -0
- netbox_dns/migrations/0005_alter_zone_view_not_null.py +18 -0
- netbox_dns/models/nameserver.py +3 -1
- netbox_dns/models/record.py +86 -32
- netbox_dns/models/view.py +53 -0
- netbox_dns/models/zone.py +91 -46
- netbox_dns/signals/ipam_coupling.py +1 -2
- netbox_dns/tables/view.py +12 -2
- netbox_dns/template_content.py +1 -1
- netbox_dns/templates/netbox_dns/record.html +1 -1
- netbox_dns/templates/netbox_dns/view.html +4 -0
- netbox_dns/templates/netbox_dns/zone.html +2 -4
- netbox_dns/urls/__init__.py +17 -0
- netbox_dns/urls/contact.py +51 -0
- netbox_dns/urls/nameserver.py +69 -0
- netbox_dns/urls/record.py +41 -0
- netbox_dns/urls/registrar.py +63 -0
- netbox_dns/urls/view.py +39 -0
- netbox_dns/urls/zone.py +57 -0
- netbox_dns/validators/dns_name.py +24 -11
- netbox_dns/views/record.py +9 -24
- {netbox_plugin_dns-1.0b1.dist-info → netbox_plugin_dns-1.0.1.dist-info}/METADATA +27 -13
- {netbox_plugin_dns-1.0b1.dist-info → netbox_plugin_dns-1.0.1.dist-info}/RECORD +39 -30
- netbox_dns/urls.py +0 -297
- {netbox_plugin_dns-1.0b1.dist-info → netbox_plugin_dns-1.0.1.dist-info}/LICENSE +0 -0
- {netbox_plugin_dns-1.0b1.dist-info → netbox_plugin_dns-1.0.1.dist-info}/WHEEL +0 -0
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
<td>{{ unicode_name }}</td>
|
|
21
21
|
</tr>
|
|
22
22
|
{% endif %}
|
|
23
|
-
{% if object.view %}
|
|
24
23
|
<tr>
|
|
25
24
|
<th scope="row">View</th>
|
|
26
25
|
<td>
|
|
@@ -29,7 +28,6 @@
|
|
|
29
28
|
</a>
|
|
30
29
|
</td>
|
|
31
30
|
</tr>
|
|
32
|
-
{% endif %}
|
|
33
31
|
{% if object.description %}
|
|
34
32
|
<tr>
|
|
35
33
|
<th scope="row">Description</th>
|
|
@@ -116,11 +114,11 @@
|
|
|
116
114
|
<td>{{ object.soa_ttl }}</td>
|
|
117
115
|
</tr>
|
|
118
116
|
<tr>
|
|
119
|
-
<th scope="row">
|
|
117
|
+
<th scope="row">MName</th>
|
|
120
118
|
<td><a href="{% url 'plugins:netbox_dns:nameserver' pk=object.soa_mname.pk %}">{{ object.soa_mname }}</a></td>
|
|
121
119
|
</tr>
|
|
122
120
|
<tr>
|
|
123
|
-
<th scope="row">
|
|
121
|
+
<th scope="row">RName</th>
|
|
124
122
|
<td>{{ object.soa_rname }}</td>
|
|
125
123
|
</tr>
|
|
126
124
|
{% if object.soa_serial_auto %}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from .contact import contact_urlpatterns
|
|
2
|
+
from .nameserver import nameserver_urlpatterns
|
|
3
|
+
from .record import record_urlpatterns
|
|
4
|
+
from .registrar import registrar_urlpatterns
|
|
5
|
+
from .view import view_urlpatterns
|
|
6
|
+
from .zone import zone_urlpatterns
|
|
7
|
+
|
|
8
|
+
app_name = "netbox_dns"
|
|
9
|
+
|
|
10
|
+
urlpatterns = (
|
|
11
|
+
contact_urlpatterns
|
|
12
|
+
+ nameserver_urlpatterns
|
|
13
|
+
+ record_urlpatterns
|
|
14
|
+
+ registrar_urlpatterns
|
|
15
|
+
+ view_urlpatterns
|
|
16
|
+
+ zone_urlpatterns
|
|
17
|
+
)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
from django.urls import path
|
|
2
|
+
|
|
3
|
+
from netbox.views.generic import ObjectChangeLogView, ObjectJournalView
|
|
4
|
+
|
|
5
|
+
from netbox_dns.models import Contact
|
|
6
|
+
from netbox_dns.views import (
|
|
7
|
+
ContactListView,
|
|
8
|
+
ContactView,
|
|
9
|
+
ContactDeleteView,
|
|
10
|
+
ContactEditView,
|
|
11
|
+
ContactBulkImportView,
|
|
12
|
+
ContactBulkEditView,
|
|
13
|
+
ContactBulkDeleteView,
|
|
14
|
+
ContactZoneListView,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
contact_urlpatterns = [
|
|
18
|
+
path("contacts/", ContactListView.as_view(), name="contact_list"),
|
|
19
|
+
path("contacts/add/", ContactEditView.as_view(), name="contact_add"),
|
|
20
|
+
path("contacts/import/", ContactBulkImportView.as_view(), name="contact_import"),
|
|
21
|
+
path("contacts/edit/", ContactBulkEditView.as_view(), name="contact_bulk_edit"),
|
|
22
|
+
path(
|
|
23
|
+
"contacts/delete/",
|
|
24
|
+
ContactBulkDeleteView.as_view(),
|
|
25
|
+
name="contact_bulk_delete",
|
|
26
|
+
),
|
|
27
|
+
path("contacts/<int:pk>/", ContactView.as_view(), name="contact"),
|
|
28
|
+
path("contacts/<int:pk>/edit/", ContactEditView.as_view(), name="contact_edit"),
|
|
29
|
+
path(
|
|
30
|
+
"contacts/<int:pk>/delete/",
|
|
31
|
+
ContactDeleteView.as_view(),
|
|
32
|
+
name="contact_delete",
|
|
33
|
+
),
|
|
34
|
+
path(
|
|
35
|
+
"contacts/<int:pk>/zones/",
|
|
36
|
+
ContactZoneListView.as_view(),
|
|
37
|
+
name="contact_zones",
|
|
38
|
+
),
|
|
39
|
+
path(
|
|
40
|
+
"contacts/<int:pk>/journal/",
|
|
41
|
+
ObjectJournalView.as_view(),
|
|
42
|
+
name="contact_journal",
|
|
43
|
+
kwargs={"model": Contact},
|
|
44
|
+
),
|
|
45
|
+
path(
|
|
46
|
+
"contacts/<int:pk>/changelog/",
|
|
47
|
+
ObjectChangeLogView.as_view(),
|
|
48
|
+
name="contact_changelog",
|
|
49
|
+
kwargs={"model": Contact},
|
|
50
|
+
),
|
|
51
|
+
]
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
from django.urls import path
|
|
2
|
+
|
|
3
|
+
from netbox.views.generic import ObjectChangeLogView, ObjectJournalView
|
|
4
|
+
|
|
5
|
+
from netbox_dns.models import NameServer
|
|
6
|
+
from netbox_dns.views import (
|
|
7
|
+
NameServerListView,
|
|
8
|
+
NameServerView,
|
|
9
|
+
NameServerEditView,
|
|
10
|
+
NameServerDeleteView,
|
|
11
|
+
NameServerBulkImportView,
|
|
12
|
+
NameServerBulkEditView,
|
|
13
|
+
NameServerBulkDeleteView,
|
|
14
|
+
NameServerZoneListView,
|
|
15
|
+
NameServerSOAZoneListView,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
nameserver_urlpatterns = [
|
|
19
|
+
path("nameservers/", NameServerListView.as_view(), name="nameserver_list"),
|
|
20
|
+
path("nameservers/add/", NameServerEditView.as_view(), name="nameserver_add"),
|
|
21
|
+
path(
|
|
22
|
+
"nameservers/import/",
|
|
23
|
+
NameServerBulkImportView.as_view(),
|
|
24
|
+
name="nameserver_import",
|
|
25
|
+
),
|
|
26
|
+
path(
|
|
27
|
+
"nameservers/edit/",
|
|
28
|
+
NameServerBulkEditView.as_view(),
|
|
29
|
+
name="nameserver_bulk_edit",
|
|
30
|
+
),
|
|
31
|
+
path(
|
|
32
|
+
"nameservers/delete/",
|
|
33
|
+
NameServerBulkDeleteView.as_view(),
|
|
34
|
+
name="nameserver_bulk_delete",
|
|
35
|
+
),
|
|
36
|
+
path("nameservers/<int:pk>/", NameServerView.as_view(), name="nameserver"),
|
|
37
|
+
path(
|
|
38
|
+
"nameservers/<int:pk>/edit",
|
|
39
|
+
NameServerEditView.as_view(),
|
|
40
|
+
name="nameserver_edit",
|
|
41
|
+
),
|
|
42
|
+
path(
|
|
43
|
+
"nameservers/<int:pk>/delete",
|
|
44
|
+
NameServerDeleteView.as_view(),
|
|
45
|
+
name="nameserver_delete",
|
|
46
|
+
),
|
|
47
|
+
path(
|
|
48
|
+
"nameservers/<int:pk>/journal/",
|
|
49
|
+
ObjectJournalView.as_view(),
|
|
50
|
+
name="nameserver_journal",
|
|
51
|
+
kwargs={"model": NameServer},
|
|
52
|
+
),
|
|
53
|
+
path(
|
|
54
|
+
"nameservers/<int:pk>/changelog/",
|
|
55
|
+
ObjectChangeLogView.as_view(),
|
|
56
|
+
name="nameserver_changelog",
|
|
57
|
+
kwargs={"model": NameServer},
|
|
58
|
+
),
|
|
59
|
+
path(
|
|
60
|
+
"nameservers/<int:pk>/zones/",
|
|
61
|
+
NameServerZoneListView.as_view(),
|
|
62
|
+
name="nameserver_zones",
|
|
63
|
+
),
|
|
64
|
+
path(
|
|
65
|
+
"nameservers/<int:pk>/soazones/",
|
|
66
|
+
NameServerSOAZoneListView.as_view(),
|
|
67
|
+
name="nameserver_soa_zones",
|
|
68
|
+
),
|
|
69
|
+
]
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
from django.urls import path
|
|
2
|
+
|
|
3
|
+
from netbox.views.generic import ObjectChangeLogView, ObjectJournalView
|
|
4
|
+
|
|
5
|
+
from netbox_dns.models import Record
|
|
6
|
+
from netbox_dns.views import (
|
|
7
|
+
RecordListView,
|
|
8
|
+
RecordView,
|
|
9
|
+
RecordEditView,
|
|
10
|
+
RecordDeleteView,
|
|
11
|
+
RecordBulkImportView,
|
|
12
|
+
RecordBulkEditView,
|
|
13
|
+
RecordBulkDeleteView,
|
|
14
|
+
ManagedRecordListView,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
record_urlpatterns = [
|
|
18
|
+
path("records/", RecordListView.as_view(), name="record_list"),
|
|
19
|
+
path("records/add/", RecordEditView.as_view(), name="record_add"),
|
|
20
|
+
path("records/import/", RecordBulkImportView.as_view(), name="record_import"),
|
|
21
|
+
path("records/edit/", RecordBulkEditView.as_view(), name="record_bulk_edit"),
|
|
22
|
+
path("records/delete/", RecordBulkDeleteView.as_view(), name="record_bulk_delete"),
|
|
23
|
+
path("records/<int:pk>/", RecordView.as_view(), name="record"),
|
|
24
|
+
path("records/<int:pk>/edit/", RecordEditView.as_view(), name="record_edit"),
|
|
25
|
+
path("records/<int:pk>/delete/", RecordDeleteView.as_view(), name="record_delete"),
|
|
26
|
+
path(
|
|
27
|
+
"records/<int:pk>/journal/",
|
|
28
|
+
ObjectJournalView.as_view(),
|
|
29
|
+
name="record_journal",
|
|
30
|
+
kwargs={"model": Record},
|
|
31
|
+
),
|
|
32
|
+
path(
|
|
33
|
+
"records/<int:pk>/changelog/",
|
|
34
|
+
ObjectChangeLogView.as_view(),
|
|
35
|
+
name="record_changelog",
|
|
36
|
+
kwargs={"model": Record},
|
|
37
|
+
),
|
|
38
|
+
path(
|
|
39
|
+
"managedrecords/", ManagedRecordListView.as_view(), name="managed_record_list"
|
|
40
|
+
),
|
|
41
|
+
]
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
from django.urls import path
|
|
2
|
+
|
|
3
|
+
from netbox.views.generic import ObjectChangeLogView, ObjectJournalView
|
|
4
|
+
|
|
5
|
+
from netbox_dns.models import Registrar
|
|
6
|
+
from netbox_dns.views import (
|
|
7
|
+
RegistrarListView,
|
|
8
|
+
RegistrarView,
|
|
9
|
+
RegistrarDeleteView,
|
|
10
|
+
RegistrarEditView,
|
|
11
|
+
RegistrarBulkImportView,
|
|
12
|
+
RegistrarBulkEditView,
|
|
13
|
+
RegistrarBulkDeleteView,
|
|
14
|
+
RegistrarZoneListView,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
registrar_urlpatterns = [
|
|
18
|
+
path("registrars/", RegistrarListView.as_view(), name="registrar_list"),
|
|
19
|
+
path("registrars/add/", RegistrarEditView.as_view(), name="registrar_add"),
|
|
20
|
+
path(
|
|
21
|
+
"registrars/import/",
|
|
22
|
+
RegistrarBulkImportView.as_view(),
|
|
23
|
+
name="registrar_import",
|
|
24
|
+
),
|
|
25
|
+
path(
|
|
26
|
+
"registrars/edit/",
|
|
27
|
+
RegistrarBulkEditView.as_view(),
|
|
28
|
+
name="registrar_bulk_edit",
|
|
29
|
+
),
|
|
30
|
+
path(
|
|
31
|
+
"registrars/delete/",
|
|
32
|
+
RegistrarBulkDeleteView.as_view(),
|
|
33
|
+
name="registrar_bulk_delete",
|
|
34
|
+
),
|
|
35
|
+
path("registrars/<int:pk>/", RegistrarView.as_view(), name="registrar"),
|
|
36
|
+
path(
|
|
37
|
+
"registrars/<int:pk>/edit/",
|
|
38
|
+
RegistrarEditView.as_view(),
|
|
39
|
+
name="registrar_edit",
|
|
40
|
+
),
|
|
41
|
+
path(
|
|
42
|
+
"registrars/<int:pk>/delete/",
|
|
43
|
+
RegistrarDeleteView.as_view(),
|
|
44
|
+
name="registrar_delete",
|
|
45
|
+
),
|
|
46
|
+
path(
|
|
47
|
+
"registrars/<int:pk>/zones/",
|
|
48
|
+
RegistrarZoneListView.as_view(),
|
|
49
|
+
name="registrar_zones",
|
|
50
|
+
),
|
|
51
|
+
path(
|
|
52
|
+
"registrars/<int:pk>/journal/",
|
|
53
|
+
ObjectJournalView.as_view(),
|
|
54
|
+
name="registrar_journal",
|
|
55
|
+
kwargs={"model": Registrar},
|
|
56
|
+
),
|
|
57
|
+
path(
|
|
58
|
+
"registrars/<int:pk>/changelog/",
|
|
59
|
+
ObjectChangeLogView.as_view(),
|
|
60
|
+
name="registrar_changelog",
|
|
61
|
+
kwargs={"model": Registrar},
|
|
62
|
+
),
|
|
63
|
+
]
|
netbox_dns/urls/view.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
from django.urls import path
|
|
2
|
+
|
|
3
|
+
from netbox.views.generic import ObjectChangeLogView, ObjectJournalView
|
|
4
|
+
|
|
5
|
+
from netbox_dns.models import View
|
|
6
|
+
from netbox_dns.views import (
|
|
7
|
+
ViewListView,
|
|
8
|
+
ViewView,
|
|
9
|
+
ViewDeleteView,
|
|
10
|
+
ViewEditView,
|
|
11
|
+
ViewBulkImportView,
|
|
12
|
+
ViewBulkEditView,
|
|
13
|
+
ViewBulkDeleteView,
|
|
14
|
+
ViewZoneListView,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
view_urlpatterns = [
|
|
18
|
+
path("views/", ViewListView.as_view(), name="view_list"),
|
|
19
|
+
path("views/add/", ViewEditView.as_view(), name="view_add"),
|
|
20
|
+
path("views/import/", ViewBulkImportView.as_view(), name="view_import"),
|
|
21
|
+
path("views/edit/", ViewBulkEditView.as_view(), name="view_bulk_edit"),
|
|
22
|
+
path("views/delete/", ViewBulkDeleteView.as_view(), name="view_bulk_delete"),
|
|
23
|
+
path("views/<int:pk>/", ViewView.as_view(), name="view"),
|
|
24
|
+
path("views/<int:pk>/edit/", ViewEditView.as_view(), name="view_edit"),
|
|
25
|
+
path("views/<int:pk>/delete/", ViewDeleteView.as_view(), name="view_delete"),
|
|
26
|
+
path("views/<int:pk>/zones/", ViewZoneListView.as_view(), name="view_zones"),
|
|
27
|
+
path(
|
|
28
|
+
"views/<int:pk>/journal/",
|
|
29
|
+
ObjectJournalView.as_view(),
|
|
30
|
+
name="view_journal",
|
|
31
|
+
kwargs={"model": View},
|
|
32
|
+
),
|
|
33
|
+
path(
|
|
34
|
+
"views/<int:pk>/changelog/",
|
|
35
|
+
ObjectChangeLogView.as_view(),
|
|
36
|
+
name="view_changelog",
|
|
37
|
+
kwargs={"model": View},
|
|
38
|
+
),
|
|
39
|
+
]
|
netbox_dns/urls/zone.py
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
from django.urls import path
|
|
2
|
+
|
|
3
|
+
from netbox.views.generic import ObjectChangeLogView, ObjectJournalView
|
|
4
|
+
|
|
5
|
+
from netbox_dns.models import Zone
|
|
6
|
+
from netbox_dns.views import (
|
|
7
|
+
ZoneListView,
|
|
8
|
+
ZoneView,
|
|
9
|
+
ZoneDeleteView,
|
|
10
|
+
ZoneEditView,
|
|
11
|
+
ZoneBulkImportView,
|
|
12
|
+
ZoneBulkEditView,
|
|
13
|
+
ZoneBulkDeleteView,
|
|
14
|
+
ZoneRecordListView,
|
|
15
|
+
ZoneManagedRecordListView,
|
|
16
|
+
ZoneRegistrationView,
|
|
17
|
+
ZoneRFC2317ChildZoneListView,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
zone_urlpatterns = [
|
|
21
|
+
path("zones/", ZoneListView.as_view(), name="zone_list"),
|
|
22
|
+
path("zones/add/", ZoneEditView.as_view(), name="zone_add"),
|
|
23
|
+
path("zones/import/", ZoneBulkImportView.as_view(), name="zone_import"),
|
|
24
|
+
path("zones/edit/", ZoneBulkEditView.as_view(), name="zone_bulk_edit"),
|
|
25
|
+
path("zones/delete/", ZoneBulkDeleteView.as_view(), name="zone_bulk_delete"),
|
|
26
|
+
path("zones/<int:pk>/", ZoneView.as_view(), name="zone"),
|
|
27
|
+
path("zones/<int:pk>/delete/", ZoneDeleteView.as_view(), name="zone_delete"),
|
|
28
|
+
path("zones/<int:pk>/edit/", ZoneEditView.as_view(), name="zone_edit"),
|
|
29
|
+
path("zones/<int:pk>/records/", ZoneRecordListView.as_view(), name="zone_records"),
|
|
30
|
+
path(
|
|
31
|
+
"zones/<int:pk>/managedrecords/",
|
|
32
|
+
ZoneManagedRecordListView.as_view(),
|
|
33
|
+
name="zone_managed_records",
|
|
34
|
+
),
|
|
35
|
+
path(
|
|
36
|
+
"zones/<int:pk>/rfc2317childzones/",
|
|
37
|
+
ZoneRFC2317ChildZoneListView.as_view(),
|
|
38
|
+
name="zone_rfc2317_child_zones",
|
|
39
|
+
),
|
|
40
|
+
path(
|
|
41
|
+
"zones/<int:pk>/registration/",
|
|
42
|
+
ZoneRegistrationView.as_view(),
|
|
43
|
+
name="zone_registration",
|
|
44
|
+
),
|
|
45
|
+
path(
|
|
46
|
+
"zones/<int:pk>/journal/",
|
|
47
|
+
ObjectJournalView.as_view(),
|
|
48
|
+
name="zone_journal",
|
|
49
|
+
kwargs={"model": Zone},
|
|
50
|
+
),
|
|
51
|
+
path(
|
|
52
|
+
"zones/<int:pk>/changelog/",
|
|
53
|
+
ObjectChangeLogView.as_view(),
|
|
54
|
+
name="zone_changelog",
|
|
55
|
+
kwargs={"model": Zone},
|
|
56
|
+
),
|
|
57
|
+
]
|
|
@@ -14,19 +14,25 @@ def has_invalid_double_dash(name):
|
|
|
14
14
|
return bool(re.findall(r"\b(?!xn)..--", name, re.IGNORECASE))
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
def validate_fqdn(name):
|
|
18
|
-
if get_plugin_config(
|
|
17
|
+
def validate_fqdn(name, always_tolerant=False):
|
|
18
|
+
if always_tolerant or get_plugin_config(
|
|
19
|
+
"netbox_dns", "tolerate_underscores_in_hostnames"
|
|
20
|
+
):
|
|
19
21
|
regex = rf"^(\*|{TOLERANT_LABEL})(\.{TOLERANT_LABEL})+\.?$"
|
|
20
22
|
else:
|
|
21
23
|
regex = rf"^(\*|{LABEL})(\.{LABEL})+\.?$"
|
|
22
24
|
|
|
23
25
|
if not re.match(regex, name, flags=re.IGNORECASE) or has_invalid_double_dash(name):
|
|
24
|
-
raise ValidationError("
|
|
26
|
+
raise ValidationError(f"{name} is not a valid fully qualified DNS host name")
|
|
25
27
|
|
|
26
28
|
|
|
27
|
-
def validate_extended_hostname(
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
def validate_extended_hostname(
|
|
30
|
+
name, tolerate_leading_underscores=False, always_tolerant=False
|
|
31
|
+
):
|
|
32
|
+
if always_tolerant or tolerate_leading_underscores:
|
|
33
|
+
if always_tolerant or get_plugin_config(
|
|
34
|
+
"netbox_dns", "tolerate_underscores_in_hostnames"
|
|
35
|
+
):
|
|
30
36
|
regex = rf"^([*@]|(\*\.)?{TOLERANT_LEADING_UNDERSCORE_LABEL}(\.{TOLERANT_LEADING_UNDERSCORE_LABEL})*\.?)$"
|
|
31
37
|
else:
|
|
32
38
|
regex = rf"^([*@]|(\*\.)?{LEADING_UNDERSCORE_LABEL}(\.{LEADING_UNDERSCORE_LABEL})*\.?)$"
|
|
@@ -36,17 +42,24 @@ def validate_extended_hostname(name, tolerate_leading_underscores=False):
|
|
|
36
42
|
regex = rf"^([*@]|(\*\.)?{LABEL}(\.{LABEL})*\.?)$"
|
|
37
43
|
|
|
38
44
|
if not re.match(regex, name, flags=re.IGNORECASE) or has_invalid_double_dash(name):
|
|
39
|
-
raise ValidationError("
|
|
45
|
+
raise ValidationError(f"{name} is not a valid DNS host name")
|
|
40
46
|
|
|
41
47
|
|
|
42
|
-
def validate_domain_name(name):
|
|
43
|
-
if name == "
|
|
48
|
+
def validate_domain_name(name, always_tolerant=False, allow_empty_label=False):
|
|
49
|
+
if name == "@" and allow_empty_label:
|
|
44
50
|
return
|
|
45
51
|
|
|
46
|
-
if
|
|
52
|
+
if name == "." and (
|
|
53
|
+
always_tolerant or get_plugin_config("netbox_dns", "enable_root_zones")
|
|
54
|
+
):
|
|
55
|
+
return
|
|
56
|
+
|
|
57
|
+
if always_tolerant or get_plugin_config(
|
|
58
|
+
"netbox_dns", "tolerate_underscores_in_hostnames"
|
|
59
|
+
):
|
|
47
60
|
regex = rf"^{TOLERANT_LABEL}(\.{TOLERANT_LABEL})*\.?$"
|
|
48
61
|
else:
|
|
49
62
|
regex = rf"^{LABEL}(\.{LABEL})*\.?$"
|
|
50
63
|
|
|
51
64
|
if not re.match(regex, name, flags=re.IGNORECASE) or has_invalid_double_dash(name):
|
|
52
|
-
raise ValidationError("
|
|
65
|
+
raise ValidationError(f"{name} is not a valid DNS domain name")
|
netbox_dns/views/record.py
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
from dns import name as dns_name
|
|
2
2
|
|
|
3
|
-
from django.db.models import Q
|
|
4
|
-
from django.db.models.functions import Length
|
|
5
|
-
|
|
6
3
|
from netbox.views import generic
|
|
7
4
|
|
|
8
5
|
from netbox_dns.filtersets import RecordFilterSet
|
|
@@ -42,21 +39,10 @@ class RecordView(generic.ObjectView):
|
|
|
42
39
|
|
|
43
40
|
def get_value_records(self, instance):
|
|
44
41
|
value_fqdn = dns_name.from_text(instance.value_fqdn)
|
|
45
|
-
value_zone_names = [
|
|
46
|
-
value_fqdn.split(length)[1].to_text().rstrip(".")
|
|
47
|
-
for length in range(2, len(value_fqdn) + 1)
|
|
48
|
-
]
|
|
49
42
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
.order_by(Length("name").desc())
|
|
53
|
-
.first()
|
|
43
|
+
cname_targets = Record.objects.filter(
|
|
44
|
+
zone__view=instance.zone.view, fqdn=value_fqdn
|
|
54
45
|
)
|
|
55
|
-
if not value_zone:
|
|
56
|
-
return None
|
|
57
|
-
|
|
58
|
-
value_name = value_fqdn.relativize(dns_name.from_text(value_zone.name))
|
|
59
|
-
cname_targets = Record.objects.filter(zone=value_zone, name=value_name)
|
|
60
46
|
|
|
61
47
|
if cname_targets:
|
|
62
48
|
return RelatedRecordTable(
|
|
@@ -66,14 +52,11 @@ class RecordView(generic.ObjectView):
|
|
|
66
52
|
return None
|
|
67
53
|
|
|
68
54
|
def get_cname_records(self, instance):
|
|
69
|
-
view_filter = (
|
|
70
|
-
Q(zone__view__isnull=True)
|
|
71
|
-
if instance.zone.view is None
|
|
72
|
-
else Q(zone__view=instance.zone.view)
|
|
73
|
-
)
|
|
74
55
|
cname_records = set(
|
|
75
56
|
Record.objects.filter(
|
|
76
|
-
|
|
57
|
+
zone__view=instance.zone.view,
|
|
58
|
+
value=instance.fqdn,
|
|
59
|
+
type=RecordTypeChoices.CNAME,
|
|
77
60
|
)
|
|
78
61
|
)
|
|
79
62
|
|
|
@@ -84,12 +67,14 @@ class RecordView(generic.ObjectView):
|
|
|
84
67
|
]
|
|
85
68
|
|
|
86
69
|
parent_zones = Zone.objects.filter(
|
|
87
|
-
instance.zone.
|
|
70
|
+
view=instance.zone.view, name__in=parent_zone_names
|
|
88
71
|
)
|
|
89
72
|
|
|
90
73
|
for parent_zone in parent_zones:
|
|
91
74
|
parent_cname_records = Record.objects.filter(
|
|
92
|
-
|
|
75
|
+
zone__view=instance.zone.view,
|
|
76
|
+
type=RecordTypeChoices.CNAME,
|
|
77
|
+
zone=parent_zone,
|
|
93
78
|
)
|
|
94
79
|
cname_records = cname_records.union(
|
|
95
80
|
set(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: netbox-plugin-dns
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.0.1
|
|
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
|
|
@@ -8,18 +8,18 @@ Keywords: netbox,netbox-plugin,dns
|
|
|
8
8
|
Author: Peter Eckel
|
|
9
9
|
Author-email: pete@netbox-dns.org
|
|
10
10
|
Requires-Python: >=3.10,<4.0
|
|
11
|
-
Classifier: Development Status ::
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
12
|
Classifier: License :: OSI Approved :: MIT License
|
|
13
13
|
Classifier: Programming Language :: Python :: 3
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.10
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.11
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
-
Requires-Dist: dnspython (>=2.
|
|
17
|
+
Requires-Dist: dnspython (>=2.6.1,<3.0.0)
|
|
18
18
|
Project-URL: Repository, https://github.com/peteeckel/netbox-plugin-dns
|
|
19
19
|
Description-Content-Type: text/markdown
|
|
20
20
|
|
|
21
21
|
# NetBox DNS
|
|
22
|
-
The NetBox DNS plugin enables NetBox to manage operational DNS data such as name servers, zones, records and views, as well as registration data for domains. It can automate tasks like creating PTR records, generating zone serial numbers, NS and SOA records, as well as validate names and values values for resource records to ensure zone data is consistent,
|
|
22
|
+
The NetBox DNS plugin enables NetBox to manage operational DNS data such as name servers, zones, records and views, as well as registration data for domains. It can automate tasks like creating PTR records, generating zone serial numbers, NS and SOA records, as well as validate names and values values for resource records to ensure zone data is consistent, up-to-date and compliant with to the relevant RFCs.
|
|
23
23
|
|
|
24
24
|
<div align="center">
|
|
25
25
|
<a href="https://pypi.org/project/netbox-plugin-dns/"><img src="https://img.shields.io/pypi/v/netbox-plugin-dns" alt="PyPi"/></a>
|
|
@@ -34,16 +34,30 @@ The NetBox DNS plugin enables NetBox to manage operational DNS data such as name
|
|
|
34
34
|
<a href="https://pepy.tech/project/netbox-plugin-dns"><img alt="Downloads/Month" src="https://static.pepy.tech/badge/netbox-plugin-dns/week"></a>
|
|
35
35
|
</div>
|
|
36
36
|
|
|
37
|
-
##
|
|
37
|
+
## Objectives
|
|
38
|
+
NetBox DNS is designed to be the 'DNS Source of Truth' analogous to NetBox being the 'Network Source of Truth'.
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
* Automatically generate SOA and NS records for zones
|
|
41
|
-
* Automatically create and update PTR records for IPv4 and IPv6 address records
|
|
42
|
-
* Organize DNS zones in views for split horizon DNS and multi-site deployments
|
|
43
|
-
* Manage domain registrar and registrant information for domains related to zones
|
|
44
|
-
* Manage RFC2317 reverse zones for IPv4 prefixes with a network mask length longer than 24 bits
|
|
40
|
+
The plugin stores information about DNS name servers, DNS views and zones, and DNS records, making it a data source for automatic provisioning of DNS instances. Registration information about DNS registrars and contacts for DNS domains can also be stored and associated with zones.
|
|
45
41
|
|
|
46
|
-
|
|
42
|
+
The main focus of the plugin is to ensure the quality of the data stored in it. To achieve this, there are many validation and automation mechanisms in place:
|
|
43
|
+
|
|
44
|
+
* Validation of record names and values
|
|
45
|
+
* Automatic maintenance of PTR records for IPv6 and IPv4 address records
|
|
46
|
+
* Automatic generation of SOA records, optionally including the serial number of the zone data
|
|
47
|
+
* Validation of record types such as CNAME and singletons, to ensure DNS zone validity
|
|
48
|
+
* Support for [RFC 2317](https://datatracker.ietf.org/doc/html/rfc2317) delegation of PTR zones for IPv4 subnets longer than 24 bits
|
|
49
|
+
|
|
50
|
+
Other main features include:
|
|
51
|
+
|
|
52
|
+
* Support for BIND views, providing lightweight namespaces for zones
|
|
53
|
+
* Support for IDN, including the validation of punycode names
|
|
54
|
+
* Full support for the NetBox REST and GraphQL APIs
|
|
55
|
+
* Support for all major NetBox features such as global search, tenancy, change logs, tagging, journaling etc.
|
|
56
|
+
|
|
57
|
+
## Non-objectives
|
|
58
|
+
In the same way as NetBox is not a network management application, NetBox DNS does not provide any functionality to manage specific name servers or DNS service providers or to generate input such as configuration and zone files for them. The focus is on the completeness and integrity of the data needed to run DNS zones, not on the peculiarities of a plethora of servers and services that actually use the data. This functionality is left to specialized integration tools, or in many cases it can be easily implemented using Ansible or similar tools based on NetBox DNS data. Example code for some simple use cases is provided.
|
|
59
|
+
|
|
60
|
+
For integration with a large number of DNS server implementations integration tools like [octodns-netbox-dns](https://pypi.org/project/octodns-netbox-dns/) are available.
|
|
47
61
|
|
|
48
62
|
## Requirements
|
|
49
63
|
|
|
@@ -85,7 +99,7 @@ Full documentation on using plugins with NetBox: [Using Plugins - NetBox Documen
|
|
|
85
99
|
|
|
86
100
|
## Contribute
|
|
87
101
|
|
|
88
|
-
Contributions are always welcome! Please see
|
|
102
|
+
Contributions are always welcome! Please see the [Contribution Guidelines](CONTRIBUTING.md)
|
|
89
103
|
|
|
90
104
|
## Documentation
|
|
91
105
|
|