netbox-plugin-dns 0.21.8__py3-none-any.whl → 0.21.11__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of netbox-plugin-dns might be problematic. Click here for more details.

netbox_dns/__init__.py CHANGED
@@ -9,7 +9,7 @@ except ImportError:
9
9
  # NetBox 3.5.8
10
10
  from extras.plugins.utils import get_plugin_config
11
11
 
12
- __version__ = "0.21.8"
12
+ __version__ = "0.21.11"
13
13
 
14
14
 
15
15
  class DNSConfig(PluginConfig):
@@ -14,62 +14,76 @@ class Command(BaseCommand):
14
14
  parser.add_argument(
15
15
  "--remove", action="store_true", help="Remove custom fields"
16
16
  )
17
+ parser.add_argument("--verbose", action="store_true", help="Verbose output")
17
18
 
18
19
  def handle(self, *model_names, **options):
19
20
  ipaddress_object_type = ContentType.objects.get_for_model(IPAddress)
20
- zone_object_type = ContentType.objects.get_for_model(Zone)
21
- record_object_type = ContentType.objects.get_for_model(Record)
22
- customfields = ("ipaddress_dns_record_name", "ipaddress_dns_zone_id")
23
21
 
24
22
  if options["remove"]:
25
- for cf in customfields:
23
+ for cf in (
24
+ "ipaddress_dns_record_name",
25
+ "ipaddress_dns_record_ttl",
26
+ "ipaddress_dns_zone_id",
27
+ ):
26
28
  try:
27
29
  CustomField.objects.get(
28
30
  name=cf, content_types=ipaddress_object_type
29
31
  ).delete()
32
+ if options.get("verbose"):
33
+ self.stdout.write(f"Custom field '{cf}' removed")
30
34
  except:
31
- self.stderr.write(f"Custom field '{cf}' does not exist!")
32
- else:
33
- self.stdout.write(f"Custom field '{cf}' removed")
35
+ pass
34
36
 
35
37
  else:
36
- msg = ""
37
- for cf in customfields:
38
- try:
39
- CustomField.objects.get(
40
- name=cf, content_types=ipaddress_object_type
41
- )
42
- except:
43
- pass
44
- else:
45
- msg += f"custom fields '{cf}' already exists, "
46
- if msg != "":
47
- raise CommandError(
48
- "\n".join(
49
- (
50
- "Can't setup IPAM-DNS coupling:",
51
- msg,
52
- "Remove them with NetBox command:",
53
- "python manage.py setup_coupling --remove",
54
- )
38
+ if not CustomField.objects.filter(
39
+ name="ipaddress_dns_record_name",
40
+ type=CustomFieldTypeChoices.TYPE_TEXT,
41
+ content_types=ipaddress_object_type,
42
+ ).exists():
43
+ cf_name = CustomField.objects.create(
44
+ name="ipaddress_dns_record_name",
45
+ label="Name",
46
+ type=CustomFieldTypeChoices.TYPE_TEXT,
47
+ required=False,
48
+ group_name="DNS",
49
+ )
50
+ cf_name.content_types.set([ipaddress_object_type])
51
+ if options.get("verbose"):
52
+ self.stdout.write(
53
+ "Created custom field 'ipaddress_dns_record_name'"
55
54
  )
55
+
56
+ if not CustomField.objects.filter(
57
+ name="ipaddress_dns_record_ttl",
58
+ type=CustomFieldTypeChoices.TYPE_INTEGER,
59
+ content_types=ipaddress_object_type,
60
+ ).exists():
61
+ cf_ttl = CustomField.objects.create(
62
+ name="ipaddress_dns_record_ttl",
63
+ label="TTL",
64
+ type=CustomFieldTypeChoices.TYPE_INTEGER,
65
+ validation_minimum=0,
66
+ validation_maximum=2147483647,
67
+ required=False,
68
+ group_name="DNS",
56
69
  )
70
+ cf_ttl.content_types.set([ipaddress_object_type])
71
+ if options.get("verbose"):
72
+ self.stdout.write("Created custom field 'ipaddress_dns_record_ttl'")
57
73
 
58
- cf_name = CustomField.objects.create(
59
- name="ipaddress_dns_record_name",
60
- label="Name",
61
- type=CustomFieldTypeChoices.TYPE_TEXT,
62
- required=False,
63
- group_name="DNS",
64
- )
65
- cf_name.content_types.set([ipaddress_object_type])
66
- cf_zone = CustomField.objects.create(
74
+ if not CustomField.objects.filter(
67
75
  name="ipaddress_dns_zone_id",
68
- label="Zone",
69
76
  type=CustomFieldTypeChoices.TYPE_OBJECT,
70
- object_type=zone_object_type,
71
- required=False,
72
- group_name="DNS",
73
- )
74
- cf_zone.content_types.set([ipaddress_object_type])
75
- self.stdout.write(f"Custom fields for IPAM-DNS coupling added")
77
+ content_types=ipaddress_object_type,
78
+ ).exists():
79
+ cf_zone = CustomField.objects.create(
80
+ name="ipaddress_dns_zone_id",
81
+ label="Zone",
82
+ type=CustomFieldTypeChoices.TYPE_OBJECT,
83
+ object_type=ContentType.objects.get_for_model(Zone),
84
+ required=False,
85
+ group_name="DNS",
86
+ )
87
+ cf_zone.content_types.set([ipaddress_object_type])
88
+ if options.get("verbose"):
89
+ self.stdout.write("Created custom field 'ipaddress_dns_zone_id'")
@@ -48,7 +48,7 @@ def ip_address_check_permissions_save(instance, **kwargs):
48
48
 
49
49
  record = get_address_record(instance)
50
50
  if record is not None:
51
- name, zone_id = ipaddress_cf_data(instance)
51
+ name, ttl, zone_id = ipaddress_cf_data(instance)
52
52
  if zone_id is not None:
53
53
  update_address_record(record, instance)
54
54
  record.full_clean()
@@ -68,6 +68,10 @@ def ip_address_check_permissions_save(instance, **kwargs):
68
68
  if value is not None:
69
69
  exc.error_dict["cf_ipaddress_dns_record_name"] = value
70
70
 
71
+ value = exc.error_dict.pop("ttl", None)
72
+ if value is not None:
73
+ exc.error_dict["cf_ipaddress_dns_record_ttl"] = value
74
+
71
75
  value = exc.error_dict.pop("value", None)
72
76
  if value is not None:
73
77
  exc.error_dict["cf_ipaddress_dns_record_name"] = value
@@ -108,13 +112,14 @@ def ip_address_update_dns_information(instance, **kwargs):
108
112
  if not get_plugin_config("netbox_dns", "feature_ipam_coupling"):
109
113
  return
110
114
 
111
- name, zone_id = ipaddress_cf_data(instance)
115
+ name, ttl, zone_id = ipaddress_cf_data(instance)
112
116
 
113
117
  if zone_id is not None:
114
118
  instance.dns_name = f"{name}.{Zone.objects.get(pk=zone_id).name}"
115
119
  else:
116
120
  instance.dns_name = ""
117
121
  instance.custom_field_data["ipaddress_dns_record_name"] = None
122
+ instance.custom_field_data["ipaddress_dns_record_ttl"] = None
118
123
  instance.custom_field_data["ipaddress_dns_zone_id"] = None
119
124
 
120
125
 
@@ -126,7 +131,7 @@ def ip_address_update_address_record(instance, **kwargs):
126
131
  if not get_plugin_config("netbox_dns", "feature_ipam_coupling"):
127
132
  return
128
133
 
129
- name, zone_id = ipaddress_cf_data(instance)
134
+ name, ttl, zone_id = ipaddress_cf_data(instance)
130
135
 
131
136
  if zone_id is None:
132
137
  #
netbox_dns/urls.py CHANGED
@@ -1,6 +1,6 @@
1
1
  from django.urls import path
2
2
 
3
- from netbox.views.generic import ObjectChangeLogView
3
+ from netbox.views.generic import ObjectChangeLogView, ObjectJournalView
4
4
 
5
5
  from netbox_dns.models import View, Zone, Record, NameServer, Contact, Registrar
6
6
  from netbox_dns.views import (
@@ -78,6 +78,12 @@ urlpatterns = [
78
78
  path("zones/<int:pk>/", ZoneView.as_view(), name="zone"),
79
79
  path("zones/<int:pk>/delete/", ZoneDeleteView.as_view(), name="zone_delete"),
80
80
  path("zones/<int:pk>/edit/", ZoneEditView.as_view(), name="zone_edit"),
81
+ path(
82
+ "zones/<int:pk>/journal/",
83
+ ObjectJournalView.as_view(),
84
+ name="zone_journal",
85
+ kwargs={"model": Zone},
86
+ ),
81
87
  path(
82
88
  "zones/<int:pk>/changelog/",
83
89
  ObjectChangeLogView.as_view(),
@@ -126,6 +132,12 @@ urlpatterns = [
126
132
  NameServerDeleteView.as_view(),
127
133
  name="nameserver_delete",
128
134
  ),
135
+ path(
136
+ "nameservers/<int:pk>/journal/",
137
+ ObjectJournalView.as_view(),
138
+ name="nameserver_journal",
139
+ kwargs={"model": NameServer},
140
+ ),
129
141
  path(
130
142
  "nameservers/<int:pk>/changelog/",
131
143
  ObjectChangeLogView.as_view(),
@@ -153,6 +165,12 @@ urlpatterns = [
153
165
  path("records/<int:pk>/", RecordView.as_view(), name="record"),
154
166
  path("records/<int:pk>/edit/", RecordEditView.as_view(), name="record_edit"),
155
167
  path("records/<int:pk>/delete/", RecordDeleteView.as_view(), name="record_delete"),
168
+ path(
169
+ "records/<int:pk>/journal/",
170
+ ObjectJournalView.as_view(),
171
+ name="record_journal",
172
+ kwargs={"model": Record},
173
+ ),
156
174
  path(
157
175
  "records/<int:pk>/changelog/",
158
176
  ObjectChangeLogView.as_view(),
@@ -174,6 +192,12 @@ urlpatterns = [
174
192
  path("views/<int:pk>/edit/", ViewEditView.as_view(), name="view_edit"),
175
193
  path("views/<int:pk>/delete/", ViewDeleteView.as_view(), name="view_delete"),
176
194
  path("views/<int:pk>/zones/", ViewZoneListView.as_view(), name="view_zones"),
195
+ path(
196
+ "views/<int:pk>/journal/",
197
+ ObjectJournalView.as_view(),
198
+ name="view_journal",
199
+ kwargs={"model": View},
200
+ ),
177
201
  path(
178
202
  "views/<int:pk>/changelog/",
179
203
  ObjectChangeLogView.as_view(),
@@ -204,6 +228,12 @@ urlpatterns = [
204
228
  ContactZoneListView.as_view(),
205
229
  name="contact_zones",
206
230
  ),
231
+ path(
232
+ "contacts/<int:pk>/journal/",
233
+ ObjectJournalView.as_view(),
234
+ name="contact_journal",
235
+ kwargs={"model": Contact},
236
+ ),
207
237
  path(
208
238
  "contacts/<int:pk>/changelog/",
209
239
  ObjectChangeLogView.as_view(),
@@ -246,6 +276,12 @@ urlpatterns = [
246
276
  RegistrarZoneListView.as_view(),
247
277
  name="registrar_zones",
248
278
  ),
279
+ path(
280
+ "registrars/<int:pk>/journal/",
281
+ ObjectJournalView.as_view(),
282
+ name="registrar_journal",
283
+ kwargs={"model": Registrar},
284
+ ),
249
285
  path(
250
286
  "registrars/<int:pk>/changelog/",
251
287
  ObjectChangeLogView.as_view(),
@@ -10,12 +10,13 @@ class DNSPermissionDenied(Exception):
10
10
 
11
11
  def ipaddress_cf_data(ip_address):
12
12
  name = ip_address.custom_field_data.get("ipaddress_dns_record_name")
13
+ ttl = ip_address.custom_field_data.get("ipaddress_dns_record_ttl")
13
14
  zone_id = ip_address.custom_field_data.get("ipaddress_dns_zone_id")
14
15
 
15
16
  if name is None or zone_id is None:
16
- return None, None
17
+ return None, None, None
17
18
 
18
- return name, zone_id
19
+ return name, ttl, zone_id
19
20
 
20
21
 
21
22
  def address_record_type(ip_address):
@@ -35,7 +36,7 @@ def get_address_record(ip_address):
35
36
 
36
37
 
37
38
  def new_address_record(instance):
38
- name, zone_id = ipaddress_cf_data(instance)
39
+ name, ttl, zone_id = ipaddress_cf_data(instance)
39
40
 
40
41
  if zone_id is None:
41
42
  return None
@@ -43,6 +44,7 @@ def new_address_record(instance):
43
44
  return Record(
44
45
  name=name,
45
46
  zone_id=zone_id,
47
+ ttl=ttl,
46
48
  status=address_record_status(instance),
47
49
  type=address_record_type(instance),
48
50
  value=str(instance.address.ip),
@@ -52,9 +54,10 @@ def new_address_record(instance):
52
54
 
53
55
 
54
56
  def update_address_record(record, ip_address):
55
- name, zone_id = ipaddress_cf_data(ip_address)
57
+ name, ttl, zone_id = ipaddress_cf_data(ip_address)
56
58
 
57
59
  record.name = name
60
+ record.ttl = ttl
58
61
  record.zone_id = zone_id
59
62
  record.status = address_record_status(ip_address)
60
63
  record.value = str(ip_address.address.ip)
@@ -79,9 +82,11 @@ def dns_changed(old, new):
79
82
  return any(
80
83
  (
81
84
  old.address.ip != new.address.ip,
82
- old.custom_field_data["ipaddress_dns_record_name"]
83
- != new.custom_field_data["ipaddress_dns_record_name"],
84
- old.custom_field_data["ipaddress_dns_zone_id"]
85
- != new.custom_field_data["ipaddress_dns_zone_id"],
85
+ old.custom_field_data.get("ipaddress_dns_record_name")
86
+ != new.custom_field_data.get("ipaddress_dns_record_name"),
87
+ old.custom_field_data.get("ipaddress_dns_record_ttl")
88
+ != new.custom_field_data.get("ipaddress_dns_record_ttl"),
89
+ old.custom_field_data.get("ipaddress_dns_zone_id")
90
+ != new.custom_field_data.get("ipaddress_dns_zone_id"),
86
91
  )
87
92
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: netbox-plugin-dns
3
- Version: 0.21.8
3
+ Version: 0.21.11
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
@@ -1,4 +1,4 @@
1
- netbox_dns/__init__.py,sha256=0uRYkfDw8mWckKhzVPqFpsfw3h7yQyKXcY-kZWYI0HU,2254
1
+ netbox_dns/__init__.py,sha256=nqAZJ1aCDHd5sPMF-Zp8G8Rd3TTkE9bk7bqgf47ARt0,2255
2
2
  netbox_dns/api/nested_serializers.py,sha256=Do1wWwWrZ5a4OUuW0Sj8AU3AVlaCu675PAG78RT3dv4,2616
3
3
  netbox_dns/api/serializers.py,sha256=RXSETFLwRZQrUus8uzMt7q7wuB-QVoiHBQumQQxyX3s,7673
4
4
  netbox_dns/api/urls.py,sha256=R9VmmWtdrjvr35i5d_SfZK2lGn6JzmPuWEKTQlZ8MJo,575
@@ -30,7 +30,7 @@ netbox_dns/graphql/schema.py,sha256=D_dDusogaI55tmGx_dr1owsgzXS5fd2S-kPZ7xcXxs8,
30
30
  netbox_dns/graphql/view.py,sha256=S_61hYlQCtPQen1lI1UQs38UBWKQTaWfUxzlbpO07zA,467
31
31
  netbox_dns/graphql/zone.py,sha256=QDBxocezhLSHBGDV4RJnmarBfOsiUTeE9KzBGJ3gJi8,467
32
32
  netbox_dns/management/commands/cleanup_database.py,sha256=fGkzOPXDsZWTlwetnerzkMmdpluV4vo34XXB_z8-yHU,6035
33
- netbox_dns/management/commands/setup_coupling.py,sha256=K842DptVDbDdY3m6ILs90ClJdnBVkLnI623bhVASeDo,2872
33
+ netbox_dns/management/commands/setup_coupling.py,sha256=nfMZmbhIVzXUMKYLO_zT9hfJQTbdGDWeGKQqTaoDYMg,3676
34
34
  netbox_dns/management/commands/update_soa.py,sha256=qvlApMngTVpauj0CU0yeOy9r3lxxDciKorMxFsyvQhs,661
35
35
  netbox_dns/migrations/0001_initial.py,sha256=R9FbIQ7nO1ROb12NL8YQDkFQuP1r6-TtMcPwg4rwjus,4153
36
36
  netbox_dns/migrations/0001_squashed_netbox_dns_0_15.py,sha256=nxktsb-1oyiw1bHiBpnp8Vq4ugT0p0UMdJcYiq-UHoo,11466
@@ -70,7 +70,7 @@ netbox_dns/models/view.py,sha256=ljs3Q2xQR63ZOSyja5H7DEdFbm7MX2ZjlR6uNVrAsVo,920
70
70
  netbox_dns/models/zone.py,sha256=wfOgvGnu8aT0A6xwthI0KDFSU3XY-R-Ut75mJ5-GkfQ,18076
71
71
  netbox_dns/navigation.py,sha256=IutEr_TcPgDGzqTT1ZzV4IUABLSOFU9v364BfpCqbro,4587
72
72
  netbox_dns/signals/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
73
- netbox_dns/signals/ipam_coupling.py,sha256=l9Qcxh6A9hbb-zIU3h-Pis5xXA2ST_puNFgr1Yj1aRE,4801
73
+ netbox_dns/signals/ipam_coupling.py,sha256=VXNNeOm47llpywpeGJJaPwmQiKWDBJ11m6-u_RMvijg,5043
74
74
  netbox_dns/tables/__init__.py,sha256=Aw8HrCTjaJfu5JSwJsQRHfOUz4zKwAmZNByT9q6BrFU,136
75
75
  netbox_dns/tables/contact.py,sha256=HpblHKrlQqQAPC59gvw8wUV3tc6UBAphHPE6CfN2uVM,747
76
76
  netbox_dns/tables/nameserver.py,sha256=7Ap0px5gAHtgk5XFMpZCHccy9N-v8UKy19GP7fdWuPc,819
@@ -93,9 +93,9 @@ netbox_dns/templates/netbox_dns/zone/managed_record.html,sha256=5P85eJuQOB7omih2
93
93
  netbox_dns/templates/netbox_dns/zone/record.html,sha256=1oIRGXOZAjwmTMkTgArfKyVrmL54Sh_IN7IAF3qYEKM,2218
94
94
  netbox_dns/templates/netbox_dns/zone/registration.html,sha256=3R5uqLXZxIJkp9_LVnTTgTV61mITfDPDDNofV7s4d1k,1283
95
95
  netbox_dns/templates/netbox_dns/zone.html,sha256=oz_GopJpox3aK_w6F5iqeKuA7-vROQceowGdgTfrj1Y,5852
96
- netbox_dns/urls.py,sha256=RMEDiyEmtHQzbjKy65ud6LofQYoEziIH7BvRaVs7kn0,8020
96
+ netbox_dns/urls.py,sha256=_ET6CstIhCk-H2sVX0XXyfPmWQmCFHVndph_KkTY8-M,8987
97
97
  netbox_dns/utilities/__init__.py,sha256=UjYHNp3RxToJgjOLs6iPn5ekETCpES2yWUfuqJXkDyU,1915
98
- netbox_dns/utilities/ipam_coupling.py,sha256=Fmu03-W6WzGBFbUDt_DChz5tU1Cs7NOMsvSczutImhc,2420
98
+ netbox_dns/utilities/ipam_coupling.py,sha256=VbPKTkcSJfgeSirnJ1yoX_HzBYgRgNYKNFjKB7kAPUA,2702
99
99
  netbox_dns/validators.py,sha256=mauW5-7a-sjTxyP4qWiRi-kfffGEj9Ma7N2o-BJjx38,2232
100
100
  netbox_dns/views/__init__.py,sha256=Aw8HrCTjaJfu5JSwJsQRHfOUz4zKwAmZNByT9q6BrFU,136
101
101
  netbox_dns/views/contact.py,sha256=6-oCfK98-submcUTmi0ejw7QBscNn3S9bnS0oUTXOaY,2235
@@ -104,7 +104,7 @@ netbox_dns/views/record.py,sha256=eT-M-rqhCrcmhpEyKOnQ8SWnxAVUgams5e86nVL9uc0,25
104
104
  netbox_dns/views/registrar.py,sha256=aznSKt1L5tILMLGgcZiBR7u7B8rNl-jM1B2-N0fTeK8,2072
105
105
  netbox_dns/views/view.py,sha256=uUvtlNEh5MYoEALvWWaCOqj_Zj8dpGOL2PUyg-UPfEA,1895
106
106
  netbox_dns/views/zone.py,sha256=j1wxqEQKYxkQv2DqOHo0gP6e_hZrD2RTyZhkx5CCXFE,3988
107
- netbox_plugin_dns-0.21.8.dist-info/LICENSE,sha256=tziMJKpkMbySr09L6bIwsu7Ca9ICoqpMO3yAXgEMQA4,1076
108
- netbox_plugin_dns-0.21.8.dist-info/METADATA,sha256=S4JWySqR8ji6ZGgefQCc9IzazWKjsoamMTRyiRz3Yos,3931
109
- netbox_plugin_dns-0.21.8.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
110
- netbox_plugin_dns-0.21.8.dist-info/RECORD,,
107
+ netbox_plugin_dns-0.21.11.dist-info/LICENSE,sha256=tziMJKpkMbySr09L6bIwsu7Ca9ICoqpMO3yAXgEMQA4,1076
108
+ netbox_plugin_dns-0.21.11.dist-info/METADATA,sha256=OQbNPaFhPexDrIJ_z89_gKHe4zpLAAqJIAPW4Wx4cCc,3932
109
+ netbox_plugin_dns-0.21.11.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
110
+ netbox_plugin_dns-0.21.11.dist-info/RECORD,,