netbox-plugin-dns 0.21.4__py3-none-any.whl → 1.4.7__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.
Files changed (232) hide show
  1. netbox_dns/__init__.py +106 -41
  2. netbox_dns/api/field_serializers.py +25 -0
  3. netbox_dns/api/nested_serializers.py +95 -52
  4. netbox_dns/api/serializers.py +14 -296
  5. netbox_dns/api/serializers_/__init__.py +0 -0
  6. netbox_dns/api/serializers_/dnssec_key_template.py +69 -0
  7. netbox_dns/api/serializers_/dnssec_policy.py +165 -0
  8. netbox_dns/api/serializers_/nameserver.py +56 -0
  9. netbox_dns/api/serializers_/prefix.py +18 -0
  10. netbox_dns/api/serializers_/record.py +105 -0
  11. netbox_dns/api/serializers_/record_template.py +71 -0
  12. netbox_dns/api/serializers_/registrar.py +45 -0
  13. netbox_dns/api/serializers_/registration_contact.py +50 -0
  14. netbox_dns/api/serializers_/view.py +81 -0
  15. netbox_dns/api/serializers_/zone.py +247 -0
  16. netbox_dns/api/serializers_/zone_template.py +157 -0
  17. netbox_dns/api/urls.py +13 -2
  18. netbox_dns/api/views.py +96 -58
  19. netbox_dns/choices/__init__.py +4 -0
  20. netbox_dns/choices/dnssec_key_template.py +67 -0
  21. netbox_dns/choices/dnssec_policy.py +40 -0
  22. netbox_dns/choices/record.py +104 -0
  23. netbox_dns/choices/utilities.py +4 -0
  24. netbox_dns/choices/zone.py +119 -0
  25. netbox_dns/fields/__init__.py +4 -0
  26. netbox_dns/fields/address.py +22 -16
  27. netbox_dns/fields/choice_array.py +33 -0
  28. netbox_dns/fields/ipam.py +15 -0
  29. netbox_dns/fields/network.py +42 -18
  30. netbox_dns/fields/rfc2317.py +97 -0
  31. netbox_dns/fields/timeperiod.py +33 -0
  32. netbox_dns/filters.py +7 -0
  33. netbox_dns/filtersets/__init__.py +12 -0
  34. netbox_dns/filtersets/dnssec_key_template.py +57 -0
  35. netbox_dns/filtersets/dnssec_policy.py +101 -0
  36. netbox_dns/filtersets/nameserver.py +46 -0
  37. netbox_dns/filtersets/record.py +135 -0
  38. netbox_dns/filtersets/record_template.py +59 -0
  39. netbox_dns/{filters → filtersets}/registrar.py +8 -1
  40. netbox_dns/{filters/contact.py → filtersets/registration_contact.py} +9 -3
  41. netbox_dns/filtersets/view.py +45 -0
  42. netbox_dns/filtersets/zone.py +254 -0
  43. netbox_dns/filtersets/zone_template.py +165 -0
  44. netbox_dns/forms/__init__.py +5 -1
  45. netbox_dns/forms/dnssec_key_template.py +250 -0
  46. netbox_dns/forms/dnssec_policy.py +654 -0
  47. netbox_dns/forms/nameserver.py +121 -27
  48. netbox_dns/forms/record.py +215 -104
  49. netbox_dns/forms/record_template.py +285 -0
  50. netbox_dns/forms/registrar.py +108 -31
  51. netbox_dns/forms/registration_contact.py +282 -0
  52. netbox_dns/forms/view.py +331 -20
  53. netbox_dns/forms/zone.py +769 -373
  54. netbox_dns/forms/zone_template.py +463 -0
  55. netbox_dns/graphql/__init__.py +25 -22
  56. netbox_dns/graphql/enums.py +41 -0
  57. netbox_dns/graphql/filter_lookups.py +13 -0
  58. netbox_dns/graphql/filters/__init__.py +12 -0
  59. netbox_dns/graphql/filters/dnssec_key_template.py +63 -0
  60. netbox_dns/graphql/filters/dnssec_policy.py +124 -0
  61. netbox_dns/graphql/filters/nameserver.py +32 -0
  62. netbox_dns/graphql/filters/record.py +89 -0
  63. netbox_dns/graphql/filters/record_template.py +55 -0
  64. netbox_dns/graphql/filters/registrar.py +30 -0
  65. netbox_dns/graphql/filters/registration_contact.py +27 -0
  66. netbox_dns/graphql/filters/view.py +28 -0
  67. netbox_dns/graphql/filters/zone.py +147 -0
  68. netbox_dns/graphql/filters/zone_template.py +97 -0
  69. netbox_dns/graphql/schema.py +89 -7
  70. netbox_dns/graphql/types.py +355 -0
  71. netbox_dns/locale/de/LC_MESSAGES/django.mo +0 -0
  72. netbox_dns/locale/en/LC_MESSAGES/django.mo +0 -0
  73. netbox_dns/locale/fr/LC_MESSAGES/django.mo +0 -0
  74. netbox_dns/management/commands/cleanup_database.py +175 -156
  75. netbox_dns/management/commands/cleanup_rrset_ttl.py +64 -0
  76. netbox_dns/management/commands/rebuild_dnssync.py +23 -0
  77. netbox_dns/management/commands/setup_dnssync.py +140 -0
  78. netbox_dns/migrations/0001_squashed_netbox_dns_0_15.py +0 -27
  79. netbox_dns/migrations/0001_squashed_netbox_dns_0_22.py +557 -0
  80. netbox_dns/migrations/{0013_add_nameserver_zone_record_description.py → 0002_contact_description_registrar_description.py} +4 -9
  81. netbox_dns/migrations/0003_default_view.py +15 -0
  82. netbox_dns/migrations/0004_create_and_assign_default_view.py +26 -0
  83. netbox_dns/migrations/0005_alter_zone_view_not_null.py +18 -0
  84. netbox_dns/migrations/0006_templating.py +172 -0
  85. netbox_dns/migrations/0007_alter_ordering_options.py +25 -0
  86. netbox_dns/migrations/0008_view_prefixes.py +18 -0
  87. netbox_dns/migrations/0009_rename_contact_registrationcontact.py +36 -0
  88. netbox_dns/migrations/0010_view_ip_address_filter.py +18 -0
  89. netbox_dns/migrations/0011_rename_related_fields.py +63 -0
  90. netbox_dns/migrations/0012_natural_ordering.py +88 -0
  91. netbox_dns/migrations/0013_zonetemplate_soa_mname_zonetemplate_soa_rname.py +30 -0
  92. netbox_dns/migrations/0014_alter_unique_constraints_lowercase.py +42 -0
  93. netbox_dns/migrations/0015_dnssec.py +168 -0
  94. netbox_dns/migrations/{0015_add_record_status.py → 0016_dnssec_policy_status.py} +5 -4
  95. netbox_dns/migrations/0017_dnssec_policy_zone_zone_template.py +41 -0
  96. netbox_dns/migrations/0018_zone_domain_status_zone_expiration_date.py +23 -0
  97. netbox_dns/migrations/0019_dnssecpolicy_parental_agents.py +25 -0
  98. netbox_dns/migrations/0020_netbox_3_4.py +1 -1
  99. netbox_dns/migrations/0020_remove_dnssecpolicy_parental_agents_and_more.py +29 -0
  100. netbox_dns/migrations/0021_alter_record_ptr_record.py +25 -0
  101. netbox_dns/migrations/0021_record_ip_address.py +1 -1
  102. netbox_dns/migrations/0022_alter_record_ipam_ip_address.py +26 -0
  103. netbox_dns/migrations/0023_disable_ptr_false.py +27 -0
  104. netbox_dns/migrations/0024_zonetemplate_parental_agents.py +25 -0
  105. netbox_dns/migrations/0025_remove_zone_inline_signing_and_more.py +22 -0
  106. netbox_dns/migrations/0026_alter_dnssecpolicy_nsec3_opt_out.py +18 -0
  107. netbox_dns/migrations/0026_domain_registration.py +1 -1
  108. netbox_dns/migrations/0027_zone_comments.py +18 -0
  109. netbox_dns/migrations/0028_alter_zone_default_ttl_alter_zone_soa_minimum_and_more.py +54 -0
  110. netbox_dns/migrations/0028_rfc2317_fields.py +44 -0
  111. netbox_dns/migrations/0029_alter_registrationcontact_street.py +18 -0
  112. netbox_dns/migrations/0029_record_fqdn.py +30 -0
  113. netbox_dns/mixins/__init__.py +1 -0
  114. netbox_dns/mixins/object_modification.py +57 -0
  115. netbox_dns/models/__init__.py +5 -1
  116. netbox_dns/models/dnssec_key_template.py +114 -0
  117. netbox_dns/models/dnssec_policy.py +203 -0
  118. netbox_dns/models/nameserver.py +61 -30
  119. netbox_dns/models/record.py +781 -234
  120. netbox_dns/models/record_template.py +198 -0
  121. netbox_dns/models/registrar.py +34 -15
  122. netbox_dns/models/{contact.py → registration_contact.py} +72 -43
  123. netbox_dns/models/view.py +129 -9
  124. netbox_dns/models/zone.py +806 -242
  125. netbox_dns/models/zone_template.py +209 -0
  126. netbox_dns/navigation.py +176 -76
  127. netbox_dns/signals/__init__.py +0 -0
  128. netbox_dns/signals/dnssec.py +32 -0
  129. netbox_dns/signals/ipam_dnssync.py +216 -0
  130. netbox_dns/tables/__init__.py +5 -1
  131. netbox_dns/tables/dnssec_key_template.py +49 -0
  132. netbox_dns/tables/dnssec_policy.py +140 -0
  133. netbox_dns/tables/ipam_dnssync.py +12 -0
  134. netbox_dns/tables/nameserver.py +14 -17
  135. netbox_dns/tables/record.py +117 -59
  136. netbox_dns/tables/record_template.py +91 -0
  137. netbox_dns/tables/registrar.py +20 -10
  138. netbox_dns/tables/{contact.py → registration_contact.py} +22 -11
  139. netbox_dns/tables/view.py +47 -3
  140. netbox_dns/tables/zone.py +62 -31
  141. netbox_dns/tables/zone_template.py +78 -0
  142. netbox_dns/template_content.py +124 -38
  143. netbox_dns/templates/netbox_dns/dnsseckeytemplate.html +70 -0
  144. netbox_dns/templates/netbox_dns/dnssecpolicy.html +163 -0
  145. netbox_dns/templates/netbox_dns/nameserver.html +31 -28
  146. netbox_dns/templates/netbox_dns/record/managed.html +2 -1
  147. netbox_dns/templates/netbox_dns/record/related.html +17 -6
  148. netbox_dns/templates/netbox_dns/record.html +140 -93
  149. netbox_dns/templates/netbox_dns/recordtemplate.html +96 -0
  150. netbox_dns/templates/netbox_dns/registrar.html +41 -34
  151. netbox_dns/templates/netbox_dns/registrationcontact.html +76 -0
  152. netbox_dns/templates/netbox_dns/view/button.html +10 -0
  153. netbox_dns/templates/netbox_dns/view/prefix.html +44 -0
  154. netbox_dns/templates/netbox_dns/view/related.html +33 -0
  155. netbox_dns/templates/netbox_dns/view.html +62 -18
  156. netbox_dns/templates/netbox_dns/zone/base.html +6 -3
  157. netbox_dns/templates/netbox_dns/zone/child.html +6 -5
  158. netbox_dns/templates/netbox_dns/zone/child_zone.html +18 -0
  159. netbox_dns/templates/netbox_dns/zone/delegation_record.html +18 -0
  160. netbox_dns/templates/netbox_dns/zone/managed_record.html +1 -1
  161. netbox_dns/templates/netbox_dns/zone/record.html +6 -5
  162. netbox_dns/templates/netbox_dns/zone/registration.html +43 -24
  163. netbox_dns/templates/netbox_dns/zone/rfc2317_child_zone.html +18 -0
  164. netbox_dns/templates/netbox_dns/zone.html +178 -119
  165. netbox_dns/templates/netbox_dns/zonetemplate/child.html +46 -0
  166. netbox_dns/templates/netbox_dns/zonetemplate.html +124 -0
  167. netbox_dns/templatetags/netbox_dns.py +10 -0
  168. netbox_dns/urls.py +50 -210
  169. netbox_dns/utilities/__init__.py +3 -0
  170. netbox_dns/{utilities.py → utilities/conversions.py} +55 -7
  171. netbox_dns/utilities/dns.py +11 -0
  172. netbox_dns/utilities/ipam_dnssync.py +370 -0
  173. netbox_dns/validators/__init__.py +4 -0
  174. netbox_dns/validators/dns_name.py +116 -0
  175. netbox_dns/validators/dns_value.py +147 -0
  176. netbox_dns/validators/dnssec.py +148 -0
  177. netbox_dns/validators/rfc2317.py +28 -0
  178. netbox_dns/views/__init__.py +5 -1
  179. netbox_dns/views/dnssec_key_template.py +78 -0
  180. netbox_dns/views/dnssec_policy.py +146 -0
  181. netbox_dns/views/nameserver.py +34 -15
  182. netbox_dns/views/record.py +156 -15
  183. netbox_dns/views/record_template.py +93 -0
  184. netbox_dns/views/registrar.py +32 -13
  185. netbox_dns/views/registration_contact.py +101 -0
  186. netbox_dns/views/view.py +58 -14
  187. netbox_dns/views/zone.py +130 -33
  188. netbox_dns/views/zone_template.py +82 -0
  189. netbox_plugin_dns-1.4.7.dist-info/METADATA +132 -0
  190. netbox_plugin_dns-1.4.7.dist-info/RECORD +201 -0
  191. {netbox_plugin_dns-0.21.4.dist-info → netbox_plugin_dns-1.4.7.dist-info}/WHEEL +2 -1
  192. {netbox_plugin_dns-0.21.4.dist-info → netbox_plugin_dns-1.4.7.dist-info/licenses}/LICENSE +2 -1
  193. netbox_plugin_dns-1.4.7.dist-info/top_level.txt +1 -0
  194. netbox_dns/filters/__init__.py +0 -6
  195. netbox_dns/filters/nameserver.py +0 -18
  196. netbox_dns/filters/record.py +0 -53
  197. netbox_dns/filters/view.py +0 -18
  198. netbox_dns/filters/zone.py +0 -112
  199. netbox_dns/forms/contact.py +0 -211
  200. netbox_dns/graphql/contact.py +0 -19
  201. netbox_dns/graphql/nameserver.py +0 -19
  202. netbox_dns/graphql/record.py +0 -19
  203. netbox_dns/graphql/registrar.py +0 -19
  204. netbox_dns/graphql/view.py +0 -19
  205. netbox_dns/graphql/zone.py +0 -19
  206. netbox_dns/management/commands/setup_coupling.py +0 -75
  207. netbox_dns/management/commands/update_soa.py +0 -22
  208. netbox_dns/middleware.py +0 -226
  209. netbox_dns/migrations/0001_initial.py +0 -115
  210. netbox_dns/migrations/0002_zone_default_ttl.py +0 -18
  211. netbox_dns/migrations/0003_soa_managed_records.py +0 -112
  212. netbox_dns/migrations/0004_create_ptr_for_a_aaaa_records.py +0 -80
  213. netbox_dns/migrations/0005_update_ns_records.py +0 -41
  214. netbox_dns/migrations/0006_zone_soa_serial_auto.py +0 -29
  215. netbox_dns/migrations/0007_alter_zone_soa_serial_auto.py +0 -17
  216. netbox_dns/migrations/0008_zone_status_names.py +0 -21
  217. netbox_dns/migrations/0009_netbox32.py +0 -71
  218. netbox_dns/migrations/0010_update_soa_records.py +0 -58
  219. netbox_dns/migrations/0011_add_view_model.py +0 -70
  220. netbox_dns/migrations/0012_adjust_zone_and_record.py +0 -17
  221. netbox_dns/migrations/0014_add_view_description.py +0 -16
  222. netbox_dns/migrations/0016_cleanup_ptr_records.py +0 -38
  223. netbox_dns/migrations/0017_alter_record_ttl.py +0 -17
  224. netbox_dns/migrations/0018_zone_arpa_network.py +0 -51
  225. netbox_dns/migrations/0019_update_ns_ttl.py +0 -19
  226. netbox_dns/templates/netbox_dns/contact.html +0 -71
  227. netbox_dns/templates/netbox_dns/related_dns_objects.html +0 -21
  228. netbox_dns/templatetags/view_helpers.py +0 -15
  229. netbox_dns/validators.py +0 -57
  230. netbox_dns/views/contact.py +0 -83
  231. netbox_plugin_dns-0.21.4.dist-info/METADATA +0 -101
  232. netbox_plugin_dns-0.21.4.dist-info/RECORD +0 -110
netbox_dns/views/zone.py CHANGED
@@ -1,9 +1,11 @@
1
1
  from dns import name as dns_name
2
2
 
3
+ from django.utils.translation import gettext_lazy as _
4
+
3
5
  from netbox.views import generic
4
6
  from utilities.views import ViewTab, register_model_view
5
7
 
6
- from netbox_dns.filters import ZoneFilter, RecordFilter
8
+ from netbox_dns.filtersets import ZoneFilterSet, RecordFilterSet
7
9
  from netbox_dns.forms import (
8
10
  ZoneImportForm,
9
11
  ZoneForm,
@@ -15,31 +17,48 @@ from netbox_dns.tables import (
15
17
  ZoneTable,
16
18
  RecordTable,
17
19
  ManagedRecordTable,
20
+ DelegationRecordTable,
21
+ )
22
+
23
+
24
+ __all__ = (
25
+ "ZoneView",
26
+ "ZoneListView",
27
+ "ZoneEditView",
28
+ "ZoneDeleteView",
29
+ "ZoneBulkImportView",
30
+ "ZoneBulkEditView",
31
+ "ZoneBulkDeleteView",
18
32
  )
19
33
 
20
34
 
35
+ @register_model_view(Zone, "list", path="", detail=False)
21
36
  class ZoneListView(generic.ObjectListView):
22
- queryset = Zone.objects.all().prefetch_related("view", "tags")
23
- filterset = ZoneFilter
37
+ queryset = Zone.objects.prefetch_related("view", "tags")
38
+ filterset = ZoneFilterSet
24
39
  filterset_form = ZoneFilterForm
25
40
  table = ZoneTable
26
41
 
27
42
 
43
+ @register_model_view(Zone)
28
44
  class ZoneView(generic.ObjectView):
29
- queryset = Zone.objects.all().prefetch_related(
45
+ queryset = Zone.objects.prefetch_related(
30
46
  "view",
31
47
  "tags",
32
48
  "nameservers",
33
49
  "soa_mname",
34
- "record_set",
50
+ "records",
35
51
  )
36
52
 
37
53
  def get_extra_context(self, request, instance):
38
54
  ns_warnings, ns_errors = instance.check_nameservers()
55
+ mname_warning = instance.check_soa_mname()
39
56
 
40
57
  context = {
41
58
  "nameserver_warnings": ns_warnings,
42
59
  "nameserver_errors": ns_errors,
60
+ "mname_warning": mname_warning,
61
+ "parent_zone": instance.parent_zone,
43
62
  }
44
63
 
45
64
  name = dns_name.from_text(instance.name)
@@ -49,40 +68,37 @@ class ZoneView(generic.ObjectView):
49
68
  return context
50
69
 
51
70
 
71
+ @register_model_view(Zone, "add", detail=False)
72
+ @register_model_view(Zone, "edit")
52
73
  class ZoneEditView(generic.ObjectEditView):
53
- queryset = Zone.objects.all().prefetch_related(
54
- "view", "tags", "nameservers", "soa_mname"
55
- )
74
+ queryset = Zone.objects.prefetch_related("view", "tags", "nameservers", "soa_mname")
56
75
  form = ZoneForm
57
- default_return_url = "plugins:netbox_dns:zone_list"
58
76
 
59
77
 
78
+ @register_model_view(Zone, "delete")
60
79
  class ZoneDeleteView(generic.ObjectDeleteView):
61
80
  queryset = Zone.objects.all()
62
- default_return_url = "plugins:netbox_dns:zone_list"
63
81
 
64
82
 
83
+ @register_model_view(Zone, "bulk_import", detail=False)
65
84
  class ZoneBulkImportView(generic.BulkImportView):
66
- queryset = Zone.objects.all().prefetch_related(
67
- "view", "tags", "nameservers", "soa_mname"
68
- )
85
+ queryset = Zone.objects.prefetch_related("view", "tags", "nameservers", "soa_mname")
69
86
  model_form = ZoneImportForm
70
87
  table = ZoneTable
71
- default_return_url = "plugins:netbox_dns:zone_list"
72
88
 
73
89
 
90
+ @register_model_view(Zone, "bulk_edit", path="edit", detail=False)
74
91
  class ZoneBulkEditView(generic.BulkEditView):
75
- queryset = Zone.objects.all().prefetch_related(
76
- "view", "tags", "nameservers", "soa_mname"
77
- )
78
- filterset = ZoneFilter
92
+ queryset = Zone.objects.prefetch_related("view", "tags", "nameservers", "soa_mname")
93
+ filterset = ZoneFilterSet
79
94
  table = ZoneTable
80
95
  form = ZoneBulkEditForm
81
- default_return_url = "plugins:netbox_dns:zone_list"
82
96
 
83
97
 
98
+ @register_model_view(Zone, "bulk_delete", path="delete", detail=False)
84
99
  class ZoneBulkDeleteView(generic.BulkDeleteView):
85
100
  queryset = Zone.objects.all()
101
+ filterset = ZoneFilterSet
86
102
  table = ZoneTable
87
103
 
88
104
 
@@ -100,30 +116,38 @@ class ZoneRegistrationView(generic.ObjectView):
100
116
  template_name = "netbox_dns/zone/registration.html"
101
117
 
102
118
  tab = RegistrationViewTab(
103
- label="Registration",
119
+ label=_("Registration"),
104
120
  )
105
121
 
122
+ def get_extra_context(self, request, instance):
123
+ expiration_warning, expiration_error = instance.check_expiration()
124
+
125
+ context = {
126
+ "expiration_warning": expiration_warning,
127
+ "expiration_error": expiration_error,
128
+ }
129
+
130
+ return context
131
+
106
132
 
107
133
  @register_model_view(Zone, "records")
108
134
  class ZoneRecordListView(generic.ObjectChildrenView):
109
135
  queryset = Zone.objects.all()
110
136
  child_model = Record
111
137
  table = RecordTable
112
- filterset = RecordFilter
138
+ filterset = RecordFilterSet
113
139
  template_name = "netbox_dns/zone/record.html"
114
140
  hide_if_empty = True
115
141
 
116
142
  tab = ViewTab(
117
- label="Records",
143
+ label=_("Records"),
118
144
  permission="netbox_dns.view_record",
119
- badge=lambda obj: obj.record_count(managed=False),
145
+ badge=lambda obj: obj.records.filter(managed=False).count(),
120
146
  hide_if_empty=True,
121
147
  )
122
148
 
123
149
  def get_children(self, request, parent):
124
- return Record.objects.restrict(request.user, "view").filter(
125
- zone=parent, managed=False
126
- )
150
+ return parent.records.restrict(request.user, "view").filter(managed=False)
127
151
 
128
152
 
129
153
  @register_model_view(Zone, "managed_records")
@@ -131,18 +155,91 @@ class ZoneManagedRecordListView(generic.ObjectChildrenView):
131
155
  queryset = Zone.objects.all()
132
156
  child_model = Record
133
157
  table = ManagedRecordTable
134
- filterset = RecordFilter
158
+ filterset = RecordFilterSet
135
159
  template_name = "netbox_dns/zone/managed_record.html"
136
- actions = ("changelog",)
137
160
 
138
161
  tab = ViewTab(
139
- label="Managed Records",
162
+ label=_("Managed Records"),
163
+ permission="netbox_dns.view_record",
164
+ badge=lambda obj: obj.records.filter(managed=True).count(),
165
+ hide_if_empty=True,
166
+ )
167
+
168
+ def get_children(self, request, parent):
169
+ return parent.records.restrict(request.user, "view").filter(managed=True)
170
+
171
+
172
+ @register_model_view(Zone, "delegation_records")
173
+ class ZoneDelegationRecordListView(generic.ObjectChildrenView):
174
+ queryset = Zone.objects.all()
175
+ child_model = Record
176
+ table = DelegationRecordTable
177
+ filterset = RecordFilterSet
178
+ template_name = "netbox_dns/zone/delegation_record.html"
179
+
180
+ tab = ViewTab(
181
+ label=_("Delegation Records"),
182
+ permission="netbox_dns.view_record",
183
+ badge=lambda obj: obj.delegation_records.count(),
184
+ hide_if_empty=True,
185
+ )
186
+
187
+ def get_children(self, request, parent):
188
+ return parent.delegation_records.restrict(request.user, "view")
189
+
190
+
191
+ @register_model_view(Zone, "parent_delegation_records")
192
+ class ZoneParentDelegationRecordListView(generic.ObjectChildrenView):
193
+ queryset = Zone.objects.all()
194
+ child_model = Record
195
+ table = DelegationRecordTable
196
+ filterset = RecordFilterSet
197
+ template_name = "netbox_dns/zone/delegation_record.html"
198
+
199
+ tab = ViewTab(
200
+ label=_("Parent Delegation Records"),
140
201
  permission="netbox_dns.view_record",
141
- badge=lambda obj: obj.record_count(managed=True),
202
+ badge=lambda obj: obj.ancestor_delegation_records.count(),
203
+ hide_if_empty=True,
204
+ )
205
+
206
+ def get_children(self, request, parent):
207
+ return parent.ancestor_delegation_records.restrict(request.user, "view")
208
+
209
+
210
+ @register_model_view(Zone, "rfc2317_child_zones")
211
+ class ZoneRFC2317ChildZoneListView(generic.ObjectChildrenView):
212
+ queryset = Zone.objects.all()
213
+ child_model = Zone
214
+ table = ZoneTable
215
+ filterset = ZoneFilterSet
216
+ template_name = "netbox_dns/zone/rfc2317_child_zone.html"
217
+
218
+ tab = ViewTab(
219
+ label=_("RFC2317 Child Zones"),
220
+ permission="netbox_dns.view_zone",
221
+ badge=lambda obj: obj.rfc2317_child_zones.count(),
222
+ hide_if_empty=True,
223
+ )
224
+
225
+ def get_children(self, request, parent):
226
+ return parent.rfc2317_child_zones.all()
227
+
228
+
229
+ @register_model_view(Zone, "child_zones")
230
+ class ZoneChildZoneListView(generic.ObjectChildrenView):
231
+ queryset = Zone.objects.all()
232
+ child_model = Zone
233
+ table = ZoneTable
234
+ filterset = ZoneFilterSet
235
+ template_name = "netbox_dns/zone/child_zone.html"
236
+
237
+ tab = ViewTab(
238
+ label=_("Child Zones"),
239
+ permission="netbox_dns.view_zone",
240
+ badge=lambda obj: obj.child_zones.count(),
142
241
  hide_if_empty=True,
143
242
  )
144
243
 
145
244
  def get_children(self, request, parent):
146
- return Record.objects.restrict(request.user, "view").filter(
147
- zone=parent, managed=True
148
- )
245
+ return parent.child_zones
@@ -0,0 +1,82 @@
1
+ from netbox.views import generic
2
+ from utilities.views import register_model_view
3
+
4
+ from netbox_dns.models import ZoneTemplate
5
+ from netbox_dns.filtersets import ZoneTemplateFilterSet
6
+ from netbox_dns.forms import (
7
+ ZoneTemplateImportForm,
8
+ ZoneTemplateForm,
9
+ ZoneTemplateFilterForm,
10
+ ZoneTemplateBulkEditForm,
11
+ )
12
+ from netbox_dns.tables import ZoneTemplateTable, RecordTemplateDisplayTable
13
+
14
+
15
+ __all__ = (
16
+ "ZoneTemplateView",
17
+ "ZoneTemplateListView",
18
+ "ZoneTemplateEditView",
19
+ "ZoneTemplateDeleteView",
20
+ "ZoneTemplateBulkImportView",
21
+ "ZoneTemplateBulkEditView",
22
+ "ZoneTemplateBulkDeleteView",
23
+ )
24
+
25
+
26
+ @register_model_view(ZoneTemplate, "list", path="", detail=False)
27
+ class ZoneTemplateListView(generic.ObjectListView):
28
+ queryset = ZoneTemplate.objects.all()
29
+ filterset = ZoneTemplateFilterSet
30
+ filterset_form = ZoneTemplateFilterForm
31
+ table = ZoneTemplateTable
32
+
33
+
34
+ @register_model_view(ZoneTemplate)
35
+ class ZoneTemplateView(generic.ObjectView):
36
+ queryset = ZoneTemplate.objects.all()
37
+
38
+ def get_extra_context(self, request, instance):
39
+ if instance.record_templates.exists():
40
+ record_template_table = RecordTemplateDisplayTable(
41
+ data=instance.record_templates.all()
42
+ )
43
+ record_template_table.configure(request)
44
+ return {
45
+ "record_template_table": record_template_table,
46
+ }
47
+
48
+ return {}
49
+
50
+
51
+ @register_model_view(ZoneTemplate, "add", detail=False)
52
+ @register_model_view(ZoneTemplate, "edit")
53
+ class ZoneTemplateEditView(generic.ObjectEditView):
54
+ queryset = ZoneTemplate.objects.all()
55
+ form = ZoneTemplateForm
56
+
57
+
58
+ @register_model_view(ZoneTemplate, "delete")
59
+ class ZoneTemplateDeleteView(generic.ObjectDeleteView):
60
+ queryset = ZoneTemplate.objects.all()
61
+
62
+
63
+ @register_model_view(ZoneTemplate, "bulk_import", detail=False)
64
+ class ZoneTemplateBulkImportView(generic.BulkImportView):
65
+ queryset = ZoneTemplate.objects.all()
66
+ model_form = ZoneTemplateImportForm
67
+ table = ZoneTemplateTable
68
+
69
+
70
+ @register_model_view(ZoneTemplate, "bulk_edit", path="edit", detail=False)
71
+ class ZoneTemplateBulkEditView(generic.BulkEditView):
72
+ queryset = ZoneTemplate.objects.all()
73
+ filterset = ZoneTemplateFilterSet
74
+ table = ZoneTemplateTable
75
+ form = ZoneTemplateBulkEditForm
76
+
77
+
78
+ @register_model_view(ZoneTemplate, "bulk_delete", path="delete", detail=False)
79
+ class ZoneTemplateBulkDeleteView(generic.BulkDeleteView):
80
+ queryset = ZoneTemplate.objects.all()
81
+ filterset = ZoneTemplateFilterSet
82
+ table = ZoneTemplateTable
@@ -0,0 +1,132 @@
1
+ Metadata-Version: 2.4
2
+ Name: netbox-plugin-dns
3
+ Version: 1.4.7
4
+ Summary: NetBox DNS is a NetBox plugin for managing DNS data.
5
+ Author-email: Peter Eckel <pete@netbox-dns.org>
6
+ Project-URL: Homepage, https://github.com/peteeckel/netbox-plugin-dns
7
+ Project-URL: Documentation, https://github.com/peteeckel/netbox-plugin-dns/blob/main/docs/using_netbox_dns.md
8
+ Project-URL: Repository, https://github.com/peteeckel/netbox-plugin-dns
9
+ Project-URL: Issues, https://github.com/peteeckel/netbox-plugin-dns/issues
10
+ Keywords: netbox,netbox-plugin,dns
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Requires-Python: >=3.10
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: dnspython
16
+ Dynamic: license-file
17
+
18
+ # NetBox DNS
19
+ 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.
20
+
21
+ <div align="center">
22
+ <a href="https://pypi.org/project/netbox-plugin-dns/"><img src="https://img.shields.io/pypi/v/netbox-plugin-dns" alt="PyPi"/></a>
23
+ <a href="https://github.com/peteeckel/netbox-plugin-dns/stargazers"><img src="https://img.shields.io/github/stars/peteeckel/netbox-plugin-dns?style=flat" alt="Stars Badge"/></a>
24
+ <a href="https://github.com/peteeckel/netbox-plugin-dns/network/members"><img src="https://img.shields.io/github/forks/peteeckel/netbox-plugin-dns?style=flat" alt="Forks Badge"/></a>
25
+ <a href="https://github.com/peteeckel/netbox-plugin-dns/issues"><img src="https://img.shields.io/github/issues/peteeckel/netbox-plugin-dns" alt="Issues Badge"/></a>
26
+ <a href="https://github.com/peteeckel/netbox-plugin-dns/pulls"><img src="https://img.shields.io/github/issues-pr/peteeckel/netbox-plugin-dns" alt="Pull Requests Badge"/></a>
27
+ <a href="https://github.com/peteeckel/netbox-plugin-dns/graphs/contributors"><img alt="GitHub contributors" src="https://img.shields.io/github/contributors/peteeckel/netbox-plugin-dns?color=2b9348"></a>
28
+ <a href="https://github.com/peteeckel/netbox-plugin-dns/blob/master/LICENSE"><img src="https://img.shields.io/github/license/peteeckel/netbox-plugin-dns?color=2b9348" alt="License Badge"/></a>
29
+ <a href="https://github.com/psf/black"><img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="Code Style Black"/></a>
30
+ <a href="https://pepy.tech/project/netbox-plugin-dns"><img alt="Downloads" src="https://static.pepy.tech/personalized-badge/netbox-plugin-dns?period=total&left_color=BLACK&right_color=BLUE&left_text=Downloads"></a>
31
+ <a href="https://pepy.tech/project/netbox-plugin-dns"><img alt="Downloads/Week" src="https://static.pepy.tech/personalized-badge/netbox-plugin-dns?period=monthly&left_color=BLACK&right_color=BLUE&left_text=Downloads%2fMonth"></a>
32
+ <a href="https://pepy.tech/project/netbox-plugin-dns"><img alt="Downloads/Month" src="https://static.pepy.tech/personalized-badge/netbox-plugin-dns?period=weekly&left_color=BLACK&right_color=BLUE&left_text=Downloads%2fWeek"></a>
33
+ </div>
34
+
35
+ > [!WARNING]
36
+ > **As a result of some issues with NetBox Branching still under investigation, NetBox DNS is currently not compatible with the new NetBox Branching plugin.**
37
+ > This affects multiple aspects of the branching functionality, and currently there is no workaround. Do not try to use NetBox Branching together with NetBox DNS until these issues are resolved.
38
+ > This warning will be updated as soon as the situation is resolved.
39
+
40
+ ## Objectives
41
+ NetBox DNS is designed to be the 'DNS Source of Truth' analogous to NetBox being the 'Network Source of Truth'.
42
+
43
+ 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.
44
+
45
+ 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:
46
+
47
+ * Validation of record names and values
48
+ * Automatic maintenance of PTR records for IPv6 and IPv4 address records
49
+ * Automatic generation of SOA records, optionally including the serial number of the zone data
50
+ * Validation of changes to the SOA SERIAL number, whether they are done automatically or manually
51
+ * Validation of record types such as CNAME and singletons, to ensure DNS zone validity
52
+ * Support for [RFC 2317](https://datatracker.ietf.org/doc/html/rfc2317) delegation of PTR zones for IPv4 subnets longer than 24 bits
53
+ * 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
54
+ * 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
55
+ * DNSSEC support for storing configuration data relevant to DNSSEC operation in NetBox DNS
56
+
57
+ Other main features include:
58
+
59
+ * Support for BIND views, providing lightweight namespaces for zones
60
+ * Support for IDN, including the validation of punycode names
61
+ * Full support for the NetBox REST and GraphQL APIs
62
+ * Support for all major NetBox features such as global search, tenancy, change logs, tagging, journaling etc.
63
+
64
+ ## Non-objectives
65
+ 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.
66
+
67
+ 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.
68
+
69
+ For RFC9432 compatible DNS Servers like BIND, a related plugin [netbox-plugin-bind-provisioner](https://github.com/Suraxius/netbox-plugin-bind-provisioner) provides direct integration using DNS native zone distribution.
70
+
71
+ ## Requirements
72
+
73
+ * NetBox 4.3.0 or higher
74
+ * Python 3.10 or higher
75
+
76
+ ## Compatibility with NetBox Versions
77
+
78
+ NetBox Version | NetBox DNS Version | Comment
79
+ -------------- | ------------------ | -------
80
+ 3.5 | 0.22 |
81
+ 3.6 | 0.22 |
82
+ 3.7 | 0.22 |
83
+ 4.0 - 4.1 | 1.0 | Supports legacy IPAM Coupling
84
+ 4.0 - 4.1 | 1.1 | Supports IPAM DNSsync
85
+ 4.2 | 1.2 |
86
+ 4.3 | 1.3 - 1.4 |
87
+ 4.4 | 1.4 |
88
+
89
+ ## Installation & Configuration
90
+
91
+ ### Installation
92
+
93
+ ```
94
+ $ source /opt/netbox/venv/bin/activate
95
+ (venv) $ pip install netbox-plugin-dns
96
+ ```
97
+
98
+ ### NetBox Configuration
99
+
100
+ Add the plugin to the NetBox config. `~/netbox/configuration.py`
101
+
102
+ ```python
103
+ PLUGINS = [
104
+ "netbox_dns",
105
+ ]
106
+ ```
107
+
108
+ To permanently keep the plugin installed when updating NetBox via `upgrade.sh`:
109
+
110
+ ```
111
+ echo netbox-plugin-dns >> ~/netbox/local_requirements.txt
112
+ ```
113
+
114
+ To add the required netbox_dns tables to your database run the following command from your NetBox directory:
115
+
116
+ ```
117
+ ./manage.py migrate
118
+ ```
119
+
120
+ Full documentation on using plugins with NetBox: [Using Plugins - NetBox Documentation](https://netbox.readthedocs.io/en/stable/plugins/)
121
+
122
+ ## Contribute
123
+
124
+ Contributions are always welcome! Please see the [Contribution Guidelines](CONTRIBUTING.md)
125
+
126
+ ## Documentation
127
+
128
+ For further information, please refer to the full documentation: [Using NetBox DNS](docs/using_netbox_dns.md)
129
+
130
+ ## License
131
+
132
+ MIT