netbox-plugin-dns 1.0.6__py3-none-any.whl → 1.0.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.
Potentially problematic release.
This version of netbox-plugin-dns might be problematic. Click here for more details.
- netbox_dns/__init__.py +1 -1
- netbox_dns/api/nested_serializers.py +17 -16
- netbox_dns/api/serializers_/record.py +1 -0
- netbox_dns/api/views.py +0 -28
- netbox_dns/filtersets/record.py +1 -1
- netbox_dns/graphql/schema.py +16 -40
- netbox_dns/migrations/0007_alter_ordering_options.py +25 -0
- netbox_dns/models/contact.py +9 -3
- netbox_dns/models/nameserver.py +8 -3
- netbox_dns/models/record.py +15 -4
- netbox_dns/models/record_template.py +4 -1
- netbox_dns/models/registrar.py +7 -1
- netbox_dns/models/view.py +9 -2
- netbox_dns/models/zone.py +10 -5
- netbox_dns/models/zone_template.py +8 -5
- netbox_dns/tables/contact.py +0 -1
- netbox_dns/tables/nameserver.py +1 -7
- netbox_dns/tables/record.py +10 -30
- netbox_dns/tables/record_template.py +0 -17
- netbox_dns/tables/registrar.py +0 -2
- netbox_dns/tables/view.py +1 -8
- netbox_dns/tables/zone.py +0 -15
- netbox_dns/tables/zone_template.py +2 -16
- netbox_dns/urls/contact.py +10 -32
- netbox_dns/urls/nameserver.py +14 -38
- netbox_dns/urls/record.py +7 -19
- netbox_dns/urls/record_template.py +18 -27
- netbox_dns/urls/registrar.py +11 -35
- netbox_dns/urls/view.py +8 -22
- netbox_dns/urls/zone.py +8 -46
- netbox_dns/urls/zone_template.py +16 -26
- netbox_dns/validators/dns_name.py +9 -0
- netbox_dns/views/contact.py +0 -1
- netbox_dns/views/nameserver.py +7 -3
- netbox_dns/views/record.py +9 -2
- netbox_dns/views/record_template.py +1 -1
- netbox_dns/views/registrar.py +0 -1
- netbox_dns/views/view.py +6 -1
- netbox_dns/views/zone.py +7 -6
- netbox_dns/views/zone_template.py +2 -2
- {netbox_plugin_dns-1.0.6.dist-info → netbox_plugin_dns-1.0.7.dist-info}/METADATA +1 -1
- {netbox_plugin_dns-1.0.6.dist-info → netbox_plugin_dns-1.0.7.dist-info}/RECORD +44 -43
- {netbox_plugin_dns-1.0.6.dist-info → netbox_plugin_dns-1.0.7.dist-info}/LICENSE +0 -0
- {netbox_plugin_dns-1.0.6.dist-info → netbox_plugin_dns-1.0.7.dist-info}/WHEEL +0 -0
netbox_dns/__init__.py
CHANGED
|
@@ -59,6 +59,22 @@ class NestedZoneSerializer(WritableNestedSerializer):
|
|
|
59
59
|
]
|
|
60
60
|
|
|
61
61
|
|
|
62
|
+
class NestedZoneTemplateSerializer(WritableNestedSerializer):
|
|
63
|
+
url = serializers.HyperlinkedIdentityField(
|
|
64
|
+
view_name="plugins-api:netbox_dns-api:zonetemplate-detail"
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
class Meta:
|
|
68
|
+
model = ZoneTemplate
|
|
69
|
+
fields = (
|
|
70
|
+
"id",
|
|
71
|
+
"url",
|
|
72
|
+
"name",
|
|
73
|
+
"display",
|
|
74
|
+
"description",
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
|
|
62
78
|
class NestedRecordSerializer(WritableNestedSerializer):
|
|
63
79
|
url = serializers.HyperlinkedIdentityField(
|
|
64
80
|
view_name="plugins-api:netbox_dns-api:record-detail"
|
|
@@ -86,6 +102,7 @@ class NestedRecordSerializer(WritableNestedSerializer):
|
|
|
86
102
|
"status",
|
|
87
103
|
"ttl",
|
|
88
104
|
"zone",
|
|
105
|
+
"managed",
|
|
89
106
|
"active",
|
|
90
107
|
]
|
|
91
108
|
|
|
@@ -109,19 +126,3 @@ class NestedRecordTemplateSerializer(WritableNestedSerializer):
|
|
|
109
126
|
"ttl",
|
|
110
127
|
"description",
|
|
111
128
|
)
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
class NestedZoneTemplateSerializer(WritableNestedSerializer):
|
|
115
|
-
url = serializers.HyperlinkedIdentityField(
|
|
116
|
-
view_name="plugins-api:netbox_dns-api:zonetemplate-detail"
|
|
117
|
-
)
|
|
118
|
-
|
|
119
|
-
class Meta:
|
|
120
|
-
model = ZoneTemplate
|
|
121
|
-
fields = (
|
|
122
|
-
"id",
|
|
123
|
-
"url",
|
|
124
|
-
"name",
|
|
125
|
-
"display",
|
|
126
|
-
"description",
|
|
127
|
-
)
|
netbox_dns/api/views.py
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
from rest_framework import serializers
|
|
2
|
-
from rest_framework.decorators import action
|
|
3
|
-
from rest_framework.response import Response
|
|
4
2
|
from rest_framework.routers import APIRootView
|
|
5
3
|
|
|
6
4
|
from netbox.api.viewsets import NetBoxModelViewSet
|
|
@@ -47,12 +45,6 @@ class ViewViewSet(NetBoxModelViewSet):
|
|
|
47
45
|
serializer_class = ViewSerializer
|
|
48
46
|
filterset_class = ViewFilterSet
|
|
49
47
|
|
|
50
|
-
@action(detail=True, methods=["get"])
|
|
51
|
-
def views(self, request, pk=None):
|
|
52
|
-
views = View.objects.filter(zone=pk)
|
|
53
|
-
serializer = ViewSerializer(views, many=True, context={"request": request})
|
|
54
|
-
return Response(serializer.data)
|
|
55
|
-
|
|
56
48
|
|
|
57
49
|
class ZoneViewSet(NetBoxModelViewSet):
|
|
58
50
|
queryset = Zone.objects.prefetch_related(
|
|
@@ -66,32 +58,12 @@ class ZoneViewSet(NetBoxModelViewSet):
|
|
|
66
58
|
serializer_class = ZoneSerializer
|
|
67
59
|
filterset_class = ZoneFilterSet
|
|
68
60
|
|
|
69
|
-
@action(detail=True, methods=["get"])
|
|
70
|
-
def records(self, request, pk=None):
|
|
71
|
-
records = Record.objects.filter(zone=pk)
|
|
72
|
-
serializer = RecordSerializer(records, many=True, context={"request": request})
|
|
73
|
-
return Response(serializer.data)
|
|
74
|
-
|
|
75
|
-
@action(detail=True, methods=["get"])
|
|
76
|
-
def nameservers(self, request, pk=None):
|
|
77
|
-
nameservers = NameServer.objects.filter(zones__id=pk)
|
|
78
|
-
serializer = NameServerSerializer(
|
|
79
|
-
nameservers, many=True, context={"request": request}
|
|
80
|
-
)
|
|
81
|
-
return Response(serializer.data)
|
|
82
|
-
|
|
83
61
|
|
|
84
62
|
class NameServerViewSet(NetBoxModelViewSet):
|
|
85
63
|
queryset = NameServer.objects.prefetch_related("zones", "tenant")
|
|
86
64
|
serializer_class = NameServerSerializer
|
|
87
65
|
filterset_class = NameServerFilterSet
|
|
88
66
|
|
|
89
|
-
@action(detail=True, methods=["get"])
|
|
90
|
-
def zones(self, request, pk=None):
|
|
91
|
-
zones = Zone.objects.filter(nameservers__id=pk)
|
|
92
|
-
serializer = ZoneSerializer(zones, many=True, context={"request": request})
|
|
93
|
-
return Response(serializer.data)
|
|
94
|
-
|
|
95
67
|
|
|
96
68
|
class RecordViewSet(NetBoxModelViewSet):
|
|
97
69
|
queryset = Record.objects.all().prefetch_related("zone", "zone__view", "tenant")
|
netbox_dns/filtersets/record.py
CHANGED
|
@@ -121,7 +121,7 @@ class RecordFilterSet(TenancyFilterSet, NetBoxModelFilterSet):
|
|
|
121
121
|
if not value.strip():
|
|
122
122
|
return queryset
|
|
123
123
|
qs_filter = (
|
|
124
|
-
Q(
|
|
124
|
+
Q(fqdn__icontains=value)
|
|
125
125
|
| Q(value__icontains=value)
|
|
126
126
|
| Q(zone__name__icontains=value)
|
|
127
127
|
)
|
netbox_dns/graphql/schema.py
CHANGED
|
@@ -25,79 +25,55 @@ from .types import (
|
|
|
25
25
|
)
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
@strawberry.type
|
|
28
|
+
@strawberry.type(name="Query")
|
|
29
29
|
class NetBoxDNSNameServerQuery:
|
|
30
|
-
|
|
31
|
-
def netbox_dns_nameserver(self, id: int) -> NetBoxDNSNameServerType:
|
|
32
|
-
return NameServer.objects.get(pk=id)
|
|
33
|
-
|
|
30
|
+
netbox_dns_nameserver: NetBoxDNSNameServerType = strawberry_django.field()
|
|
34
31
|
netbox_dns_nameserver_list: List[NetBoxDNSNameServerType] = (
|
|
35
32
|
strawberry_django.field()
|
|
36
33
|
)
|
|
37
34
|
|
|
38
35
|
|
|
39
|
-
@strawberry.type
|
|
36
|
+
@strawberry.type(name="Query")
|
|
40
37
|
class NetBoxDNSViewQuery:
|
|
41
|
-
|
|
42
|
-
def netbox_dns_view(self, id: int) -> NetBoxDNSViewType:
|
|
43
|
-
return View.objects.get(pk=id)
|
|
44
|
-
|
|
38
|
+
netbox_dns_view: NetBoxDNSViewType = strawberry_django.field()
|
|
45
39
|
netbox_dns_view_list: List[NetBoxDNSViewType] = strawberry_django.field()
|
|
46
40
|
|
|
47
41
|
|
|
48
|
-
@strawberry.type
|
|
42
|
+
@strawberry.type(name="Query")
|
|
49
43
|
class NetBoxDNSZoneQuery:
|
|
50
|
-
|
|
51
|
-
def netbox_dns_zone(self, id: int) -> NetBoxDNSZoneType:
|
|
52
|
-
return Zone.objects.get(pk=id)
|
|
53
|
-
|
|
44
|
+
netbox_dns_zone: NetBoxDNSZoneType = strawberry_django.field()
|
|
54
45
|
netbox_dns_zone_list: List[NetBoxDNSZoneType] = strawberry_django.field()
|
|
55
46
|
|
|
56
47
|
|
|
57
|
-
@strawberry.type
|
|
48
|
+
@strawberry.type(name="Query")
|
|
58
49
|
class NetBoxDNSRecordQuery:
|
|
59
|
-
|
|
60
|
-
def netbox_dns_record(self, id: int) -> NetBoxDNSRecordType:
|
|
61
|
-
return Record.objects.get(pk=id)
|
|
62
|
-
|
|
50
|
+
netbox_dns_record: NetBoxDNSRecordType = strawberry_django.field()
|
|
63
51
|
netbox_dns_record_list: List[NetBoxDNSRecordType] = strawberry_django.field()
|
|
64
52
|
|
|
65
53
|
|
|
66
|
-
@strawberry.type
|
|
54
|
+
@strawberry.type(name="Query")
|
|
67
55
|
class NetBoxDNSContactQuery:
|
|
68
|
-
|
|
69
|
-
def netbox_dns_contact(self, id: int) -> NetBoxDNSContactType:
|
|
70
|
-
return Contact.objects.get(pk=id)
|
|
71
|
-
|
|
56
|
+
netbox_dns_contact: NetBoxDNSContactType = strawberry_django.field()
|
|
72
57
|
netbox_dns_contact_list: List[NetBoxDNSContactType] = strawberry_django.field()
|
|
73
58
|
|
|
74
59
|
|
|
75
|
-
@strawberry.type
|
|
60
|
+
@strawberry.type(name="Query")
|
|
76
61
|
class NetBoxDNSRegistrarQuery:
|
|
77
|
-
|
|
78
|
-
def netbox_dns_registrar(self, id: int) -> NetBoxDNSRegistrarType:
|
|
79
|
-
return Registrar.objects.get(pk=id)
|
|
80
|
-
|
|
62
|
+
netbox_dns_registrar: NetBoxDNSRegistrarType = strawberry_django.field()
|
|
81
63
|
netbox_dns_registrar_list: List[NetBoxDNSRegistrarType] = strawberry_django.field()
|
|
82
64
|
|
|
83
65
|
|
|
84
|
-
@strawberry.type
|
|
66
|
+
@strawberry.type(name="Query")
|
|
85
67
|
class NetBoxDNSZoneTemplateQuery:
|
|
86
|
-
|
|
87
|
-
def netbox_dns_zone_template(self, id: int) -> NetBoxDNSZoneTemplateType:
|
|
88
|
-
return ZoneTemplate.objects.get(pk=id)
|
|
89
|
-
|
|
68
|
+
netbox_dns_zone_template: NetBoxDNSZoneTemplateType = strawberry_django.field()
|
|
90
69
|
netbox_dns_zone_template_list: List[NetBoxDNSZoneTemplateType] = (
|
|
91
70
|
strawberry_django.field()
|
|
92
71
|
)
|
|
93
72
|
|
|
94
73
|
|
|
95
|
-
@strawberry.type
|
|
74
|
+
@strawberry.type(name="Query")
|
|
96
75
|
class NetBoxDNSRecordTemplateQuery:
|
|
97
|
-
|
|
98
|
-
def netbox_dns_record_template(self, id: int) -> NetBoxDNSRecordTemplateType:
|
|
99
|
-
return RecordTemplate.objects.get(pk=id)
|
|
100
|
-
|
|
76
|
+
netbox_dns_record_template: NetBoxDNSRecordTemplateType = strawberry_django.field()
|
|
101
77
|
netbox_dns_record_template_list: List[NetBoxDNSRecordTemplateType] = (
|
|
102
78
|
strawberry_django.field()
|
|
103
79
|
)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Generated by Django 5.0.7 on 2024-08-27 09:29
|
|
2
|
+
|
|
3
|
+
from django.db import migrations
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
|
|
8
|
+
dependencies = [
|
|
9
|
+
("netbox_dns", "0006_templating"),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.AlterModelOptions(
|
|
14
|
+
name="record",
|
|
15
|
+
options={"ordering": ("fqdn", "zone", "name", "type", "value", "status")},
|
|
16
|
+
),
|
|
17
|
+
migrations.AlterModelOptions(
|
|
18
|
+
name="recordtemplate",
|
|
19
|
+
options={"ordering": ("name",)},
|
|
20
|
+
),
|
|
21
|
+
migrations.AlterModelOptions(
|
|
22
|
+
name="zonetemplate",
|
|
23
|
+
options={"ordering": ("name",)},
|
|
24
|
+
),
|
|
25
|
+
]
|
netbox_dns/models/contact.py
CHANGED
|
@@ -87,7 +87,7 @@ class Contact(NetBoxModel):
|
|
|
87
87
|
related_name="netbox_dns_contact_set",
|
|
88
88
|
)
|
|
89
89
|
|
|
90
|
-
clone_fields =
|
|
90
|
+
clone_fields = (
|
|
91
91
|
"name",
|
|
92
92
|
"description",
|
|
93
93
|
"organization",
|
|
@@ -102,7 +102,7 @@ class Contact(NetBoxModel):
|
|
|
102
102
|
"fax_ext",
|
|
103
103
|
"email",
|
|
104
104
|
"tags",
|
|
105
|
-
|
|
105
|
+
)
|
|
106
106
|
|
|
107
107
|
def get_absolute_url(self):
|
|
108
108
|
return reverse("plugins:netbox_dns:contact", kwargs={"pk": self.pk})
|
|
@@ -114,7 +114,13 @@ class Contact(NetBoxModel):
|
|
|
114
114
|
return self.contact_id
|
|
115
115
|
|
|
116
116
|
class Meta:
|
|
117
|
-
|
|
117
|
+
verbose_name = "Contact"
|
|
118
|
+
verbose_name_plural = "Contacts"
|
|
119
|
+
|
|
120
|
+
ordering = (
|
|
121
|
+
"name",
|
|
122
|
+
"contact_id",
|
|
123
|
+
)
|
|
118
124
|
|
|
119
125
|
@property
|
|
120
126
|
def zones(self):
|
netbox_dns/models/nameserver.py
CHANGED
|
@@ -7,6 +7,7 @@ from django.urls import reverse
|
|
|
7
7
|
|
|
8
8
|
from netbox.models import NetBoxModel
|
|
9
9
|
from netbox.search import SearchIndex, register_search
|
|
10
|
+
from netbox.models.features import ContactsMixin
|
|
10
11
|
|
|
11
12
|
from netbox_dns.utilities import (
|
|
12
13
|
name_to_unicode,
|
|
@@ -26,7 +27,7 @@ __all__ = (
|
|
|
26
27
|
)
|
|
27
28
|
|
|
28
29
|
|
|
29
|
-
class NameServer(ObjectModificationMixin, NetBoxModel):
|
|
30
|
+
class NameServer(ObjectModificationMixin, ContactsMixin, NetBoxModel):
|
|
30
31
|
name = models.CharField(
|
|
31
32
|
unique=True,
|
|
32
33
|
max_length=255,
|
|
@@ -43,13 +44,17 @@ class NameServer(ObjectModificationMixin, NetBoxModel):
|
|
|
43
44
|
null=True,
|
|
44
45
|
)
|
|
45
46
|
|
|
46
|
-
clone_fields =
|
|
47
|
+
clone_fields = (
|
|
48
|
+
"name",
|
|
49
|
+
"description",
|
|
50
|
+
)
|
|
47
51
|
|
|
48
52
|
class Meta:
|
|
49
|
-
ordering = ("name",)
|
|
50
53
|
verbose_name = "Nameserver"
|
|
51
54
|
verbose_name_plural = "Nameservers"
|
|
52
55
|
|
|
56
|
+
ordering = ("name",)
|
|
57
|
+
|
|
53
58
|
def __str__(self):
|
|
54
59
|
try:
|
|
55
60
|
return dns_name.from_text(self.name, origin=None).to_unicode()
|
netbox_dns/models/record.py
CHANGED
|
@@ -9,6 +9,7 @@ from django.db.models import Q, ExpressionWrapper, BooleanField, Min
|
|
|
9
9
|
from django.urls import reverse
|
|
10
10
|
|
|
11
11
|
from netbox.models import NetBoxModel
|
|
12
|
+
from netbox.models.features import ContactsMixin
|
|
12
13
|
from netbox.search import SearchIndex, register_search
|
|
13
14
|
from netbox.plugins.utils import get_plugin_config
|
|
14
15
|
from utilities.querysets import RestrictedQuerySet
|
|
@@ -62,7 +63,7 @@ class RecordManager(models.Manager.from_queryset(RestrictedQuerySet)):
|
|
|
62
63
|
)
|
|
63
64
|
|
|
64
65
|
|
|
65
|
-
class Record(ObjectModificationMixin, NetBoxModel):
|
|
66
|
+
class Record(ObjectModificationMixin, ContactsMixin, NetBoxModel):
|
|
66
67
|
ACTIVE_STATUS_LIST = (RecordStatusChoices.STATUS_ACTIVE,)
|
|
67
68
|
|
|
68
69
|
unique_ptr_qs = Q(
|
|
@@ -155,7 +156,7 @@ class Record(ObjectModificationMixin, NetBoxModel):
|
|
|
155
156
|
objects = RecordManager()
|
|
156
157
|
raw_objects = RestrictedQuerySet.as_manager()
|
|
157
158
|
|
|
158
|
-
clone_fields =
|
|
159
|
+
clone_fields = (
|
|
159
160
|
"zone",
|
|
160
161
|
"type",
|
|
161
162
|
"name",
|
|
@@ -164,10 +165,20 @@ class Record(ObjectModificationMixin, NetBoxModel):
|
|
|
164
165
|
"ttl",
|
|
165
166
|
"disable_ptr",
|
|
166
167
|
"description",
|
|
167
|
-
|
|
168
|
+
)
|
|
168
169
|
|
|
169
170
|
class Meta:
|
|
170
|
-
|
|
171
|
+
verbose_name = "Record"
|
|
172
|
+
verbose_name_plural = "Records"
|
|
173
|
+
|
|
174
|
+
ordering = (
|
|
175
|
+
"fqdn",
|
|
176
|
+
"zone",
|
|
177
|
+
"name",
|
|
178
|
+
"type",
|
|
179
|
+
"value",
|
|
180
|
+
"status",
|
|
181
|
+
)
|
|
171
182
|
|
|
172
183
|
def __str__(self):
|
|
173
184
|
try:
|
netbox_dns/models/registrar.py
CHANGED
|
@@ -59,7 +59,13 @@ class Registrar(NetBoxModel):
|
|
|
59
59
|
return str(self.name)
|
|
60
60
|
|
|
61
61
|
class Meta:
|
|
62
|
-
|
|
62
|
+
verbose_name = "Registrar"
|
|
63
|
+
verbose_name_plural = "Registrars"
|
|
64
|
+
|
|
65
|
+
ordering = (
|
|
66
|
+
"name",
|
|
67
|
+
"iana_id",
|
|
68
|
+
)
|
|
63
69
|
|
|
64
70
|
|
|
65
71
|
@register_search
|
netbox_dns/models/view.py
CHANGED
|
@@ -3,6 +3,7 @@ from django.urls import reverse
|
|
|
3
3
|
from django.core.exceptions import ValidationError
|
|
4
4
|
|
|
5
5
|
from netbox.models import NetBoxModel
|
|
6
|
+
from netbox.models.features import ContactsMixin
|
|
6
7
|
from netbox.search import SearchIndex, register_search
|
|
7
8
|
from netbox.context import current_request
|
|
8
9
|
from utilities.exceptions import AbortRequest
|
|
@@ -16,7 +17,7 @@ __all__ = (
|
|
|
16
17
|
)
|
|
17
18
|
|
|
18
19
|
|
|
19
|
-
class View(ObjectModificationMixin, NetBoxModel):
|
|
20
|
+
class View(ObjectModificationMixin, ContactsMixin, NetBoxModel):
|
|
20
21
|
name = models.CharField(
|
|
21
22
|
unique=True,
|
|
22
23
|
max_length=255,
|
|
@@ -36,7 +37,10 @@ class View(ObjectModificationMixin, NetBoxModel):
|
|
|
36
37
|
null=True,
|
|
37
38
|
)
|
|
38
39
|
|
|
39
|
-
clone_fields =
|
|
40
|
+
clone_fields = (
|
|
41
|
+
"name",
|
|
42
|
+
"description",
|
|
43
|
+
)
|
|
40
44
|
|
|
41
45
|
@classmethod
|
|
42
46
|
def get_default_view(cls):
|
|
@@ -49,6 +53,9 @@ class View(ObjectModificationMixin, NetBoxModel):
|
|
|
49
53
|
return str(self.name)
|
|
50
54
|
|
|
51
55
|
class Meta:
|
|
56
|
+
verbose_name = "View"
|
|
57
|
+
verbose_name_plural = "Views"
|
|
58
|
+
|
|
52
59
|
ordering = ("name",)
|
|
53
60
|
|
|
54
61
|
def delete(self, *args, **kwargs):
|
netbox_dns/models/zone.py
CHANGED
|
@@ -19,6 +19,7 @@ from django.dispatch import receiver
|
|
|
19
19
|
from django.conf import settings
|
|
20
20
|
|
|
21
21
|
from netbox.models import NetBoxModel
|
|
22
|
+
from netbox.models.features import ContactsMixin
|
|
22
23
|
from netbox.search import SearchIndex, register_search
|
|
23
24
|
from netbox.plugins.utils import get_plugin_config
|
|
24
25
|
from utilities.querysets import RestrictedQuerySet
|
|
@@ -34,6 +35,7 @@ from netbox_dns.utilities import (
|
|
|
34
35
|
)
|
|
35
36
|
from netbox_dns.validators import (
|
|
36
37
|
validate_fqdn,
|
|
38
|
+
validate_rname,
|
|
37
39
|
validate_domain_name,
|
|
38
40
|
)
|
|
39
41
|
from netbox_dns.mixins import ObjectModificationMixin
|
|
@@ -66,7 +68,7 @@ class ZoneManager(models.Manager.from_queryset(RestrictedQuerySet)):
|
|
|
66
68
|
)
|
|
67
69
|
|
|
68
70
|
|
|
69
|
-
class Zone(ObjectModificationMixin, NetBoxModel):
|
|
71
|
+
class Zone(ObjectModificationMixin, ContactsMixin, NetBoxModel):
|
|
70
72
|
ACTIVE_STATUS_LIST = (ZoneStatusChoices.STATUS_ACTIVE,)
|
|
71
73
|
|
|
72
74
|
def __init__(self, *args, **kwargs):
|
|
@@ -245,7 +247,7 @@ class Zone(ObjectModificationMixin, NetBoxModel):
|
|
|
245
247
|
|
|
246
248
|
objects = ZoneManager()
|
|
247
249
|
|
|
248
|
-
clone_fields =
|
|
250
|
+
clone_fields = (
|
|
249
251
|
"view",
|
|
250
252
|
"name",
|
|
251
253
|
"status",
|
|
@@ -259,9 +261,12 @@ class Zone(ObjectModificationMixin, NetBoxModel):
|
|
|
259
261
|
"soa_expire",
|
|
260
262
|
"soa_minimum",
|
|
261
263
|
"description",
|
|
262
|
-
|
|
264
|
+
)
|
|
263
265
|
|
|
264
266
|
class Meta:
|
|
267
|
+
verbose_name = "Zone"
|
|
268
|
+
verbose_name_plural = "Zones"
|
|
269
|
+
|
|
265
270
|
ordering = (
|
|
266
271
|
"view",
|
|
267
272
|
"name",
|
|
@@ -618,7 +623,7 @@ class Zone(ObjectModificationMixin, NetBoxModel):
|
|
|
618
623
|
raise ValidationError("soa_rname not set and no default value defined")
|
|
619
624
|
try:
|
|
620
625
|
dns_name.from_text(self.soa_rname, origin=dns_name.root)
|
|
621
|
-
|
|
626
|
+
validate_rname(self.soa_rname)
|
|
622
627
|
except (DNSException, ValidationError) as exc:
|
|
623
628
|
raise ValidationError(
|
|
624
629
|
{
|
|
@@ -638,7 +643,7 @@ class Zone(ObjectModificationMixin, NetBoxModel):
|
|
|
638
643
|
old_zone = Zone.objects.get(pk=self.pk)
|
|
639
644
|
if not self.soa_serial_auto:
|
|
640
645
|
self.check_soa_serial_increment(old_zone.soa_serial, self.soa_serial)
|
|
641
|
-
|
|
646
|
+
elif not old_zone.soa_serial_auto:
|
|
642
647
|
try:
|
|
643
648
|
self.check_soa_serial_increment(
|
|
644
649
|
old_zone.soa_serial, self.get_auto_serial()
|
|
@@ -82,7 +82,7 @@ class ZoneTemplate(NetBoxModel):
|
|
|
82
82
|
null=True,
|
|
83
83
|
)
|
|
84
84
|
|
|
85
|
-
clone_fields =
|
|
85
|
+
clone_fields = (
|
|
86
86
|
"description",
|
|
87
87
|
"nameservers",
|
|
88
88
|
"record_templates",
|
|
@@ -92,19 +92,22 @@ class ZoneTemplate(NetBoxModel):
|
|
|
92
92
|
"admin_c",
|
|
93
93
|
"tech_c",
|
|
94
94
|
"billing_c",
|
|
95
|
-
|
|
95
|
+
)
|
|
96
96
|
|
|
97
|
-
template_fields =
|
|
97
|
+
template_fields = (
|
|
98
98
|
"tenant",
|
|
99
99
|
"registrar",
|
|
100
100
|
"registrant",
|
|
101
101
|
"admin_c",
|
|
102
102
|
"tech_c",
|
|
103
103
|
"billing_c",
|
|
104
|
-
|
|
104
|
+
)
|
|
105
105
|
|
|
106
106
|
class Meta:
|
|
107
|
-
|
|
107
|
+
verbose_name = "Zone Template"
|
|
108
|
+
verbose_name_plural = "Zone Templates"
|
|
109
|
+
|
|
110
|
+
ordering = ("name",)
|
|
108
111
|
|
|
109
112
|
def __str__(self):
|
|
110
113
|
return str(self.name)
|
netbox_dns/tables/contact.py
CHANGED
netbox_dns/tables/nameserver.py
CHANGED
|
@@ -22,13 +22,7 @@ class NameServerTable(TenancyColumnsMixin, NetBoxTable):
|
|
|
22
22
|
|
|
23
23
|
class Meta(NetBoxTable.Meta):
|
|
24
24
|
model = NameServer
|
|
25
|
-
fields = (
|
|
26
|
-
"name",
|
|
27
|
-
"description",
|
|
28
|
-
"tags",
|
|
29
|
-
"tenant",
|
|
30
|
-
"tenant_group",
|
|
31
|
-
)
|
|
25
|
+
fields = ("description",)
|
|
32
26
|
default_columns = (
|
|
33
27
|
"name",
|
|
34
28
|
"tags",
|
netbox_dns/tables/record.py
CHANGED
|
@@ -23,10 +23,18 @@ class RecordBaseTable(TenancyColumnsMixin, NetBoxTable):
|
|
|
23
23
|
zone = tables.Column(
|
|
24
24
|
linkify=True,
|
|
25
25
|
)
|
|
26
|
+
view = tables.Column(
|
|
27
|
+
accessor="zone__view",
|
|
28
|
+
linkify=True,
|
|
29
|
+
)
|
|
26
30
|
type = tables.Column()
|
|
27
31
|
name = tables.Column(
|
|
28
32
|
linkify=True,
|
|
29
33
|
)
|
|
34
|
+
fqdn = tables.Column(
|
|
35
|
+
verbose_name="FQDN",
|
|
36
|
+
linkify=True,
|
|
37
|
+
)
|
|
30
38
|
value = tables.TemplateColumn(
|
|
31
39
|
template_code="{{ value|truncatechars:64 }}",
|
|
32
40
|
)
|
|
@@ -65,20 +73,8 @@ class RecordTable(RecordBaseTable):
|
|
|
65
73
|
class Meta(NetBoxTable.Meta):
|
|
66
74
|
model = Record
|
|
67
75
|
fields = (
|
|
68
|
-
"name",
|
|
69
|
-
"zone",
|
|
70
|
-
"ttl",
|
|
71
|
-
"type",
|
|
72
|
-
"value",
|
|
73
|
-
"unicode_value",
|
|
74
76
|
"status",
|
|
75
|
-
"disable_ptr",
|
|
76
|
-
"ptr_record",
|
|
77
|
-
"tags",
|
|
78
|
-
"active",
|
|
79
77
|
"description",
|
|
80
|
-
"tenant",
|
|
81
|
-
"tenant_group",
|
|
82
78
|
)
|
|
83
79
|
default_columns = (
|
|
84
80
|
"name",
|
|
@@ -104,17 +100,7 @@ class ManagedRecordTable(RecordBaseTable):
|
|
|
104
100
|
|
|
105
101
|
class Meta(NetBoxTable.Meta):
|
|
106
102
|
model = Record
|
|
107
|
-
fields = (
|
|
108
|
-
"name",
|
|
109
|
-
"zone",
|
|
110
|
-
"ttl",
|
|
111
|
-
"type",
|
|
112
|
-
"value",
|
|
113
|
-
"unicode_value",
|
|
114
|
-
"address_record",
|
|
115
|
-
"ipam_ip_address",
|
|
116
|
-
"active",
|
|
117
|
-
)
|
|
103
|
+
fields = ()
|
|
118
104
|
default_columns = (
|
|
119
105
|
"name",
|
|
120
106
|
"zone",
|
|
@@ -130,13 +116,7 @@ class RelatedRecordTable(RecordBaseTable):
|
|
|
130
116
|
|
|
131
117
|
class Meta(NetBoxTable.Meta):
|
|
132
118
|
model = Record
|
|
133
|
-
fields = (
|
|
134
|
-
"name",
|
|
135
|
-
"zone",
|
|
136
|
-
"type",
|
|
137
|
-
"value",
|
|
138
|
-
"unicode_value",
|
|
139
|
-
)
|
|
119
|
+
fields = ()
|
|
140
120
|
default_columns = (
|
|
141
121
|
"name",
|
|
142
122
|
"zone",
|
|
@@ -43,18 +43,8 @@ class RecordTemplateTable(TenancyColumnsMixin, NetBoxTable):
|
|
|
43
43
|
class Meta(NetBoxTable.Meta):
|
|
44
44
|
model = RecordTemplate
|
|
45
45
|
fields = (
|
|
46
|
-
"name",
|
|
47
|
-
"record_name",
|
|
48
|
-
"ttl",
|
|
49
|
-
"type",
|
|
50
|
-
"value",
|
|
51
|
-
"unicode_value",
|
|
52
46
|
"status",
|
|
53
|
-
"disable_ptr",
|
|
54
|
-
"tags",
|
|
55
47
|
"description",
|
|
56
|
-
"tenant",
|
|
57
|
-
"tenant_group",
|
|
58
48
|
)
|
|
59
49
|
default_columns = (
|
|
60
50
|
"name",
|
|
@@ -72,14 +62,7 @@ class RecordTemplateDisplayTable(RecordTemplateTable):
|
|
|
72
62
|
class Meta(NetBoxTable.Meta):
|
|
73
63
|
model = RecordTemplate
|
|
74
64
|
fields = (
|
|
75
|
-
"name",
|
|
76
|
-
"record_name",
|
|
77
|
-
"ttl",
|
|
78
|
-
"type",
|
|
79
|
-
"value",
|
|
80
|
-
"unicode_value",
|
|
81
65
|
"status",
|
|
82
|
-
"disable_ptr",
|
|
83
66
|
"description",
|
|
84
67
|
)
|
|
85
68
|
default_columns = (
|
netbox_dns/tables/registrar.py
CHANGED
|
@@ -19,13 +19,11 @@ class RegistrarTable(NetBoxTable):
|
|
|
19
19
|
class Meta(NetBoxTable.Meta):
|
|
20
20
|
model = Registrar
|
|
21
21
|
fields = (
|
|
22
|
-
"name",
|
|
23
22
|
"description",
|
|
24
23
|
"iana_id",
|
|
25
24
|
"referral_url",
|
|
26
25
|
"whois_server",
|
|
27
26
|
"abuse_email",
|
|
28
27
|
"abuse_phone",
|
|
29
|
-
"tags",
|
|
30
28
|
)
|
|
31
29
|
default_columns = ("name", "iana_id", "referral_url")
|