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
@@ -0,0 +1,216 @@
1
+ from netaddr import IPNetwork
2
+
3
+ from django.conf import settings
4
+ from django.dispatch import receiver
5
+ from django.db.models.signals import pre_delete, pre_save, post_save, m2m_changed
6
+ from django.core.exceptions import ValidationError
7
+ from django.utils.translation import gettext as _
8
+
9
+ from netbox.context import current_request
10
+ from netbox.signals import post_clean
11
+ from ipam.models import IPAddress, Prefix
12
+ from utilities.exceptions import AbortRequest
13
+
14
+ from netbox_dns.utilities import (
15
+ check_dns_records,
16
+ check_record_permission,
17
+ update_dns_records,
18
+ delete_dns_records,
19
+ get_views_by_prefix,
20
+ get_ip_addresses_by_prefix,
21
+ )
22
+
23
+ DNSSYNC_CUSTOM_FIELDS = {
24
+ "ipaddress_dns_disabled": False,
25
+ "ipaddress_dns_record_ttl": None,
26
+ "ipaddress_dns_record_disable_ptr": False,
27
+ }
28
+
29
+ IPADDRESS_ACTIVE_STATUS = settings.PLUGINS_CONFIG["netbox_dns"][
30
+ "dnssync_ipaddress_active_status"
31
+ ]
32
+ ENFORCE_UNIQUE_RECORDS = settings.PLUGINS_CONFIG["netbox_dns"]["enforce_unique_records"]
33
+
34
+
35
+ @receiver(post_clean, sender=IPAddress)
36
+ def ipam_dnssync_ipaddress_post_clean(instance, **kwargs):
37
+ if not instance.dns_name:
38
+ return
39
+
40
+ if not isinstance(instance.address, IPNetwork):
41
+ return
42
+
43
+ if instance.custom_field_data.get("ipaddress_dns_disabled"):
44
+ return
45
+
46
+ # +
47
+ # Check for uniqueness of IP address and dns_name. If unique records are
48
+ # enforced, report an error when trying to create the same IP address with
49
+ # the same dns_name. Ignore existing IP addresses that have their CF
50
+ # "ipaddress_dns_disabled" set to "True".
51
+ # -
52
+ duplicate_addresses = IPAddress.objects.filter(
53
+ address=instance.address,
54
+ vrf=instance.vrf,
55
+ dns_name=instance.dns_name,
56
+ status__in=IPADDRESS_ACTIVE_STATUS,
57
+ )
58
+ if not instance._state.adding:
59
+ duplicate_addresses = duplicate_addresses.exclude(pk=instance.pk)
60
+
61
+ if ENFORCE_UNIQUE_RECORDS and instance.status in IPADDRESS_ACTIVE_STATUS:
62
+ for ip_address in duplicate_addresses.only("custom_field_data"):
63
+ if not ip_address.custom_field_data.get("ipaddress_dns_disabled"):
64
+ raise ValidationError(
65
+ {
66
+ "dns_name": _(
67
+ "Unique DNS records are enforced and there is already "
68
+ "an active IP address {address} with DNS name {name}. Please choose "
69
+ "a different name or disable record creation for this IP address."
70
+ ).format(address=instance.address, name=instance.dns_name)
71
+ }
72
+ )
73
+
74
+ # +
75
+ # Check NetBox DNS record permission for changes to IPAddress custom fields
76
+ # -
77
+ if (current_request.get()) is not None:
78
+ cf_data = instance.custom_field_data
79
+ if (
80
+ not instance._state.adding
81
+ and any(
82
+ (
83
+ cf_data.get(cf, cf_default)
84
+ != IPAddress.objects.get(pk=instance.pk).custom_field_data.get(
85
+ cf, cf_default
86
+ )
87
+ for cf, cf_default in DNSSYNC_CUSTOM_FIELDS.items()
88
+ )
89
+ )
90
+ and not check_record_permission()
91
+ ) or (
92
+ instance._state.adding
93
+ and any(
94
+ (
95
+ cf_data.get(cf, cf_default) != cf_default
96
+ for cf, cf_default in DNSSYNC_CUSTOM_FIELDS.items()
97
+ )
98
+ )
99
+ and not check_record_permission(change=False, delete=False)
100
+ ):
101
+ raise ValidationError(
102
+ _("You do not have permission to alter DNSsync custom fields")
103
+ )
104
+
105
+ try:
106
+ check_dns_records(instance)
107
+ except ValidationError as exc:
108
+ raise ValidationError({"dns_name": exc.messages})
109
+
110
+
111
+ @receiver(pre_delete, sender=IPAddress)
112
+ def ipam_dnssync_ipaddress_pre_delete(instance, **kwargs):
113
+ delete_dns_records(instance)
114
+
115
+
116
+ @receiver(pre_save, sender=IPAddress)
117
+ def ipam_dnssync_ipaddress_pre_save(instance, **kwargs):
118
+ check_dns_records(instance)
119
+
120
+
121
+ @receiver(post_save, sender=IPAddress)
122
+ def ipam_dnssync_ipaddress_post_save(instance, **kwargs):
123
+ update_dns_records(instance)
124
+
125
+
126
+ @receiver(pre_save, sender=Prefix)
127
+ def ipam_dnssync_prefix_pre_save(instance, **kwargs):
128
+ """
129
+ Changes that modify the prefix hierarchy cannot be validated properly before
130
+ commiting them. So the solution in this case is to ask the user to deassign
131
+ the prefix from any views it is assigned to and retry.
132
+ """
133
+ request = current_request.get()
134
+
135
+ if instance._state.adding or not instance.netbox_dns_views.exists():
136
+ return
137
+
138
+ saved_prefix = Prefix.objects.prefetch_related("netbox_dns_views").get(
139
+ pk=instance.pk
140
+ )
141
+ if saved_prefix.prefix != instance.prefix or saved_prefix.vrf != instance.vrf:
142
+ dns_views = ", ".join([view.name for view in instance.netbox_dns_views.all()])
143
+ if request is not None:
144
+ raise AbortRequest(
145
+ _(
146
+ "This prefix is currently assigned to the following DNS views: {views}. "
147
+ "Please deassign it from these views before making changes to the prefix "
148
+ "or VRF."
149
+ ).format(views=dns_views)
150
+ )
151
+
152
+ raise ValidationError(
153
+ _(
154
+ "Prefix is assigned to DNS views {views}. Prefix and VRF must not be changed"
155
+ ).format(views=dns_views)
156
+ )
157
+
158
+
159
+ @receiver(pre_delete, sender=Prefix)
160
+ def ipam_dnssync_prefix_pre_delete(instance, **kwargs):
161
+ parent = instance.get_parents().last()
162
+ request = current_request.get()
163
+
164
+ if parent is not None and get_views_by_prefix(instance) != get_views_by_prefix(
165
+ parent
166
+ ):
167
+ try:
168
+ for prefix in instance.get_children().filter(
169
+ _depth=instance.depth + 1, netbox_dns_views__isnull=True
170
+ ):
171
+ for ip_address in get_ip_addresses_by_prefix(prefix):
172
+ check_dns_records(ip_address)
173
+ except ValidationError as exc:
174
+ if request is not None:
175
+ raise AbortRequest(
176
+ _(
177
+ "Prefix deletion would cause DNS errors: {errors}. Please review "
178
+ "DNS View assignments for this and the parent prefix"
179
+ ).format(errors=exc.messages[0])
180
+ )
181
+ else:
182
+ raise exc
183
+
184
+ # +
185
+ # CAUTION: This only works because the NetBox workaround for an ancient
186
+ # Django bug (see https://code.djangoproject.com/ticket/17688) has already
187
+ # removed the relations between the prefix and the views when this signal
188
+ # handler runs.
189
+ #
190
+ # Should anything be fixed, this code will stop working and need to be
191
+ # revisited.
192
+ #
193
+ # The NetBox workaround only works for requests, not for model level
194
+ # operations. The following code replicates it for non-requests.
195
+ # -
196
+ if request is None:
197
+ for view in instance.netbox_dns_views.all():
198
+ view.snapshot()
199
+ view.prefixes.remove(instance)
200
+
201
+ for ip_address in get_ip_addresses_by_prefix(instance):
202
+ update_dns_records(ip_address)
203
+
204
+
205
+ @receiver(m2m_changed, sender=Prefix.netbox_dns_views.through)
206
+ def ipam_dnssync_view_prefix_changed(**kwargs):
207
+ action = kwargs.get("action")
208
+
209
+ check_view = action != "post_remove"
210
+
211
+ ip_addresses = IPAddress.objects.none()
212
+ for prefix in Prefix.objects.filter(pk__in=kwargs.get("pk_set")):
213
+ ip_addresses |= get_ip_addresses_by_prefix(prefix, check_view=check_view)
214
+
215
+ for ip_address in ip_addresses.distinct():
216
+ update_dns_records(ip_address)
@@ -2,5 +2,9 @@ from .view import *
2
2
  from .zone import *
3
3
  from .nameserver import *
4
4
  from .record import *
5
- from .contact import *
5
+ from .registration_contact import *
6
6
  from .registrar import *
7
+ from .zone_template import *
8
+ from .record_template import *
9
+ from .dnssec_key_template import *
10
+ from .dnssec_policy import *
@@ -0,0 +1,49 @@
1
+ import django_tables2 as tables
2
+ from django.utils.translation import gettext_lazy as _
3
+
4
+ from netbox.tables import (
5
+ NetBoxTable,
6
+ ChoiceFieldColumn,
7
+ TagColumn,
8
+ )
9
+ from tenancy.tables import TenancyColumnsMixin
10
+
11
+ from netbox_dns.models import DNSSECKeyTemplate
12
+
13
+
14
+ __all__ = ("DNSSECKeyTemplateTable",)
15
+
16
+
17
+ class DNSSECKeyTemplateTable(TenancyColumnsMixin, NetBoxTable):
18
+ class Meta(NetBoxTable.Meta):
19
+ model = DNSSECKeyTemplate
20
+
21
+ fields = ("description",)
22
+
23
+ default_columns = (
24
+ "name",
25
+ "type",
26
+ "algorithm",
27
+ "key_size",
28
+ "tags",
29
+ )
30
+
31
+ name = tables.Column(
32
+ verbose_name=_("Name"),
33
+ linkify=True,
34
+ )
35
+ type = ChoiceFieldColumn(
36
+ verbose_name=_("Key Type"),
37
+ )
38
+ lifetime = tables.Column(
39
+ verbose_name=_("Lifetime"),
40
+ )
41
+ algorithm = ChoiceFieldColumn(
42
+ verbose_name=_("Algorithm"),
43
+ )
44
+ key_size = ChoiceFieldColumn(
45
+ verbose_name=_("Key Size"),
46
+ )
47
+ tags = TagColumn(
48
+ url_name="plugins:netbox_dns:dnsseckeytemplate_list",
49
+ )
@@ -0,0 +1,140 @@
1
+ import django_tables2 as tables
2
+ from django.utils.translation import gettext_lazy as _
3
+
4
+
5
+ from netbox.tables import (
6
+ NetBoxTable,
7
+ TagColumn,
8
+ ChoiceFieldColumn,
9
+ ActionsColumn,
10
+ BooleanColumn,
11
+ columns,
12
+ )
13
+ from tenancy.tables import TenancyColumnsMixin
14
+
15
+ from netbox_dns.models import DNSSECPolicy
16
+
17
+
18
+ __all__ = (
19
+ "DNSSECPolicyTable",
20
+ "DNSSECPolicyDisplayTable",
21
+ )
22
+
23
+
24
+ class DNSSECPolicyTable(TenancyColumnsMixin, NetBoxTable):
25
+ class Meta(NetBoxTable.Meta):
26
+ model = DNSSECPolicy
27
+
28
+ fields = (
29
+ "description",
30
+ "inline_signing",
31
+ )
32
+
33
+ default_columns = (
34
+ "name",
35
+ "description",
36
+ "status",
37
+ "inline_signing",
38
+ "use_nsec3",
39
+ "tags",
40
+ )
41
+
42
+ name = tables.Column(
43
+ verbose_name=_("Name"),
44
+ linkify=True,
45
+ )
46
+ status = ChoiceFieldColumn(
47
+ verbose_name=_("Status"),
48
+ )
49
+ dnskey_ttl = tables.Column(
50
+ verbose_name=_("DNSKEY TTL"),
51
+ )
52
+ purge_keys = tables.Column(
53
+ verbose_name=_("Purge Keys"),
54
+ )
55
+ publish_safety = tables.Column(
56
+ verbose_name=_("Publish Safety"),
57
+ )
58
+ retire_safety = tables.Column(
59
+ verbose_name=_("Retire Safety"),
60
+ )
61
+ signatures_jitter = tables.Column(
62
+ verbose_name=_("Signatures Jitter"),
63
+ )
64
+ signatures_refresh = tables.Column(
65
+ verbose_name=_("Signatures Refresh"),
66
+ )
67
+ signatures_validity = tables.Column(
68
+ verbose_name=_("Signatures Validity"),
69
+ )
70
+ signatures_validity_dnskey = tables.Column(
71
+ verbose_name=_("Signatures Validity (DNSKEY)"),
72
+ )
73
+ max_zone_ttl = tables.Column(
74
+ verbose_name=_("Max Zone TTL"),
75
+ )
76
+ dnskey_ttl = tables.Column(
77
+ verbose_name=_("DNSKEY TTL"),
78
+ )
79
+ zone_propagation_delay = tables.Column(
80
+ verbose_name=_("Zone Propagation Delay"),
81
+ )
82
+ create_cdnskey = BooleanColumn(
83
+ verbose_name=_("Create CDNSKEY"),
84
+ )
85
+ cds_digest_types = columns.ArrayColumn(
86
+ verbose_name=_("CDS Digest Types"),
87
+ )
88
+ parent_ds_ttl = tables.Column(
89
+ verbose_name=_("Parent DS TTL"),
90
+ )
91
+ parent_propagation_delay = tables.Column(
92
+ verbose_name=_("Parent Propagation Delay"),
93
+ )
94
+ use_nsec3 = BooleanColumn(
95
+ verbose_name=_("Use NSEC3"),
96
+ )
97
+ nsec3_iterations = tables.Column(
98
+ verbose_name=_("NSEC3 Iterations"),
99
+ )
100
+ nsec3_opt_out = BooleanColumn(
101
+ verbose_name=_("NSEC3 Opt Out"),
102
+ )
103
+ nsec3_salt_size = tables.Column(
104
+ verbose_name=_("NSEC3 Salt Size"),
105
+ )
106
+ tags = TagColumn(
107
+ url_name="plugins:netbox_dns:dnssecpolicy_list",
108
+ )
109
+
110
+
111
+ class DNSSECPolicyDisplayTable(TenancyColumnsMixin, NetBoxTable):
112
+ class Meta(NetBoxTable.Meta):
113
+ model = DNSSECPolicy
114
+
115
+ fields = ("description",)
116
+
117
+ default_columns = (
118
+ "name",
119
+ "description",
120
+ "status",
121
+ "tags",
122
+ )
123
+
124
+ name = tables.Column(
125
+ verbose_name=_("Name"),
126
+ linkify=True,
127
+ )
128
+ status = ChoiceFieldColumn(
129
+ verbose_name=_("Status"),
130
+ )
131
+ create_cdnskey = BooleanColumn(
132
+ verbose_name=_("Create CDNSKEY"),
133
+ )
134
+ use_nsec3 = BooleanColumn(
135
+ verbose_name=_("Use NSEC3"),
136
+ )
137
+ tags = TagColumn(
138
+ url_name="plugins:netbox_dns:dnssecpolicy_list",
139
+ )
140
+ actions = ActionsColumn(actions="")
@@ -0,0 +1,12 @@
1
+ import django_tables2 as tables
2
+ from django.utils.translation import gettext_lazy as _
3
+
4
+ from ipam.tables import PrefixTable
5
+ from utilities.tables import register_table_column
6
+
7
+ views = tables.ManyToManyColumn(
8
+ verbose_name=_("DNS Views"),
9
+ linkify_item=True,
10
+ )
11
+
12
+ register_table_column(views, "netbox_dns_views", PrefixTable)
@@ -1,4 +1,5 @@
1
1
  import django_tables2 as tables
2
+ from django.utils.translation import gettext_lazy as _
2
3
 
3
4
  from netbox.tables import NetBoxTable, TagColumn
4
5
  from tenancy.tables import TenancyColumnsMixin
@@ -6,10 +7,22 @@ from tenancy.tables import TenancyColumnsMixin
6
7
  from netbox_dns.models import NameServer
7
8
 
8
9
 
10
+ __all__ = ("NameServerTable",)
11
+
12
+
9
13
  class NameServerTable(TenancyColumnsMixin, NetBoxTable):
10
- """Table for displaying NameServer objects."""
14
+ class Meta(NetBoxTable.Meta):
15
+ model = NameServer
16
+
17
+ fields = ("description",)
18
+
19
+ default_columns = (
20
+ "name",
21
+ "tags",
22
+ )
11
23
 
12
24
  name = tables.Column(
25
+ verbose_name=_("Name"),
13
26
  linkify=True,
14
27
  )
15
28
  tags = TagColumn(
@@ -18,19 +31,3 @@ class NameServerTable(TenancyColumnsMixin, NetBoxTable):
18
31
 
19
32
  def render_name(self, value, record):
20
33
  return record.display_name
21
-
22
- class Meta(NetBoxTable.Meta):
23
- model = NameServer
24
- fields = (
25
- "pk",
26
- "name",
27
- "description",
28
- "tags",
29
- "tenant",
30
- "tenant_group",
31
- )
32
- default_columns = (
33
- "pk",
34
- "name",
35
- "tags",
36
- )