netbox-plugin-dns 0.22.8__py3-none-any.whl → 1.0.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 +4 -15
- netbox_dns/api/nested_serializers.py +4 -60
- netbox_dns/api/serializers.py +8 -314
- netbox_dns/api/serializers_/__init__.py +0 -0
- netbox_dns/api/serializers_/contact.py +37 -0
- netbox_dns/api/serializers_/nameserver.py +39 -0
- netbox_dns/api/serializers_/record.py +90 -0
- netbox_dns/api/serializers_/registrar.py +31 -0
- netbox_dns/api/serializers_/view.py +34 -0
- netbox_dns/api/serializers_/zone.py +159 -0
- netbox_dns/api/views.py +13 -13
- netbox_dns/fields/network.py +21 -22
- netbox_dns/fields/rfc2317.py +3 -3
- netbox_dns/{filters → filtersets}/contact.py +2 -1
- netbox_dns/filtersets/nameserver.py +37 -0
- netbox_dns/{filters → filtersets}/record.py +51 -6
- netbox_dns/{filters → filtersets}/registrar.py +2 -1
- netbox_dns/{filters → filtersets}/view.py +2 -2
- netbox_dns/filtersets/zone.py +205 -0
- netbox_dns/forms/contact.py +61 -33
- netbox_dns/forms/nameserver.py +21 -8
- netbox_dns/forms/record.py +65 -38
- netbox_dns/forms/registrar.py +45 -15
- netbox_dns/forms/view.py +23 -9
- netbox_dns/forms/zone.py +182 -188
- netbox_dns/graphql/__init__.py +17 -27
- netbox_dns/graphql/filters.py +49 -0
- netbox_dns/graphql/schema.py +66 -7
- netbox_dns/graphql/types.py +143 -0
- netbox_dns/management/commands/cleanup_database.py +0 -4
- netbox_dns/management/commands/cleanup_rrset_ttl.py +3 -5
- netbox_dns/management/commands/setup_coupling.py +15 -15
- netbox_dns/management/commands/update_soa.py +1 -1
- netbox_dns/migrations/0001_squashed_netbox_dns_0_15.py +0 -27
- netbox_dns/migrations/0001_squashed_netbox_dns_0_22.py +558 -0
- netbox_dns/migrations/{0013_add_nameserver_zone_record_description.py → 0002_contact_description_registrar_description.py} +4 -9
- 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/migrations/0020_netbox_3_4.py +1 -1
- netbox_dns/models/contact.py +6 -1
- netbox_dns/models/nameserver.py +5 -1
- netbox_dns/models/record.py +32 -34
- netbox_dns/models/registrar.py +5 -1
- netbox_dns/models/view.py +54 -1
- netbox_dns/models/zone.py +68 -54
- netbox_dns/navigation.py +1 -15
- netbox_dns/signals/ipam_coupling.py +3 -9
- netbox_dns/tables/contact.py +1 -0
- netbox_dns/tables/nameserver.py +0 -2
- netbox_dns/tables/registrar.py +1 -0
- netbox_dns/tables/view.py +9 -2
- netbox_dns/template_content.py +4 -8
- netbox_dns/templates/netbox_dns/contact.html +60 -56
- netbox_dns/templates/netbox_dns/nameserver.html +27 -27
- netbox_dns/templates/netbox_dns/record.html +92 -94
- netbox_dns/templates/netbox_dns/registrar.html +38 -36
- netbox_dns/templates/netbox_dns/view.html +25 -21
- netbox_dns/templates/netbox_dns/zone/base.html +5 -3
- netbox_dns/templates/netbox_dns/zone/child.html +3 -3
- netbox_dns/templates/netbox_dns/zone/managed_record.html +1 -1
- netbox_dns/templates/netbox_dns/zone/record.html +3 -3
- netbox_dns/templates/netbox_dns/zone/registration.html +26 -27
- netbox_dns/templates/netbox_dns/zone/rfc2317_child_zone.html +1 -1
- netbox_dns/templates/netbox_dns/zone.html +148 -149
- 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/utilities/__init__.py +1 -6
- netbox_dns/utilities/ipam_coupling.py +2 -7
- netbox_dns/validators/dns_name.py +4 -9
- netbox_dns/validators/rfc2317.py +2 -2
- netbox_dns/views/contact.py +4 -4
- netbox_dns/views/nameserver.py +5 -5
- netbox_dns/views/record.py +14 -29
- netbox_dns/views/registrar.py +4 -4
- netbox_dns/views/view.py +4 -4
- netbox_dns/views/zone.py +7 -8
- {netbox_plugin_dns-0.22.8.dist-info → netbox_plugin_dns-1.0.0.dist-info}/METADATA +27 -13
- netbox_plugin_dns-1.0.0.dist-info/RECORD +112 -0
- netbox_dns/filters/nameserver.py +0 -18
- netbox_dns/filters/zone.py +0 -112
- netbox_dns/graphql/contact.py +0 -19
- netbox_dns/graphql/nameserver.py +0 -19
- netbox_dns/graphql/record.py +0 -19
- netbox_dns/graphql/registrar.py +0 -19
- netbox_dns/graphql/view.py +0 -19
- netbox_dns/graphql/zone.py +0 -19
- netbox_dns/migrations/0001_initial.py +0 -115
- netbox_dns/migrations/0002_zone_default_ttl.py +0 -18
- netbox_dns/migrations/0003_soa_managed_records.py +0 -112
- netbox_dns/migrations/0004_create_ptr_for_a_aaaa_records.py +0 -80
- netbox_dns/migrations/0005_update_ns_records.py +0 -41
- netbox_dns/migrations/0006_zone_soa_serial_auto.py +0 -29
- netbox_dns/migrations/0007_alter_zone_soa_serial_auto.py +0 -17
- netbox_dns/migrations/0008_zone_status_names.py +0 -21
- netbox_dns/migrations/0009_netbox32.py +0 -71
- netbox_dns/migrations/0010_update_soa_records.py +0 -58
- netbox_dns/migrations/0011_add_view_model.py +0 -70
- netbox_dns/migrations/0012_adjust_zone_and_record.py +0 -17
- netbox_dns/migrations/0014_add_view_description.py +0 -16
- netbox_dns/migrations/0015_add_record_status.py +0 -17
- netbox_dns/migrations/0016_cleanup_ptr_records.py +0 -38
- netbox_dns/migrations/0017_alter_record_ttl.py +0 -17
- netbox_dns/migrations/0018_zone_arpa_network.py +0 -51
- netbox_dns/migrations/0019_update_ns_ttl.py +0 -19
- netbox_dns/urls.py +0 -297
- netbox_plugin_dns-0.22.8.dist-info/RECORD +0 -117
- /netbox_dns/{filters → filtersets}/__init__.py +0 -0
- {netbox_plugin_dns-0.22.8.dist-info → netbox_plugin_dns-1.0.0.dist-info}/LICENSE +0 -0
- {netbox_plugin_dns-0.22.8.dist-info → netbox_plugin_dns-1.0.0.dist-info}/WHEEL +0 -0
|
@@ -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
|
+
]
|
netbox_dns/utilities/__init__.py
CHANGED
|
@@ -4,12 +4,7 @@ from dns import name as dns_name
|
|
|
4
4
|
from dns.exception import DNSException
|
|
5
5
|
from netaddr import IPNetwork, AddrFormatError
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
# NetBox 3.5.0 - 3.5.7, 3.5.9+
|
|
9
|
-
from extras.plugins import get_plugin_config
|
|
10
|
-
except ImportError:
|
|
11
|
-
# NetBox 3.5.8
|
|
12
|
-
from extras.plugins.utils import get_plugin_config
|
|
7
|
+
from netbox.plugins.utils import get_plugin_config
|
|
13
8
|
|
|
14
9
|
|
|
15
10
|
class NameFormatError(Exception):
|
|
@@ -3,12 +3,7 @@ from utilities.permissions import resolve_permission
|
|
|
3
3
|
|
|
4
4
|
from netbox_dns.models import Record, RecordTypeChoices, RecordStatusChoices
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
# NetBox 3.5.0 - 3.5.7, 3.5.9+
|
|
8
|
-
from extras.plugins import get_plugin_config
|
|
9
|
-
except ImportError:
|
|
10
|
-
# NetBox 3.5.8
|
|
11
|
-
from extras.plugins.utils import get_plugin_config
|
|
6
|
+
from netbox.plugins.utils import get_plugin_config
|
|
12
7
|
|
|
13
8
|
|
|
14
9
|
class DNSPermissionDenied(Exception):
|
|
@@ -69,7 +64,7 @@ def new_address_record(instance):
|
|
|
69
64
|
status=address_record_status(instance),
|
|
70
65
|
type=address_record_type(instance),
|
|
71
66
|
value=str(instance.address.ip),
|
|
72
|
-
ipam_ip_address_id=instance.
|
|
67
|
+
ipam_ip_address_id=instance.pk,
|
|
73
68
|
managed=True,
|
|
74
69
|
)
|
|
75
70
|
|
|
@@ -2,12 +2,7 @@ import re
|
|
|
2
2
|
|
|
3
3
|
from django.core.exceptions import ValidationError
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
# NetBox 3.5.0 - 3.5.7, 3.5.9+
|
|
7
|
-
from extras.plugins import get_plugin_config
|
|
8
|
-
except ImportError:
|
|
9
|
-
# NetBox 3.5.8
|
|
10
|
-
from extras.plugins.utils import get_plugin_config
|
|
5
|
+
from netbox.plugins.utils import get_plugin_config
|
|
11
6
|
|
|
12
7
|
LABEL = r"[a-z0-9][a-z0-9-]*(?<!-)"
|
|
13
8
|
TOLERANT_LABEL = r"[a-z0-9][a-z0-9-_]*(?<![-_])"
|
|
@@ -26,7 +21,7 @@ def validate_fqdn(name):
|
|
|
26
21
|
regex = rf"^(\*|{LABEL})(\.{LABEL})+\.?$"
|
|
27
22
|
|
|
28
23
|
if not re.match(regex, name, flags=re.IGNORECASE) or has_invalid_double_dash(name):
|
|
29
|
-
raise ValidationError(
|
|
24
|
+
raise ValidationError("Not a valid fully qualified DNS host name")
|
|
30
25
|
|
|
31
26
|
|
|
32
27
|
def validate_extended_hostname(name, tolerate_leading_underscores=False):
|
|
@@ -41,7 +36,7 @@ def validate_extended_hostname(name, tolerate_leading_underscores=False):
|
|
|
41
36
|
regex = rf"^([*@]|(\*\.)?{LABEL}(\.{LABEL})*\.?)$"
|
|
42
37
|
|
|
43
38
|
if not re.match(regex, name, flags=re.IGNORECASE) or has_invalid_double_dash(name):
|
|
44
|
-
raise ValidationError(
|
|
39
|
+
raise ValidationError("Not a valid DNS host name")
|
|
45
40
|
|
|
46
41
|
|
|
47
42
|
def validate_domain_name(name):
|
|
@@ -54,4 +49,4 @@ def validate_domain_name(name):
|
|
|
54
49
|
regex = rf"^{LABEL}(\.{LABEL})*\.?$"
|
|
55
50
|
|
|
56
51
|
if not re.match(regex, name, flags=re.IGNORECASE) or has_invalid_double_dash(name):
|
|
57
|
-
raise ValidationError(
|
|
52
|
+
raise ValidationError("Not a valid DNS domain name")
|
netbox_dns/validators/rfc2317.py
CHANGED
|
@@ -10,9 +10,9 @@ def validate_prefix(prefix):
|
|
|
10
10
|
|
|
11
11
|
def validate_ipv4(prefix):
|
|
12
12
|
if prefix.version != 4:
|
|
13
|
-
raise ValidationError(
|
|
13
|
+
raise ValidationError("RFC2317 requires an IPv4 prefix.")
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
def validate_rfc2317(prefix):
|
|
17
17
|
if prefix.prefixlen <= 24:
|
|
18
|
-
raise ValidationError(
|
|
18
|
+
raise ValidationError("RFC2317 requires at least 25 bit prefix length.")
|
netbox_dns/views/contact.py
CHANGED
|
@@ -5,7 +5,7 @@ from netbox.views import generic
|
|
|
5
5
|
from utilities.views import ViewTab, register_model_view
|
|
6
6
|
|
|
7
7
|
from netbox_dns.models import Contact, Zone
|
|
8
|
-
from netbox_dns.
|
|
8
|
+
from netbox_dns.filtersets import ContactFilterSet, ZoneFilterSet
|
|
9
9
|
from netbox_dns.forms import (
|
|
10
10
|
ContactForm,
|
|
11
11
|
ContactFilterForm,
|
|
@@ -22,7 +22,7 @@ class ContactView(generic.ObjectView):
|
|
|
22
22
|
class ContactListView(generic.ObjectListView):
|
|
23
23
|
queryset = Contact.objects.all()
|
|
24
24
|
table = ContactTable
|
|
25
|
-
filterset =
|
|
25
|
+
filterset = ContactFilterSet
|
|
26
26
|
filterset_form = ContactFilterForm
|
|
27
27
|
|
|
28
28
|
|
|
@@ -46,7 +46,7 @@ class ContactBulkImportView(generic.BulkImportView):
|
|
|
46
46
|
|
|
47
47
|
class ContactBulkEditView(generic.BulkEditView):
|
|
48
48
|
queryset = Contact.objects.all()
|
|
49
|
-
filterset =
|
|
49
|
+
filterset = ContactFilterSet
|
|
50
50
|
table = ContactTable
|
|
51
51
|
form = ContactBulkEditForm
|
|
52
52
|
|
|
@@ -63,7 +63,7 @@ class ContactZoneListView(generic.ObjectChildrenView):
|
|
|
63
63
|
)
|
|
64
64
|
child_model = Zone
|
|
65
65
|
table = ZoneTable
|
|
66
|
-
filterset =
|
|
66
|
+
filterset = ZoneFilterSet
|
|
67
67
|
template_name = "netbox_dns/zone/child.html"
|
|
68
68
|
hide_if_empty = True
|
|
69
69
|
|
netbox_dns/views/nameserver.py
CHANGED
|
@@ -3,7 +3,7 @@ from dns import name as dns_name
|
|
|
3
3
|
from netbox.views import generic
|
|
4
4
|
from utilities.views import ViewTab, register_model_view
|
|
5
5
|
|
|
6
|
-
from netbox_dns.
|
|
6
|
+
from netbox_dns.filtersets import NameServerFilterSet, ZoneFilterSet
|
|
7
7
|
from netbox_dns.forms import (
|
|
8
8
|
NameServerImportForm,
|
|
9
9
|
NameServerFilterForm,
|
|
@@ -16,7 +16,7 @@ from netbox_dns.tables import NameServerTable, ZoneTable
|
|
|
16
16
|
|
|
17
17
|
class NameServerListView(generic.ObjectListView):
|
|
18
18
|
queryset = NameServer.objects.all()
|
|
19
|
-
filterset =
|
|
19
|
+
filterset = NameServerFilterSet
|
|
20
20
|
filterset_form = NameServerFilterForm
|
|
21
21
|
table = NameServerTable
|
|
22
22
|
|
|
@@ -54,7 +54,7 @@ class NameServerBulkImportView(generic.BulkImportView):
|
|
|
54
54
|
|
|
55
55
|
class NameServerBulkEditView(generic.BulkEditView):
|
|
56
56
|
queryset = NameServer.objects.all()
|
|
57
|
-
filterset =
|
|
57
|
+
filterset = NameServerFilterSet
|
|
58
58
|
table = NameServerTable
|
|
59
59
|
form = NameServerBulkEditForm
|
|
60
60
|
|
|
@@ -69,7 +69,7 @@ class NameServerZoneListView(generic.ObjectChildrenView):
|
|
|
69
69
|
queryset = NameServer.objects.all().prefetch_related("zones")
|
|
70
70
|
child_model = Zone
|
|
71
71
|
table = ZoneTable
|
|
72
|
-
filterset =
|
|
72
|
+
filterset = ZoneFilterSet
|
|
73
73
|
template_name = "netbox_dns/zone/child.html"
|
|
74
74
|
hide_if_empty = True
|
|
75
75
|
|
|
@@ -89,7 +89,7 @@ class NameServerSOAZoneListView(generic.ObjectChildrenView):
|
|
|
89
89
|
queryset = NameServer.objects.all().prefetch_related("zones_soa")
|
|
90
90
|
child_model = Zone
|
|
91
91
|
table = ZoneTable
|
|
92
|
-
filterset =
|
|
92
|
+
filterset = ZoneFilterSet
|
|
93
93
|
template_name = "netbox_dns/zone/child.html"
|
|
94
94
|
hide_if_empty = True
|
|
95
95
|
|
netbox_dns/views/record.py
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
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
|
-
from netbox_dns.
|
|
5
|
+
from netbox_dns.filtersets import RecordFilterSet
|
|
9
6
|
from netbox_dns.forms import (
|
|
10
7
|
RecordImportForm,
|
|
11
8
|
RecordFilterForm,
|
|
@@ -21,7 +18,7 @@ class RecordListView(generic.ObjectListView):
|
|
|
21
18
|
queryset = Record.objects.filter(managed=False).prefetch_related(
|
|
22
19
|
"zone", "ptr_record"
|
|
23
20
|
)
|
|
24
|
-
filterset =
|
|
21
|
+
filterset = RecordFilterSet
|
|
25
22
|
filterset_form = RecordFilterForm
|
|
26
23
|
table = RecordTable
|
|
27
24
|
|
|
@@ -30,10 +27,10 @@ class ManagedRecordListView(generic.ObjectListView):
|
|
|
30
27
|
queryset = Record.objects.filter(managed=True).prefetch_related(
|
|
31
28
|
"zone", "address_record"
|
|
32
29
|
)
|
|
33
|
-
filterset =
|
|
30
|
+
filterset = RecordFilterSet
|
|
34
31
|
filterset_form = RecordFilterForm
|
|
35
32
|
table = ManagedRecordTable
|
|
36
|
-
actions =
|
|
33
|
+
actions = {"export": {"view"}}
|
|
37
34
|
template_name = "netbox_dns/record/managed.html"
|
|
38
35
|
|
|
39
36
|
|
|
@@ -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(
|
|
@@ -149,7 +134,7 @@ class RecordBulkImportView(generic.BulkImportView):
|
|
|
149
134
|
|
|
150
135
|
class RecordBulkEditView(generic.BulkEditView):
|
|
151
136
|
queryset = Record.objects.filter(managed=False).prefetch_related("zone")
|
|
152
|
-
filterset =
|
|
137
|
+
filterset = RecordFilterSet
|
|
153
138
|
table = RecordTable
|
|
154
139
|
form = RecordBulkEditForm
|
|
155
140
|
|
netbox_dns/views/registrar.py
CHANGED
|
@@ -3,7 +3,7 @@ from netbox.views import generic
|
|
|
3
3
|
from utilities.views import ViewTab, register_model_view
|
|
4
4
|
|
|
5
5
|
from netbox_dns.models import Registrar, Zone
|
|
6
|
-
from netbox_dns.
|
|
6
|
+
from netbox_dns.filtersets import RegistrarFilterSet, ZoneFilterSet
|
|
7
7
|
from netbox_dns.forms import (
|
|
8
8
|
RegistrarForm,
|
|
9
9
|
RegistrarFilterForm,
|
|
@@ -20,7 +20,7 @@ class RegistrarView(generic.ObjectView):
|
|
|
20
20
|
class RegistrarListView(generic.ObjectListView):
|
|
21
21
|
queryset = Registrar.objects.all()
|
|
22
22
|
table = RegistrarTable
|
|
23
|
-
filterset =
|
|
23
|
+
filterset = RegistrarFilterSet
|
|
24
24
|
filterset_form = RegistrarFilterForm
|
|
25
25
|
|
|
26
26
|
|
|
@@ -44,7 +44,7 @@ class RegistrarBulkImportView(generic.BulkImportView):
|
|
|
44
44
|
|
|
45
45
|
class RegistrarBulkEditView(generic.BulkEditView):
|
|
46
46
|
queryset = Registrar.objects.all()
|
|
47
|
-
filterset =
|
|
47
|
+
filterset = RegistrarFilterSet
|
|
48
48
|
table = RegistrarTable
|
|
49
49
|
form = RegistrarBulkEditForm
|
|
50
50
|
|
|
@@ -59,7 +59,7 @@ class RegistrarZoneListView(generic.ObjectChildrenView):
|
|
|
59
59
|
queryset = Registrar.objects.all().prefetch_related("zone_set")
|
|
60
60
|
child_model = Zone
|
|
61
61
|
table = ZoneTable
|
|
62
|
-
filterset =
|
|
62
|
+
filterset = ZoneFilterSet
|
|
63
63
|
template_name = "netbox_dns/zone/child.html"
|
|
64
64
|
hide_if_empty = True
|
|
65
65
|
|
netbox_dns/views/view.py
CHANGED
|
@@ -3,7 +3,7 @@ from utilities.views import ViewTab, register_model_view
|
|
|
3
3
|
from netbox.views import generic
|
|
4
4
|
|
|
5
5
|
from netbox_dns.models import View, Zone
|
|
6
|
-
from netbox_dns.
|
|
6
|
+
from netbox_dns.filtersets import ViewFilterSet, ZoneFilterSet
|
|
7
7
|
from netbox_dns.forms import ViewForm, ViewFilterForm, ViewImportForm, ViewBulkEditForm
|
|
8
8
|
from netbox_dns.tables import ViewTable, ZoneTable
|
|
9
9
|
|
|
@@ -15,7 +15,7 @@ class ViewView(generic.ObjectView):
|
|
|
15
15
|
class ViewListView(generic.ObjectListView):
|
|
16
16
|
queryset = View.objects.all()
|
|
17
17
|
table = ViewTable
|
|
18
|
-
filterset =
|
|
18
|
+
filterset = ViewFilterSet
|
|
19
19
|
filterset_form = ViewFilterForm
|
|
20
20
|
|
|
21
21
|
|
|
@@ -39,7 +39,7 @@ class ViewBulkImportView(generic.BulkImportView):
|
|
|
39
39
|
|
|
40
40
|
class ViewBulkEditView(generic.BulkEditView):
|
|
41
41
|
queryset = View.objects.all()
|
|
42
|
-
filterset =
|
|
42
|
+
filterset = ViewFilterSet
|
|
43
43
|
table = ViewTable
|
|
44
44
|
form = ViewBulkEditForm
|
|
45
45
|
|
|
@@ -54,7 +54,7 @@ class ViewZoneListView(generic.ObjectChildrenView):
|
|
|
54
54
|
queryset = View.objects.all().prefetch_related("zone_set")
|
|
55
55
|
child_model = Zone
|
|
56
56
|
table = ZoneTable
|
|
57
|
-
filterset =
|
|
57
|
+
filterset = ZoneFilterSet
|
|
58
58
|
template_name = "netbox_dns/zone/child.html"
|
|
59
59
|
hide_if_empty = True
|
|
60
60
|
|
netbox_dns/views/zone.py
CHANGED
|
@@ -3,7 +3,7 @@ from dns import name as dns_name
|
|
|
3
3
|
from netbox.views import generic
|
|
4
4
|
from utilities.views import ViewTab, register_model_view
|
|
5
5
|
|
|
6
|
-
from netbox_dns.
|
|
6
|
+
from netbox_dns.filtersets import ZoneFilterSet, RecordFilterSet
|
|
7
7
|
from netbox_dns.forms import (
|
|
8
8
|
ZoneImportForm,
|
|
9
9
|
ZoneForm,
|
|
@@ -20,7 +20,7 @@ from netbox_dns.tables import (
|
|
|
20
20
|
|
|
21
21
|
class ZoneListView(generic.ObjectListView):
|
|
22
22
|
queryset = Zone.objects.all().prefetch_related("view", "tags")
|
|
23
|
-
filterset =
|
|
23
|
+
filterset = ZoneFilterSet
|
|
24
24
|
filterset_form = ZoneFilterForm
|
|
25
25
|
table = ZoneTable
|
|
26
26
|
|
|
@@ -75,7 +75,7 @@ class ZoneBulkEditView(generic.BulkEditView):
|
|
|
75
75
|
queryset = Zone.objects.all().prefetch_related(
|
|
76
76
|
"view", "tags", "nameservers", "soa_mname"
|
|
77
77
|
)
|
|
78
|
-
filterset =
|
|
78
|
+
filterset = ZoneFilterSet
|
|
79
79
|
table = ZoneTable
|
|
80
80
|
form = ZoneBulkEditForm
|
|
81
81
|
default_return_url = "plugins:netbox_dns:zone_list"
|
|
@@ -109,7 +109,7 @@ class ZoneRecordListView(generic.ObjectChildrenView):
|
|
|
109
109
|
queryset = Zone.objects.all()
|
|
110
110
|
child_model = Record
|
|
111
111
|
table = RecordTable
|
|
112
|
-
filterset =
|
|
112
|
+
filterset = RecordFilterSet
|
|
113
113
|
template_name = "netbox_dns/zone/record.html"
|
|
114
114
|
hide_if_empty = True
|
|
115
115
|
|
|
@@ -131,9 +131,9 @@ class ZoneManagedRecordListView(generic.ObjectChildrenView):
|
|
|
131
131
|
queryset = Zone.objects.all()
|
|
132
132
|
child_model = Record
|
|
133
133
|
table = ManagedRecordTable
|
|
134
|
-
filterset =
|
|
134
|
+
filterset = RecordFilterSet
|
|
135
135
|
template_name = "netbox_dns/zone/managed_record.html"
|
|
136
|
-
actions =
|
|
136
|
+
actions = {"changelog": {"view"}}
|
|
137
137
|
|
|
138
138
|
tab = ViewTab(
|
|
139
139
|
label="Managed Records",
|
|
@@ -153,9 +153,8 @@ class ZoneRFC2317ChildZoneListView(generic.ObjectChildrenView):
|
|
|
153
153
|
queryset = Zone.objects.all()
|
|
154
154
|
child_model = Zone
|
|
155
155
|
table = ZoneTable
|
|
156
|
-
filterset =
|
|
156
|
+
filterset = ZoneFilterSet
|
|
157
157
|
template_name = "netbox_dns/zone/rfc2317_child_zone.html"
|
|
158
|
-
actions = ("changelog",)
|
|
159
158
|
|
|
160
159
|
tab = ViewTab(
|
|
161
160
|
label="RFC2317 Child Zones",
|