netbox-plugin-dns 0.22.9__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.

Files changed (115) hide show
  1. netbox_dns/__init__.py +4 -15
  2. netbox_dns/api/nested_serializers.py +4 -60
  3. netbox_dns/api/serializers.py +8 -314
  4. netbox_dns/api/serializers_/__init__.py +0 -0
  5. netbox_dns/api/serializers_/contact.py +37 -0
  6. netbox_dns/api/serializers_/nameserver.py +39 -0
  7. netbox_dns/api/serializers_/record.py +90 -0
  8. netbox_dns/api/serializers_/registrar.py +31 -0
  9. netbox_dns/api/serializers_/view.py +34 -0
  10. netbox_dns/api/serializers_/zone.py +159 -0
  11. netbox_dns/api/views.py +13 -13
  12. netbox_dns/fields/network.py +21 -22
  13. netbox_dns/fields/rfc2317.py +3 -3
  14. netbox_dns/{filters → filtersets}/contact.py +2 -1
  15. netbox_dns/filtersets/nameserver.py +37 -0
  16. netbox_dns/{filters → filtersets}/record.py +51 -6
  17. netbox_dns/{filters → filtersets}/registrar.py +2 -1
  18. netbox_dns/{filters → filtersets}/view.py +2 -2
  19. netbox_dns/filtersets/zone.py +205 -0
  20. netbox_dns/forms/contact.py +61 -33
  21. netbox_dns/forms/nameserver.py +21 -8
  22. netbox_dns/forms/record.py +65 -38
  23. netbox_dns/forms/registrar.py +45 -15
  24. netbox_dns/forms/view.py +23 -9
  25. netbox_dns/forms/zone.py +182 -188
  26. netbox_dns/graphql/__init__.py +17 -27
  27. netbox_dns/graphql/filters.py +49 -0
  28. netbox_dns/graphql/schema.py +66 -7
  29. netbox_dns/graphql/types.py +143 -0
  30. netbox_dns/management/commands/cleanup_database.py +0 -4
  31. netbox_dns/management/commands/cleanup_rrset_ttl.py +2 -4
  32. netbox_dns/management/commands/setup_coupling.py +15 -15
  33. netbox_dns/management/commands/update_soa.py +1 -1
  34. netbox_dns/migrations/0001_squashed_netbox_dns_0_15.py +0 -27
  35. netbox_dns/migrations/0001_squashed_netbox_dns_0_22.py +558 -0
  36. netbox_dns/migrations/{0013_add_nameserver_zone_record_description.py → 0002_contact_description_registrar_description.py} +4 -9
  37. netbox_dns/migrations/0003_default_view.py +15 -0
  38. netbox_dns/migrations/0004_create_and_assign_default_view.py +26 -0
  39. netbox_dns/migrations/0005_alter_zone_view_not_null.py +18 -0
  40. netbox_dns/migrations/0020_netbox_3_4.py +1 -1
  41. netbox_dns/models/contact.py +6 -1
  42. netbox_dns/models/nameserver.py +2 -0
  43. netbox_dns/models/record.py +28 -33
  44. netbox_dns/models/registrar.py +5 -1
  45. netbox_dns/models/view.py +54 -1
  46. netbox_dns/models/zone.py +68 -54
  47. netbox_dns/navigation.py +1 -15
  48. netbox_dns/signals/ipam_coupling.py +3 -9
  49. netbox_dns/tables/contact.py +1 -0
  50. netbox_dns/tables/nameserver.py +0 -2
  51. netbox_dns/tables/registrar.py +1 -0
  52. netbox_dns/tables/view.py +9 -2
  53. netbox_dns/template_content.py +4 -8
  54. netbox_dns/templates/netbox_dns/contact.html +60 -56
  55. netbox_dns/templates/netbox_dns/nameserver.html +27 -27
  56. netbox_dns/templates/netbox_dns/record.html +92 -94
  57. netbox_dns/templates/netbox_dns/registrar.html +38 -36
  58. netbox_dns/templates/netbox_dns/view.html +25 -21
  59. netbox_dns/templates/netbox_dns/zone/base.html +5 -3
  60. netbox_dns/templates/netbox_dns/zone/child.html +3 -3
  61. netbox_dns/templates/netbox_dns/zone/managed_record.html +1 -1
  62. netbox_dns/templates/netbox_dns/zone/record.html +3 -3
  63. netbox_dns/templates/netbox_dns/zone/registration.html +26 -27
  64. netbox_dns/templates/netbox_dns/zone/rfc2317_child_zone.html +1 -1
  65. netbox_dns/templates/netbox_dns/zone.html +148 -149
  66. netbox_dns/urls/__init__.py +17 -0
  67. netbox_dns/urls/contact.py +51 -0
  68. netbox_dns/urls/nameserver.py +69 -0
  69. netbox_dns/urls/record.py +41 -0
  70. netbox_dns/urls/registrar.py +63 -0
  71. netbox_dns/urls/view.py +39 -0
  72. netbox_dns/urls/zone.py +57 -0
  73. netbox_dns/utilities/__init__.py +1 -6
  74. netbox_dns/utilities/ipam_coupling.py +2 -7
  75. netbox_dns/validators/dns_name.py +4 -9
  76. netbox_dns/validators/rfc2317.py +2 -2
  77. netbox_dns/views/contact.py +4 -4
  78. netbox_dns/views/nameserver.py +5 -5
  79. netbox_dns/views/record.py +15 -23
  80. netbox_dns/views/registrar.py +4 -4
  81. netbox_dns/views/view.py +4 -4
  82. netbox_dns/views/zone.py +7 -8
  83. {netbox_plugin_dns-0.22.9.dist-info → netbox_plugin_dns-1.0.0.dist-info}/METADATA +27 -13
  84. netbox_plugin_dns-1.0.0.dist-info/RECORD +112 -0
  85. netbox_dns/filters/nameserver.py +0 -18
  86. netbox_dns/filters/zone.py +0 -112
  87. netbox_dns/graphql/contact.py +0 -19
  88. netbox_dns/graphql/nameserver.py +0 -19
  89. netbox_dns/graphql/record.py +0 -19
  90. netbox_dns/graphql/registrar.py +0 -19
  91. netbox_dns/graphql/view.py +0 -19
  92. netbox_dns/graphql/zone.py +0 -19
  93. netbox_dns/migrations/0001_initial.py +0 -115
  94. netbox_dns/migrations/0002_zone_default_ttl.py +0 -18
  95. netbox_dns/migrations/0003_soa_managed_records.py +0 -112
  96. netbox_dns/migrations/0004_create_ptr_for_a_aaaa_records.py +0 -80
  97. netbox_dns/migrations/0005_update_ns_records.py +0 -41
  98. netbox_dns/migrations/0006_zone_soa_serial_auto.py +0 -29
  99. netbox_dns/migrations/0007_alter_zone_soa_serial_auto.py +0 -17
  100. netbox_dns/migrations/0008_zone_status_names.py +0 -21
  101. netbox_dns/migrations/0009_netbox32.py +0 -71
  102. netbox_dns/migrations/0010_update_soa_records.py +0 -58
  103. netbox_dns/migrations/0011_add_view_model.py +0 -70
  104. netbox_dns/migrations/0012_adjust_zone_and_record.py +0 -17
  105. netbox_dns/migrations/0014_add_view_description.py +0 -16
  106. netbox_dns/migrations/0015_add_record_status.py +0 -17
  107. netbox_dns/migrations/0016_cleanup_ptr_records.py +0 -38
  108. netbox_dns/migrations/0017_alter_record_ttl.py +0 -17
  109. netbox_dns/migrations/0018_zone_arpa_network.py +0 -51
  110. netbox_dns/migrations/0019_update_ns_ttl.py +0 -19
  111. netbox_dns/urls.py +0 -297
  112. netbox_plugin_dns-0.22.9.dist-info/RECORD +0 -117
  113. /netbox_dns/{filters → filtersets}/__init__.py +0 -0
  114. {netbox_plugin_dns-0.22.9.dist-info → netbox_plugin_dns-1.0.0.dist-info}/LICENSE +0 -0
  115. {netbox_plugin_dns-0.22.9.dist-info → netbox_plugin_dns-1.0.0.dist-info}/WHEEL +0 -0
@@ -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
+ ]
@@ -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
+ ]
@@ -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
+ ]
@@ -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
- try:
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
- try:
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.id,
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
- try:
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(f"Not a valid fully qualified DNS host name")
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(f"Not a valid DNS host name")
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(f"Not a valid DNS domain name")
52
+ raise ValidationError("Not a valid DNS domain name")
@@ -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(f"RFC2317 requires an IPv4 prefix.")
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(f"RFC2317 requires at least 25 bit prefix length.")
18
+ raise ValidationError("RFC2317 requires at least 25 bit prefix length.")
@@ -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.filters import ContactFilter, ZoneFilter
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 = ContactFilter
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 = ContactFilter
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 = ZoneFilter
66
+ filterset = ZoneFilterSet
67
67
  template_name = "netbox_dns/zone/child.html"
68
68
  hide_if_empty = True
69
69
 
@@ -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.filters import NameServerFilter, ZoneFilter
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 = NameServerFilter
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 = NameServerFilter
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 = ZoneFilter
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 = ZoneFilter
92
+ filterset = ZoneFilterSet
93
93
  template_name = "netbox_dns/zone/child.html"
94
94
  hide_if_empty = True
95
95
 
@@ -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.filters import RecordFilter
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 = RecordFilter
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 = RecordFilter
30
+ filterset = RecordFilterSet
34
31
  filterset_form = RecordFilterForm
35
32
  table = ManagedRecordTable
36
- actions = ("export",)
33
+ actions = {"export": {"view"}}
37
34
  template_name = "netbox_dns/record/managed.html"
38
35
 
39
36
 
@@ -41,15 +38,11 @@ class RecordView(generic.ObjectView):
41
38
  queryset = Record.objects.all().prefetch_related("zone", "ptr_record")
42
39
 
43
40
  def get_value_records(self, instance):
44
- view_filter = (
45
- Q(zone__view__isnull=True)
46
- if instance.zone.view is None
47
- else Q(zone__view=instance.zone.view)
48
- )
49
-
50
41
  value_fqdn = dns_name.from_text(instance.value_fqdn)
51
42
 
52
- cname_targets = Record.objects.filter(view_filter, fqdn=value_fqdn)
43
+ cname_targets = Record.objects.filter(
44
+ zone__view=instance.zone.view, fqdn=value_fqdn
45
+ )
53
46
 
54
47
  if cname_targets:
55
48
  return RelatedRecordTable(
@@ -59,14 +52,11 @@ class RecordView(generic.ObjectView):
59
52
  return None
60
53
 
61
54
  def get_cname_records(self, instance):
62
- view_filter = (
63
- Q(zone__view__isnull=True)
64
- if instance.zone.view is None
65
- else Q(zone__view=instance.zone.view)
66
- )
67
55
  cname_records = set(
68
56
  Record.objects.filter(
69
- view_filter, value=instance.fqdn, type=RecordTypeChoices.CNAME
57
+ zone__view=instance.zone.view,
58
+ value=instance.fqdn,
59
+ type=RecordTypeChoices.CNAME,
70
60
  )
71
61
  )
72
62
 
@@ -77,12 +67,14 @@ class RecordView(generic.ObjectView):
77
67
  ]
78
68
 
79
69
  parent_zones = Zone.objects.filter(
80
- instance.zone.view_filter, name__in=parent_zone_names
70
+ view=instance.zone.view, name__in=parent_zone_names
81
71
  )
82
72
 
83
73
  for parent_zone in parent_zones:
84
74
  parent_cname_records = Record.objects.filter(
85
- view_filter, type=RecordTypeChoices.CNAME, zone=parent_zone
75
+ zone__view=instance.zone.view,
76
+ type=RecordTypeChoices.CNAME,
77
+ zone=parent_zone,
86
78
  )
87
79
  cname_records = cname_records.union(
88
80
  set(
@@ -142,7 +134,7 @@ class RecordBulkImportView(generic.BulkImportView):
142
134
 
143
135
  class RecordBulkEditView(generic.BulkEditView):
144
136
  queryset = Record.objects.filter(managed=False).prefetch_related("zone")
145
- filterset = RecordFilter
137
+ filterset = RecordFilterSet
146
138
  table = RecordTable
147
139
  form = RecordBulkEditForm
148
140
 
@@ -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.filters import RegistrarFilter, ZoneFilter
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 = RegistrarFilter
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 = RegistrarFilter
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 = ZoneFilter
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.filters import ViewFilter, ZoneFilter
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 = ViewFilter
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 = ViewFilter
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 = ZoneFilter
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.filters import ZoneFilter, RecordFilter
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 = ZoneFilter
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 = ZoneFilter
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 = RecordFilter
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 = RecordFilter
134
+ filterset = RecordFilterSet
135
135
  template_name = "netbox_dns/zone/managed_record.html"
136
- actions = ("changelog",)
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 = ZoneFilter
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",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: netbox-plugin-dns
3
- Version: 0.22.9
3
+ Version: 1.0.0
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
@@ -21,7 +21,7 @@ Project-URL: Repository, https://github.com/peteeckel/netbox-plugin-dns
21
21
  Description-Content-Type: text/markdown
22
22
 
23
23
  # NetBox DNS
24
- 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, current and conforming to the relevant RFCs.
24
+ 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.
25
25
 
26
26
  <div align="center">
27
27
  <a href="https://pypi.org/project/netbox-plugin-dns/"><img src="https://img.shields.io/pypi/v/netbox-plugin-dns" alt="PyPi"/></a>
@@ -36,21 +36,35 @@ The NetBox DNS plugin enables NetBox to manage operational DNS data such as name
36
36
  <a href="https://pepy.tech/project/netbox-plugin-dns"><img alt="Downloads/Month" src="https://static.pepy.tech/badge/netbox-plugin-dns/week"></a>
37
37
  </div>
38
38
 
39
- ## Features
39
+ ## Objectives
40
+ NetBox DNS is designed to be the 'DNS Source of Truth' analogous to NetBox being the 'Network Source of Truth'.
40
41
 
41
- * Manage name servers, zones and records
42
- * Automatically generate SOA and NS records for zones
43
- * Automatically create and update PTR records for IPv4 and IPv6 address records
44
- * Organize DNS zones in views for split horizon DNS and multi-site deployments
45
- * Manage domain registrar and registrant information for domains related to zones
46
- * Manage RFC2317 reverse zones for IPv4 prefixes with a network mask length longer than 24 bits
42
+ 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.
47
43
 
48
- NetBox DNS is using the standardized NetBox plugin interface, so it also takes advantage of the NetBox tagging and change log features.
44
+ 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:
45
+
46
+ * Validation of record names and values
47
+ * Automatic maintenance of PTR records for IPv6 and IPv4 address records
48
+ * Automatic generation of SOA records, optionally including the serial number of the zone data
49
+ * Validation of record types such as CNAME and singletons, to ensure DNS zone validity
50
+ * Support for [RFC 2317](https://datatracker.ietf.org/doc/html/rfc2317) delegation of PTR zones for IPv4 subnets longer than 24 bits
51
+
52
+ Other main features include:
53
+
54
+ * Support for BIND views, providing lightweight namespaces for zones
55
+ * Support for IDN, including the validation of punycode names
56
+ * Full support for the NetBox REST and GraphQL APIs
57
+ * Support for all major NetBox features such as global search, tenancy, change logs, tagging, journaling etc.
58
+
59
+ ## Non-objectives
60
+ 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.
61
+
62
+ 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.
49
63
 
50
64
  ## Requirements
51
65
 
52
- * NetBox 3.5.0 or higher
53
- * Python 3.8 or higher
66
+ * NetBox 4.0.0 or higher
67
+ * Python 3.10 or higher
54
68
 
55
69
  ## Installation & Configuration
56
70
 
@@ -87,7 +101,7 @@ Full documentation on using plugins with NetBox: [Using Plugins - NetBox Documen
87
101
 
88
102
  ## Contribute
89
103
 
90
- Contributions are always welcome! Please see: [contributing guide](CONTRIBUTING.md)
104
+ Contributions are always welcome! Please see the [Contribution Guidelines](CONTRIBUTING.md)
91
105
 
92
106
  ## Documentation
93
107