netbox-plugin-dns 0.22.5__tar.gz → 0.22.6__tar.gz

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 (118) hide show
  1. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/PKG-INFO +1 -1
  2. netbox_plugin_dns-0.22.6/netbox_dns/__init__.py +50 -0
  3. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/models/record.py +10 -0
  4. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/templates/netbox_dns/record.html +6 -22
  5. netbox_plugin_dns-0.22.6/netbox_dns/views/record.py +159 -0
  6. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/pyproject.toml +1 -1
  7. netbox_plugin_dns-0.22.5/netbox_dns/__init__.py +0 -87
  8. netbox_plugin_dns-0.22.5/netbox_dns/views/record.py +0 -85
  9. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/LICENSE +0 -0
  10. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/README.md +0 -0
  11. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/api/nested_serializers.py +0 -0
  12. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/api/serializers.py +0 -0
  13. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/api/urls.py +0 -0
  14. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/api/views.py +0 -0
  15. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/apps.py +0 -0
  16. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/fields/__init__.py +0 -0
  17. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/fields/address.py +0 -0
  18. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/fields/network.py +0 -0
  19. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/fields/rfc2317.py +0 -0
  20. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/filters/__init__.py +0 -0
  21. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/filters/contact.py +0 -0
  22. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/filters/nameserver.py +0 -0
  23. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/filters/record.py +0 -0
  24. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/filters/registrar.py +0 -0
  25. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/filters/view.py +0 -0
  26. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/filters/zone.py +0 -0
  27. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/forms/__init__.py +0 -0
  28. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/forms/contact.py +0 -0
  29. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/forms/nameserver.py +0 -0
  30. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/forms/record.py +0 -0
  31. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/forms/registrar.py +0 -0
  32. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/forms/view.py +0 -0
  33. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/forms/zone.py +0 -0
  34. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/graphql/__init__.py +0 -0
  35. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/graphql/contact.py +0 -0
  36. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/graphql/nameserver.py +0 -0
  37. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/graphql/record.py +0 -0
  38. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/graphql/registrar.py +0 -0
  39. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/graphql/schema.py +0 -0
  40. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/graphql/view.py +0 -0
  41. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/graphql/zone.py +0 -0
  42. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/management/commands/cleanup_database.py +0 -0
  43. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/management/commands/cleanup_rrset_ttl.py +0 -0
  44. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/management/commands/setup_coupling.py +0 -0
  45. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/management/commands/update_soa.py +0 -0
  46. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/migrations/0001_initial.py +0 -0
  47. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/migrations/0001_squashed_netbox_dns_0_15.py +0 -0
  48. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/migrations/0002_zone_default_ttl.py +0 -0
  49. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/migrations/0003_soa_managed_records.py +0 -0
  50. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/migrations/0004_create_ptr_for_a_aaaa_records.py +0 -0
  51. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/migrations/0005_update_ns_records.py +0 -0
  52. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/migrations/0006_zone_soa_serial_auto.py +0 -0
  53. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/migrations/0007_alter_zone_soa_serial_auto.py +0 -0
  54. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/migrations/0008_zone_status_names.py +0 -0
  55. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/migrations/0009_netbox32.py +0 -0
  56. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/migrations/0010_update_soa_records.py +0 -0
  57. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/migrations/0011_add_view_model.py +0 -0
  58. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/migrations/0012_adjust_zone_and_record.py +0 -0
  59. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/migrations/0013_add_nameserver_zone_record_description.py +0 -0
  60. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/migrations/0014_add_view_description.py +0 -0
  61. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/migrations/0015_add_record_status.py +0 -0
  62. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/migrations/0016_cleanup_ptr_records.py +0 -0
  63. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/migrations/0017_alter_record_ttl.py +0 -0
  64. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/migrations/0018_zone_arpa_network.py +0 -0
  65. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/migrations/0019_update_ns_ttl.py +0 -0
  66. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/migrations/0020_netbox_3_4.py +0 -0
  67. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/migrations/0021_record_ip_address.py +0 -0
  68. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/migrations/0022_search.py +0 -0
  69. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/migrations/0023_alter_record_value.py +0 -0
  70. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/migrations/0024_tenancy.py +0 -0
  71. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/migrations/0025_ipam_coupling_cf.py +0 -0
  72. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/migrations/0026_domain_registration.py +0 -0
  73. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/migrations/0027_alter_registrar_iana_id.py +0 -0
  74. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/migrations/0028_rfc2317_fields.py +0 -0
  75. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/migrations/__init__.py +0 -0
  76. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/models/__init__.py +0 -0
  77. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/models/contact.py +0 -0
  78. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/models/nameserver.py +0 -0
  79. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/models/registrar.py +0 -0
  80. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/models/view.py +0 -0
  81. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/models/zone.py +0 -0
  82. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/navigation.py +0 -0
  83. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/signals/__init__.py +0 -0
  84. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/signals/ipam_coupling.py +0 -0
  85. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/tables/__init__.py +0 -0
  86. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/tables/contact.py +0 -0
  87. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/tables/nameserver.py +0 -0
  88. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/tables/record.py +0 -0
  89. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/tables/registrar.py +0 -0
  90. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/tables/view.py +0 -0
  91. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/tables/zone.py +0 -0
  92. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/template_content.py +0 -0
  93. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/templates/netbox_dns/contact.html +0 -0
  94. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/templates/netbox_dns/nameserver.html +0 -0
  95. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/templates/netbox_dns/record/managed.html +0 -0
  96. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/templates/netbox_dns/record/related.html +0 -0
  97. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/templates/netbox_dns/registrar.html +0 -0
  98. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/templates/netbox_dns/related_dns_objects.html +0 -0
  99. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/templates/netbox_dns/view.html +0 -0
  100. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/templates/netbox_dns/zone/base.html +0 -0
  101. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/templates/netbox_dns/zone/child.html +0 -0
  102. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/templates/netbox_dns/zone/managed_record.html +0 -0
  103. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/templates/netbox_dns/zone/record.html +0 -0
  104. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/templates/netbox_dns/zone/registration.html +0 -0
  105. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/templates/netbox_dns/zone/rfc2317_child_zone.html +0 -0
  106. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/templates/netbox_dns/zone.html +0 -0
  107. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/urls.py +0 -0
  108. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/utilities/__init__.py +0 -0
  109. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/utilities/ipam_coupling.py +0 -0
  110. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/validators/__init__.py +0 -0
  111. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/validators/dns_name.py +0 -0
  112. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/validators/rfc2317.py +0 -0
  113. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/views/__init__.py +0 -0
  114. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/views/contact.py +0 -0
  115. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/views/nameserver.py +0 -0
  116. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/views/registrar.py +0 -0
  117. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/views/view.py +0 -0
  118. {netbox_plugin_dns-0.22.5 → netbox_plugin_dns-0.22.6}/netbox_dns/views/zone.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: netbox-plugin-dns
3
- Version: 0.22.5
3
+ Version: 0.22.6
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
@@ -0,0 +1,50 @@
1
+ import sys
2
+
3
+ from extras.plugins import PluginConfig
4
+ from django.db.utils import OperationalError
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
12
+
13
+ __version__ = "0.22.6"
14
+
15
+
16
+ class DNSConfig(PluginConfig):
17
+ name = "netbox_dns"
18
+ verbose_name = "NetBox DNS"
19
+ description = "NetBox plugin for DNS data"
20
+ min_version = "3.5.0"
21
+ version = __version__
22
+ author = "Peter Eckel"
23
+ author_email = "pete@netbox-dns.org"
24
+ required_settings = []
25
+ default_settings = {
26
+ "zone_default_ttl": 86400,
27
+ "zone_soa_serial_auto": True,
28
+ "zone_soa_serial": 1,
29
+ "zone_soa_refresh": 43200,
30
+ "zone_soa_retry": 7200,
31
+ "zone_soa_expire": 2419200,
32
+ "zone_soa_minimum": 3600,
33
+ "feature_ipam_coupling": False,
34
+ "tolerate_underscores_in_hostnames": False,
35
+ "tolerate_leading_underscore_types": [
36
+ "TXT",
37
+ "SRV",
38
+ ],
39
+ "tolerate_non_rfc1035_types": [],
40
+ "enable_root_zones": False,
41
+ "enforce_unique_records": True,
42
+ "enforce_unique_rrset_ttl": True,
43
+ }
44
+ base_url = "netbox-dns"
45
+
46
+
47
+ #
48
+ # Initialize plugin config
49
+ #
50
+ config = DNSConfig
@@ -241,6 +241,16 @@ class Record(NetBoxModel):
241
241
 
242
242
  return name.to_text()
243
243
 
244
+ @property
245
+ def value_fqdn(self):
246
+ if self.type != RecordTypeChoices.CNAME:
247
+ return None
248
+
249
+ zone = dns_name.from_text(self.zone.name)
250
+ value_fqdn = dns_name.from_text(self.value, origin=zone)
251
+
252
+ return value_fqdn.to_text()
253
+
244
254
  @property
245
255
  def address_from_name(self):
246
256
  prefix = arpa_to_prefix(self.fqdn)
@@ -112,12 +112,6 @@
112
112
  <td><a href="{% url 'ipam:ipaddress' pk=object.ipam_ip_address.pk %}">{{ object.ipam_ip_address }}</td>
113
113
  </tr>
114
114
  {% endif %}
115
- {% if object.rfc2317_cname_record %}
116
- <tr>
117
- <th scope="row">RFC2317 CNAME Record</th>
118
- <td><a href="{% url 'plugins:netbox_dns:record' pk=object.rfc2317_cname_record.pk %}">{{ object.rfc2317_cname_record }}</td>
119
- </tr>
120
- {% endif %}
121
115
  <tr>
122
116
  <th scope="row">Status</th>
123
117
  <td>{% badge object.get_status_display bg_color=object.get_status_color %}</td>
@@ -131,23 +125,13 @@
131
125
  </table>
132
126
  </div>
133
127
  </div>
134
- {% if object.rfc2317_ptr_records.all|length %}
128
+ {% if cname_target_table and cname_target_table.rows|length > 0 %}
135
129
  <div class="card">
136
- <h5 class="card-header">RFC2317 Targets</h5>
137
- <div class="card-body">
138
- <table class="table table-hover attr-table">
139
- <tr>
140
- <th>Address Record</th>
141
- <th>PTR Record</th>
142
- </tr>
143
- {% for record in object.rfc2317_ptr_records.all %}
144
- <tr>
145
- <td><a href="{% url 'plugins:netbox_dns:record' pk=record.address_record.pk %}">{{ record.address_record }}</td>
146
- <td><a href="{% url 'plugins:netbox_dns:record' pk=record.pk %}">{{ record }}</td>
147
- </td>
148
- {% endfor %}
149
- </table>
150
- </div>
130
+ {% include 'inc/panel_table.html' with table=cname_target_table heading='CNAME Targets' %}
131
+ </div>
132
+ {% elif cname_table and cname_table.rows|length > 0 %}
133
+ <div class="card">
134
+ {% include 'inc/panel_table.html' with table=cname_table heading='CNAMEs' %}
151
135
  </div>
152
136
  {% endif %}
153
137
  {% if not object.managed %}
@@ -0,0 +1,159 @@
1
+ from dns import name as dns_name
2
+
3
+ from django.db.models import Q
4
+ from django.db.models.functions import Length
5
+
6
+ from netbox.views import generic
7
+
8
+ from netbox_dns.filters import RecordFilter
9
+ from netbox_dns.forms import (
10
+ RecordImportForm,
11
+ RecordFilterForm,
12
+ RecordForm,
13
+ RecordBulkEditForm,
14
+ )
15
+ from netbox_dns.models import Record, RecordTypeChoices, Zone
16
+ from netbox_dns.tables import RecordTable, ManagedRecordTable, RelatedRecordTable
17
+ from netbox_dns.utilities import value_to_unicode
18
+
19
+
20
+ class RecordListView(generic.ObjectListView):
21
+ queryset = Record.objects.filter(managed=False).prefetch_related(
22
+ "zone", "ptr_record"
23
+ )
24
+ filterset = RecordFilter
25
+ filterset_form = RecordFilterForm
26
+ table = RecordTable
27
+
28
+
29
+ class ManagedRecordListView(generic.ObjectListView):
30
+ queryset = Record.objects.filter(managed=True).prefetch_related(
31
+ "zone", "address_record"
32
+ )
33
+ filterset = RecordFilter
34
+ filterset_form = RecordFilterForm
35
+ table = ManagedRecordTable
36
+ actions = ("export",)
37
+ template_name = "netbox_dns/record/managed.html"
38
+
39
+
40
+ class RecordView(generic.ObjectView):
41
+ queryset = Record.objects.all().prefetch_related("zone", "ptr_record")
42
+
43
+ def get_value_records(self, instance):
44
+ value_fqdn = dns_name.from_text(instance.value_fqdn)
45
+ value_zone_names = [
46
+ value_fqdn.split(length)[1].to_text().rstrip(".")
47
+ for length in range(2, len(value_fqdn))
48
+ ]
49
+
50
+ value_zone = (
51
+ Zone.objects.filter(instance.zone.view_filter, name__in=value_zone_names)
52
+ .order_by(Length("name").desc())
53
+ .first()
54
+ )
55
+ if not value_zone:
56
+ return None
57
+
58
+ value_name = value_fqdn.relativize(dns_name.from_text(value_zone.name))
59
+ cname_targets = Record.objects.filter(zone=value_zone, name=value_name)
60
+
61
+ if cname_targets:
62
+ return RelatedRecordTable(
63
+ data=cname_targets,
64
+ )
65
+
66
+ return None
67
+
68
+ def get_cname_records(self, instance):
69
+ view_filter = (
70
+ Q(zone__view__isnull=True)
71
+ if instance.zone.view is None
72
+ else Q(zone__view=instance.zone.view)
73
+ )
74
+ cname_records = set(
75
+ Record.objects.filter(
76
+ view_filter, value=instance.fqdn, type=RecordTypeChoices.CNAME
77
+ )
78
+ )
79
+
80
+ fqdn = dns_name.from_text(instance.fqdn)
81
+ parent_zone_names = [
82
+ fqdn.split(length)[1].to_text().rstrip(".")
83
+ for length in range(1, len(fqdn))
84
+ ]
85
+
86
+ parent_zones = Zone.objects.filter(
87
+ instance.zone.view_filter, name__in=parent_zone_names
88
+ )
89
+
90
+ for parent_zone in parent_zones:
91
+ parent_cname_records = Record.objects.filter(
92
+ view_filter, type=RecordTypeChoices.CNAME, zone=parent_zone
93
+ )
94
+ cname_records = cname_records.union(
95
+ set(
96
+ record
97
+ for record in parent_cname_records
98
+ if record.value_fqdn == instance.fqdn
99
+ )
100
+ )
101
+
102
+ if cname_records:
103
+ return RelatedRecordTable(
104
+ data=cname_records,
105
+ )
106
+
107
+ return None
108
+
109
+ def get_extra_context(self, request, instance):
110
+ context = {}
111
+
112
+ name = dns_name.from_text(instance.name, origin=None)
113
+ if name.to_text() != name.to_unicode():
114
+ context["unicode_name"] = name.to_unicode()
115
+
116
+ unicode_value = value_to_unicode(instance.value)
117
+ if instance.value != unicode_value:
118
+ context["unicode_value"] = unicode_value
119
+
120
+ if instance.type == RecordTypeChoices.CNAME:
121
+ context["cname_target_table"] = self.get_value_records(instance)
122
+ else:
123
+ context["cname_table"] = self.get_cname_records(instance)
124
+
125
+ return context
126
+
127
+
128
+ class RecordEditView(generic.ObjectEditView):
129
+ queryset = Record.objects.filter(managed=False).prefetch_related(
130
+ "zone", "ptr_record"
131
+ )
132
+ form = RecordForm
133
+ default_return_url = "plugins:netbox_dns:record_list"
134
+
135
+
136
+ class RecordDeleteView(generic.ObjectDeleteView):
137
+ queryset = Record.objects.filter(managed=False)
138
+ default_return_url = "plugins:netbox_dns:record_list"
139
+
140
+
141
+ class RecordBulkImportView(generic.BulkImportView):
142
+ queryset = Record.objects.filter(managed=False).prefetch_related(
143
+ "zone", "ptr_record"
144
+ )
145
+ model_form = RecordImportForm
146
+ table = RecordTable
147
+ default_return_url = "plugins:netbox_dns:record_list"
148
+
149
+
150
+ class RecordBulkEditView(generic.BulkEditView):
151
+ queryset = Record.objects.filter(managed=False).prefetch_related("zone")
152
+ filterset = RecordFilter
153
+ table = RecordTable
154
+ form = RecordBulkEditForm
155
+
156
+
157
+ class RecordBulkDeleteView(generic.BulkDeleteView):
158
+ queryset = Record.objects.filter(managed=False)
159
+ table = RecordTable
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "netbox-plugin-dns"
3
- version = "0.22.5"
3
+ version = "0.22.6"
4
4
  description = "NetBox DNS is a NetBox plugin for managing DNS data."
5
5
  authors = ["Peter Eckel <pete@netbox-dns.org>"]
6
6
  homepage = "https://github.com/peteeckel/netbox-plugin-dns"
@@ -1,87 +0,0 @@
1
- import sys
2
-
3
- from extras.plugins import PluginConfig
4
- from django.db.utils import OperationalError
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
12
-
13
- __version__ = "0.22.5"
14
-
15
-
16
- class DNSConfig(PluginConfig):
17
- name = "netbox_dns"
18
- verbose_name = "NetBox DNS"
19
- description = "NetBox plugin for DNS data"
20
- min_version = "3.5.0"
21
- version = __version__
22
- author = "Peter Eckel"
23
- author_email = "pete@netbox-dns.org"
24
- required_settings = []
25
- default_settings = {
26
- "zone_default_ttl": 86400,
27
- "zone_soa_serial_auto": True,
28
- "zone_soa_serial": 1,
29
- "zone_soa_refresh": 43200,
30
- "zone_soa_retry": 7200,
31
- "zone_soa_expire": 2419200,
32
- "zone_soa_minimum": 3600,
33
- "feature_ipam_coupling": False,
34
- "tolerate_underscores_in_hostnames": False,
35
- "tolerate_leading_underscore_types": [
36
- "TXT",
37
- "SRV",
38
- ],
39
- "tolerate_non_rfc1035_types": [],
40
- "enable_root_zones": False,
41
- "enforce_unique_records": True,
42
- "enforce_unique_rrset_ttl": True,
43
- }
44
- base_url = "netbox-dns"
45
-
46
- def ready(self):
47
- #
48
- # Check if required custom fields exist for IPAM coupling
49
- #
50
- if get_plugin_config("netbox_dns", "feature_ipam_coupling"):
51
- from extras.models import CustomField
52
- from ipam.models import IPAddress
53
- from django.contrib.contenttypes.models import ContentType
54
-
55
- try:
56
- objtype = ContentType.objects.get_for_model(IPAddress)
57
- required_cf = (
58
- "ipaddress_dns_record_name",
59
- "ipaddress_dns_record_ttl",
60
- "ipaddress_dns_record_disable_ptr",
61
- "ipaddress_dns_zone_id",
62
- )
63
-
64
- if CustomField.objects.filter(
65
- name__in=required_cf, content_types=objtype
66
- ).count() < len(required_cf):
67
- print(
68
- "WARNING: 'feature_ipam_coupling' is enabled, but the required"
69
- " custom fields for IPAM DNS coupling are missing. Please run"
70
- " the Django management command 'setup_coupling' to create the"
71
- " missing custom fields.",
72
- file=sys.stderr,
73
- )
74
- except OperationalError as exc:
75
- print(
76
- "WARNING: Unable to connect to PostgreSQL, cannot check custom fields"
77
- " for feature_ipam_coupling",
78
- file=sys.stderr,
79
- )
80
-
81
- super().ready()
82
-
83
-
84
- #
85
- # Initialize plugin config
86
- #
87
- config = DNSConfig
@@ -1,85 +0,0 @@
1
- from dns import name as dns_name
2
-
3
- from netbox.views import generic
4
-
5
- from netbox_dns.filters import RecordFilter
6
- from netbox_dns.forms import (
7
- RecordImportForm,
8
- RecordFilterForm,
9
- RecordForm,
10
- RecordBulkEditForm,
11
- )
12
- from netbox_dns.models import Record
13
- from netbox_dns.tables import RecordTable, ManagedRecordTable
14
- from netbox_dns.utilities import value_to_unicode
15
-
16
-
17
- class RecordListView(generic.ObjectListView):
18
- queryset = Record.objects.filter(managed=False).prefetch_related(
19
- "zone", "ptr_record"
20
- )
21
- filterset = RecordFilter
22
- filterset_form = RecordFilterForm
23
- table = RecordTable
24
-
25
-
26
- class ManagedRecordListView(generic.ObjectListView):
27
- queryset = Record.objects.filter(managed=True).prefetch_related(
28
- "zone", "address_record"
29
- )
30
- filterset = RecordFilter
31
- filterset_form = RecordFilterForm
32
- table = ManagedRecordTable
33
- actions = ("export",)
34
- template_name = "netbox_dns/record/managed.html"
35
-
36
-
37
- class RecordView(generic.ObjectView):
38
- queryset = Record.objects.all().prefetch_related("zone", "ptr_record")
39
-
40
- def get_extra_context(self, request, instance):
41
- context = {}
42
-
43
- name = dns_name.from_text(instance.name, origin=None)
44
- if name.to_text() != name.to_unicode():
45
- context["unicode_name"] = name.to_unicode()
46
-
47
- unicode_value = value_to_unicode(instance.value)
48
- if instance.value != unicode_value:
49
- context["unicode_value"] = unicode_value
50
-
51
- return context
52
-
53
-
54
- class RecordEditView(generic.ObjectEditView):
55
- queryset = Record.objects.filter(managed=False).prefetch_related(
56
- "zone", "ptr_record"
57
- )
58
- form = RecordForm
59
- default_return_url = "plugins:netbox_dns:record_list"
60
-
61
-
62
- class RecordDeleteView(generic.ObjectDeleteView):
63
- queryset = Record.objects.filter(managed=False)
64
- default_return_url = "plugins:netbox_dns:record_list"
65
-
66
-
67
- class RecordBulkImportView(generic.BulkImportView):
68
- queryset = Record.objects.filter(managed=False).prefetch_related(
69
- "zone", "ptr_record"
70
- )
71
- model_form = RecordImportForm
72
- table = RecordTable
73
- default_return_url = "plugins:netbox_dns:record_list"
74
-
75
-
76
- class RecordBulkEditView(generic.BulkEditView):
77
- queryset = Record.objects.filter(managed=False).prefetch_related("zone")
78
- filterset = RecordFilter
79
- table = RecordTable
80
- form = RecordBulkEditForm
81
-
82
-
83
- class RecordBulkDeleteView(generic.BulkDeleteView):
84
- queryset = Record.objects.filter(managed=False)
85
- table = RecordTable