netbox-plugin-dns 1.0.6__py3-none-any.whl → 1.1.0__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 +23 -4
- netbox_dns/api/nested_serializers.py +17 -16
- netbox_dns/api/serializers.py +2 -1
- netbox_dns/api/serializers_/prefix.py +18 -0
- netbox_dns/api/serializers_/record.py +1 -0
- netbox_dns/api/serializers_/{contact.py → registration_contact.py} +5 -5
- netbox_dns/api/serializers_/view.py +34 -2
- netbox_dns/api/serializers_/zone.py +5 -5
- netbox_dns/api/serializers_/zone_template.py +5 -5
- netbox_dns/api/urls.py +5 -2
- netbox_dns/api/views.py +17 -35
- netbox_dns/fields/__init__.py +1 -0
- netbox_dns/fields/ipam.py +15 -0
- netbox_dns/filtersets/__init__.py +1 -1
- netbox_dns/filtersets/record.py +1 -1
- netbox_dns/filtersets/{contact.py → registration_contact.py} +4 -4
- netbox_dns/filtersets/view.py +16 -0
- netbox_dns/filtersets/zone.py +15 -15
- netbox_dns/filtersets/zone_template.py +15 -15
- netbox_dns/forms/__init__.py +1 -1
- netbox_dns/forms/{contact.py → registration_contact.py} +16 -16
- netbox_dns/forms/view.py +204 -4
- netbox_dns/forms/zone.py +15 -18
- netbox_dns/forms/zone_template.py +13 -13
- netbox_dns/graphql/__init__.py +2 -2
- netbox_dns/graphql/filters.py +5 -5
- netbox_dns/graphql/schema.py +24 -44
- netbox_dns/graphql/types.py +41 -12
- netbox_dns/management/commands/rebuild_dnssync.py +18 -0
- netbox_dns/management/commands/setup_dnssync.py +140 -0
- netbox_dns/migrations/0007_alter_ordering_options.py +25 -0
- netbox_dns/migrations/0008_view_prefixes.py +18 -0
- netbox_dns/migrations/0009_rename_contact_registrationcontact.py +27 -0
- netbox_dns/models/__init__.py +1 -3
- netbox_dns/models/nameserver.py +8 -3
- netbox_dns/models/record.py +154 -24
- netbox_dns/models/record_template.py +4 -1
- netbox_dns/models/registrar.py +7 -1
- netbox_dns/models/{contact.py → registration_contact.py} +15 -9
- netbox_dns/models/view.py +14 -2
- netbox_dns/models/zone.py +76 -35
- netbox_dns/models/zone_template.py +12 -9
- netbox_dns/navigation.py +7 -7
- netbox_dns/signals/ipam_dnssync.py +224 -0
- netbox_dns/tables/__init__.py +1 -1
- netbox_dns/tables/ipam_dnssync.py +11 -0
- netbox_dns/tables/nameserver.py +1 -7
- netbox_dns/tables/record.py +43 -30
- netbox_dns/tables/record_template.py +0 -17
- netbox_dns/tables/registrar.py +0 -2
- netbox_dns/tables/{contact.py → registration_contact.py} +5 -6
- netbox_dns/tables/view.py +19 -4
- netbox_dns/tables/zone.py +0 -15
- netbox_dns/tables/zone_template.py +2 -16
- netbox_dns/template_content.py +41 -40
- netbox_dns/templates/netbox_dns/record.html +6 -6
- netbox_dns/templates/netbox_dns/{contact.html → registrationcontact.html} +1 -1
- netbox_dns/templates/netbox_dns/view/button.html +9 -0
- netbox_dns/templates/netbox_dns/view/prefix.html +41 -0
- netbox_dns/templates/netbox_dns/view/related.html +17 -0
- netbox_dns/templates/netbox_dns/view.html +25 -0
- netbox_dns/urls/__init__.py +2 -2
- 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/registration_contact.py +60 -0
- netbox_dns/urls/view.py +12 -20
- netbox_dns/urls/zone.py +8 -46
- netbox_dns/urls/zone_template.py +16 -26
- netbox_dns/utilities/__init__.py +2 -74
- netbox_dns/utilities/conversions.py +83 -0
- netbox_dns/utilities/ipam_dnssync.py +295 -0
- netbox_dns/validators/dns_name.py +9 -0
- netbox_dns/views/__init__.py +1 -1
- netbox_dns/views/nameserver.py +7 -3
- netbox_dns/views/record.py +12 -7
- netbox_dns/views/record_template.py +1 -1
- netbox_dns/views/registrar.py +0 -1
- netbox_dns/views/registration_contact.py +94 -0
- netbox_dns/views/view.py +32 -2
- 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.1.0.dist-info}/METADATA +2 -1
- netbox_plugin_dns-1.1.0.dist-info/RECORD +146 -0
- netbox_dns/management/commands/setup_coupling.py +0 -109
- netbox_dns/signals/ipam_coupling.py +0 -168
- netbox_dns/templates/netbox_dns/related_dns_objects.html +0 -21
- netbox_dns/urls/contact.py +0 -51
- netbox_dns/utilities/ipam_coupling.py +0 -112
- netbox_dns/views/contact.py +0 -95
- netbox_plugin_dns-1.0.6.dist-info/RECORD +0 -136
- {netbox_plugin_dns-1.0.6.dist-info → netbox_plugin_dns-1.1.0.dist-info}/LICENSE +0 -0
- {netbox_plugin_dns-1.0.6.dist-info → netbox_plugin_dns-1.1.0.dist-info}/WHEEL +0 -0
netbox_dns/graphql/schema.py
CHANGED
|
@@ -8,7 +8,7 @@ from netbox_dns.models import (
|
|
|
8
8
|
View,
|
|
9
9
|
Zone,
|
|
10
10
|
Record,
|
|
11
|
-
|
|
11
|
+
RegistrationContact,
|
|
12
12
|
Registrar,
|
|
13
13
|
ZoneTemplate,
|
|
14
14
|
RecordTemplate,
|
|
@@ -18,86 +18,66 @@ from .types import (
|
|
|
18
18
|
NetBoxDNSViewType,
|
|
19
19
|
NetBoxDNSZoneType,
|
|
20
20
|
NetBoxDNSRecordType,
|
|
21
|
-
|
|
21
|
+
NetBoxDNSRegistrationContactType,
|
|
22
22
|
NetBoxDNSRegistrarType,
|
|
23
23
|
NetBoxDNSZoneTemplateType,
|
|
24
24
|
NetBoxDNSRecordTemplateType,
|
|
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
|
|
67
|
-
class
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
54
|
+
@strawberry.type(name="Query")
|
|
55
|
+
class NetBoxDNSRegistrationContactQuery:
|
|
56
|
+
netbox_dns_registration_contact: NetBoxDNSRegistrationContactType = (
|
|
57
|
+
strawberry_django.field()
|
|
58
|
+
)
|
|
59
|
+
netbox_dns_registration_contact_list: List[NetBoxDNSRegistrationContactType] = (
|
|
60
|
+
strawberry_django.field()
|
|
61
|
+
)
|
|
73
62
|
|
|
74
63
|
|
|
75
|
-
@strawberry.type
|
|
64
|
+
@strawberry.type(name="Query")
|
|
76
65
|
class NetBoxDNSRegistrarQuery:
|
|
77
|
-
|
|
78
|
-
def netbox_dns_registrar(self, id: int) -> NetBoxDNSRegistrarType:
|
|
79
|
-
return Registrar.objects.get(pk=id)
|
|
80
|
-
|
|
66
|
+
netbox_dns_registrar: NetBoxDNSRegistrarType = strawberry_django.field()
|
|
81
67
|
netbox_dns_registrar_list: List[NetBoxDNSRegistrarType] = strawberry_django.field()
|
|
82
68
|
|
|
83
69
|
|
|
84
|
-
@strawberry.type
|
|
70
|
+
@strawberry.type(name="Query")
|
|
85
71
|
class NetBoxDNSZoneTemplateQuery:
|
|
86
|
-
|
|
87
|
-
def netbox_dns_zone_template(self, id: int) -> NetBoxDNSZoneTemplateType:
|
|
88
|
-
return ZoneTemplate.objects.get(pk=id)
|
|
89
|
-
|
|
72
|
+
netbox_dns_zone_template: NetBoxDNSZoneTemplateType = strawberry_django.field()
|
|
90
73
|
netbox_dns_zone_template_list: List[NetBoxDNSZoneTemplateType] = (
|
|
91
74
|
strawberry_django.field()
|
|
92
75
|
)
|
|
93
76
|
|
|
94
77
|
|
|
95
|
-
@strawberry.type
|
|
78
|
+
@strawberry.type(name="Query")
|
|
96
79
|
class NetBoxDNSRecordTemplateQuery:
|
|
97
|
-
|
|
98
|
-
def netbox_dns_record_template(self, id: int) -> NetBoxDNSRecordTemplateType:
|
|
99
|
-
return RecordTemplate.objects.get(pk=id)
|
|
100
|
-
|
|
80
|
+
netbox_dns_record_template: NetBoxDNSRecordTemplateType = strawberry_django.field()
|
|
101
81
|
netbox_dns_record_template_list: List[NetBoxDNSRecordTemplateType] = (
|
|
102
82
|
strawberry_django.field()
|
|
103
83
|
)
|
netbox_dns/graphql/types.py
CHANGED
|
@@ -4,6 +4,8 @@ import strawberry
|
|
|
4
4
|
import strawberry_django
|
|
5
5
|
|
|
6
6
|
from netbox.graphql.types import NetBoxObjectType
|
|
7
|
+
from tenancy.graphql.types import TenantType
|
|
8
|
+
from ipam.graphql.types import IPAddressType, PrefixType
|
|
7
9
|
from netbox.graphql.scalars import BigInt
|
|
8
10
|
|
|
9
11
|
from netbox_dns.models import (
|
|
@@ -11,7 +13,7 @@ from netbox_dns.models import (
|
|
|
11
13
|
View,
|
|
12
14
|
Zone,
|
|
13
15
|
Record,
|
|
14
|
-
|
|
16
|
+
RegistrationContact,
|
|
15
17
|
Registrar,
|
|
16
18
|
ZoneTemplate,
|
|
17
19
|
RecordTemplate,
|
|
@@ -21,7 +23,7 @@ from .filters import (
|
|
|
21
23
|
NetBoxDNSViewFilter,
|
|
22
24
|
NetBoxDNSZoneFilter,
|
|
23
25
|
NetBoxDNSRecordFilter,
|
|
24
|
-
|
|
26
|
+
NetBoxDNSRegistrationContactFilter,
|
|
25
27
|
NetBoxDNSRegistrarFilter,
|
|
26
28
|
NetBoxDNSZoneTemplateFilter,
|
|
27
29
|
NetBoxDNSRecordTemplateFilter,
|
|
@@ -40,6 +42,7 @@ class NetBoxDNSViewType(NetBoxObjectType):
|
|
|
40
42
|
name: str
|
|
41
43
|
description: str
|
|
42
44
|
tenant: Annotated["TenantType", strawberry.lazy("tenancy.graphql.types")] | None
|
|
45
|
+
prefixes: List[Annotated["PrefixType", strawberry.lazy("ipam.graphql.types")]]
|
|
43
46
|
|
|
44
47
|
|
|
45
48
|
@strawberry_django.type(Zone, fields="__all__", filters=NetBoxDNSZoneFilter)
|
|
@@ -74,19 +77,31 @@ class NetBoxDNSZoneType(NetBoxObjectType):
|
|
|
74
77
|
)
|
|
75
78
|
registry_domain_id: str | None
|
|
76
79
|
registrant: (
|
|
77
|
-
Annotated[
|
|
80
|
+
Annotated[
|
|
81
|
+
"NetBoxDNSRegistrationContactType",
|
|
82
|
+
strawberry.lazy("netbox_dns.graphql.types"),
|
|
83
|
+
]
|
|
78
84
|
| None
|
|
79
85
|
)
|
|
80
86
|
admin_c: (
|
|
81
|
-
Annotated[
|
|
87
|
+
Annotated[
|
|
88
|
+
"NetBoxDNSRegistrationContactType",
|
|
89
|
+
strawberry.lazy("netbox_dns.graphql.types"),
|
|
90
|
+
]
|
|
82
91
|
| None
|
|
83
92
|
)
|
|
84
93
|
tech_c: (
|
|
85
|
-
Annotated[
|
|
94
|
+
Annotated[
|
|
95
|
+
"NetBoxDNSRegistrationContactType",
|
|
96
|
+
strawberry.lazy("netbox_dns.graphql.types"),
|
|
97
|
+
]
|
|
86
98
|
| None
|
|
87
99
|
)
|
|
88
100
|
billing_c: (
|
|
89
|
-
Annotated[
|
|
101
|
+
Annotated[
|
|
102
|
+
"NetBoxDNSRegistrationContactType",
|
|
103
|
+
strawberry.lazy("netbox_dns.graphql.types"),
|
|
104
|
+
]
|
|
90
105
|
| None
|
|
91
106
|
)
|
|
92
107
|
rfc2317_prefix: str | None
|
|
@@ -123,8 +138,10 @@ class NetBoxDNSRecordType(NetBoxObjectType):
|
|
|
123
138
|
)
|
|
124
139
|
|
|
125
140
|
|
|
126
|
-
@strawberry_django.type(
|
|
127
|
-
|
|
141
|
+
@strawberry_django.type(
|
|
142
|
+
RegistrationContact, fields="__all__", filters=NetBoxDNSRegistrationContactFilter
|
|
143
|
+
)
|
|
144
|
+
class NetBoxDNSRegistrationContactType(NetBoxObjectType):
|
|
128
145
|
name: str
|
|
129
146
|
contact_id: str
|
|
130
147
|
description: str
|
|
@@ -175,19 +192,31 @@ class NetBoxDNSZoneTemplateType(NetBoxObjectType):
|
|
|
175
192
|
| None
|
|
176
193
|
)
|
|
177
194
|
registrant: (
|
|
178
|
-
Annotated[
|
|
195
|
+
Annotated[
|
|
196
|
+
"NetBoxDNSRegistrationContactType",
|
|
197
|
+
strawberry.lazy("netbox_dns.graphql.types"),
|
|
198
|
+
]
|
|
179
199
|
| None
|
|
180
200
|
)
|
|
181
201
|
admin_c: (
|
|
182
|
-
Annotated[
|
|
202
|
+
Annotated[
|
|
203
|
+
"NetBoxDNSRegistrationContactType",
|
|
204
|
+
strawberry.lazy("netbox_dns.graphql.types"),
|
|
205
|
+
]
|
|
183
206
|
| None
|
|
184
207
|
)
|
|
185
208
|
tech_c: (
|
|
186
|
-
Annotated[
|
|
209
|
+
Annotated[
|
|
210
|
+
"NetBoxDNSRegistrationContactType",
|
|
211
|
+
strawberry.lazy("netbox_dns.graphql.types"),
|
|
212
|
+
]
|
|
187
213
|
| None
|
|
188
214
|
)
|
|
189
215
|
billing_c: (
|
|
190
|
-
Annotated[
|
|
216
|
+
Annotated[
|
|
217
|
+
"NetBoxDNSRegistrationContactType",
|
|
218
|
+
strawberry.lazy("netbox_dns.graphql.types"),
|
|
219
|
+
]
|
|
191
220
|
| None
|
|
192
221
|
)
|
|
193
222
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from django.core.management.base import BaseCommand
|
|
2
|
+
|
|
3
|
+
from ipam.models import IPAddress
|
|
4
|
+
|
|
5
|
+
from netbox_dns.utilities import update_dns_records
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Command(BaseCommand):
|
|
9
|
+
help = "Rebuild DNSsync relationships between IP addresses and records"
|
|
10
|
+
|
|
11
|
+
def handle(self, *model_names, **options):
|
|
12
|
+
ip_addresses = IPAddress.objects.all()
|
|
13
|
+
for ip_address in ip_addresses:
|
|
14
|
+
if options.get("verbosity") >= 2:
|
|
15
|
+
self.stdout.write(
|
|
16
|
+
f"Updating DNS records for IP Address {ip_address}, VRF {ip_address.vrf}"
|
|
17
|
+
)
|
|
18
|
+
update_dns_records(ip_address)
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
from django.core.management.base import BaseCommand
|
|
2
|
+
|
|
3
|
+
from core.models import ObjectType
|
|
4
|
+
from extras.models import CustomField
|
|
5
|
+
from extras.choices import CustomFieldTypeChoices
|
|
6
|
+
from ipam.models import IPAddress
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Command(BaseCommand):
|
|
10
|
+
help = "Setup IPAddress custom fields for IPAM DNSsync"
|
|
11
|
+
|
|
12
|
+
def add_arguments(self, parser):
|
|
13
|
+
parser.add_argument(
|
|
14
|
+
"--remove", action="store_true", default=False, help="Remove custom fields"
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
def handle(self, *model_names, **options):
|
|
18
|
+
ipaddress_object_type = ObjectType.objects.get_for_model(IPAddress)
|
|
19
|
+
|
|
20
|
+
if options.get("remove"):
|
|
21
|
+
if options.get("verbosity"):
|
|
22
|
+
self.stdout.write("Trying to remove IPAM DNSsync custom fields")
|
|
23
|
+
for cf in (
|
|
24
|
+
"ipaddress_dns_disabled",
|
|
25
|
+
"ipaddress_dns_record_ttl",
|
|
26
|
+
"ipaddress_dns_record_disable_ptr",
|
|
27
|
+
):
|
|
28
|
+
try:
|
|
29
|
+
CustomField.objects.get(
|
|
30
|
+
name=cf, object_types=ipaddress_object_type
|
|
31
|
+
).delete()
|
|
32
|
+
if options.get("verbosity"):
|
|
33
|
+
self.stdout.write(f"Removed custom field '{cf}'")
|
|
34
|
+
except CustomField.DoesNotExist:
|
|
35
|
+
pass
|
|
36
|
+
return
|
|
37
|
+
|
|
38
|
+
# +
|
|
39
|
+
# Remove pre-existing IPAM Coupling custom fields
|
|
40
|
+
# -
|
|
41
|
+
if options.get("verbosity") >= 2:
|
|
42
|
+
self.stdout.write("Trying to remove obsolete IPAM Coupling custom fields")
|
|
43
|
+
for cf in (
|
|
44
|
+
"ipaddress_dns_record_name",
|
|
45
|
+
"ipaddress_dns_zone_id",
|
|
46
|
+
):
|
|
47
|
+
try:
|
|
48
|
+
CustomField.objects.get(
|
|
49
|
+
name=cf, object_types=ipaddress_object_type
|
|
50
|
+
).delete()
|
|
51
|
+
if options.get("verbosity"):
|
|
52
|
+
self.stdout.write(f"Removed custom field '{cf}'")
|
|
53
|
+
except CustomField.DoesNotExist:
|
|
54
|
+
pass
|
|
55
|
+
|
|
56
|
+
if options.get("verbosity") >= 2:
|
|
57
|
+
self.stdout.write("Creating IPAM DNSsync custom fields")
|
|
58
|
+
|
|
59
|
+
if not CustomField.objects.filter(
|
|
60
|
+
name="ipaddress_dns_disabled",
|
|
61
|
+
type=CustomFieldTypeChoices.TYPE_BOOLEAN,
|
|
62
|
+
object_types=ipaddress_object_type,
|
|
63
|
+
).exists():
|
|
64
|
+
cf_dnssync_disabled = CustomField.objects.create(
|
|
65
|
+
name="ipaddress_dns_disabled",
|
|
66
|
+
label="Disable DNSsync",
|
|
67
|
+
description="Disable DNS address and pointer record generation for this address",
|
|
68
|
+
type=CustomFieldTypeChoices.TYPE_BOOLEAN,
|
|
69
|
+
required=False,
|
|
70
|
+
default=False,
|
|
71
|
+
group_name="DNSsync",
|
|
72
|
+
is_cloneable=True,
|
|
73
|
+
weight=100,
|
|
74
|
+
)
|
|
75
|
+
cf_dnssync_disabled.object_types.set([ipaddress_object_type])
|
|
76
|
+
if options.get("verbosity"):
|
|
77
|
+
self.stdout.write("Created custom field 'ipaddress_dns_disabled'")
|
|
78
|
+
|
|
79
|
+
try:
|
|
80
|
+
cf_ttl = CustomField.objects.get(
|
|
81
|
+
name="ipaddress_dns_record_ttl",
|
|
82
|
+
type=CustomFieldTypeChoices.TYPE_INTEGER,
|
|
83
|
+
object_types=ipaddress_object_type,
|
|
84
|
+
)
|
|
85
|
+
if cf_ttl.group_name != "DNSsync":
|
|
86
|
+
cf_ttl.group_name = "DNSsync"
|
|
87
|
+
cf_ttl.description = ("TTL for DNS records created for this address",)
|
|
88
|
+
cf_ttl.save()
|
|
89
|
+
if options.get("verbosity"):
|
|
90
|
+
self.stdout.write("Updated custom field 'ipaddress_dns_record_ttl'")
|
|
91
|
+
except CustomField.DoesNotExist:
|
|
92
|
+
cf_ttl = CustomField.objects.create(
|
|
93
|
+
name="ipaddress_dns_record_ttl",
|
|
94
|
+
description="TTL for DNS records created for this address",
|
|
95
|
+
label="TTL",
|
|
96
|
+
type=CustomFieldTypeChoices.TYPE_INTEGER,
|
|
97
|
+
validation_minimum=0,
|
|
98
|
+
validation_maximum=2147483647,
|
|
99
|
+
required=False,
|
|
100
|
+
group_name="DNSsync",
|
|
101
|
+
is_cloneable=True,
|
|
102
|
+
weight=200,
|
|
103
|
+
)
|
|
104
|
+
cf_ttl.object_types.set([ipaddress_object_type])
|
|
105
|
+
if options.get("verbosity"):
|
|
106
|
+
self.stdout.write("Created custom field 'ipaddress_dns_record_ttl'")
|
|
107
|
+
|
|
108
|
+
try:
|
|
109
|
+
cf_disable_ptr = CustomField.objects.get(
|
|
110
|
+
name="ipaddress_dns_record_disable_ptr",
|
|
111
|
+
type=CustomFieldTypeChoices.TYPE_BOOLEAN,
|
|
112
|
+
object_types=ipaddress_object_type,
|
|
113
|
+
)
|
|
114
|
+
if cf_disable_ptr.group_name != "DNSsync":
|
|
115
|
+
cf_disable_ptr.group_name = "DNSsync"
|
|
116
|
+
cf_disable_ptr.description = (
|
|
117
|
+
"Disable DNS PTR record generation for this address",
|
|
118
|
+
)
|
|
119
|
+
cf_disable_ptr.save()
|
|
120
|
+
if options.get("verbosity"):
|
|
121
|
+
self.stdout.write(
|
|
122
|
+
"Updated custom field 'ipaddress_dns_record_disable_ptr'"
|
|
123
|
+
)
|
|
124
|
+
except CustomField.DoesNotExist:
|
|
125
|
+
cf_disable_ptr = CustomField.objects.create(
|
|
126
|
+
name="ipaddress_dns_record_disable_ptr",
|
|
127
|
+
description="Disable DNS PTR record generation for this address",
|
|
128
|
+
label="Disable PTR",
|
|
129
|
+
type=CustomFieldTypeChoices.TYPE_BOOLEAN,
|
|
130
|
+
required=False,
|
|
131
|
+
default=False,
|
|
132
|
+
group_name="DNSsync",
|
|
133
|
+
is_cloneable=True,
|
|
134
|
+
weight=300,
|
|
135
|
+
)
|
|
136
|
+
cf_disable_ptr.object_types.set([ipaddress_object_type])
|
|
137
|
+
if options.get("verbosity"):
|
|
138
|
+
self.stdout.write(
|
|
139
|
+
"Created custom field 'ipaddress_dns_record_disable_ptr'"
|
|
140
|
+
)
|
|
@@ -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
|
+
]
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from django.db import migrations, models
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Migration(migrations.Migration):
|
|
5
|
+
dependencies = [
|
|
6
|
+
("ipam", "0067_ipaddress_index_host"),
|
|
7
|
+
("netbox_dns", "0007_alter_ordering_options"),
|
|
8
|
+
]
|
|
9
|
+
|
|
10
|
+
operations = [
|
|
11
|
+
migrations.AddField(
|
|
12
|
+
model_name="view",
|
|
13
|
+
name="prefixes",
|
|
14
|
+
field=models.ManyToManyField(
|
|
15
|
+
blank=True, related_name="netbox_dns_views", to="ipam.prefix"
|
|
16
|
+
),
|
|
17
|
+
),
|
|
18
|
+
]
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from django.db import migrations
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Migration(migrations.Migration):
|
|
5
|
+
|
|
6
|
+
dependencies = [
|
|
7
|
+
("netbox_dns", "0008_view_prefixes"),
|
|
8
|
+
]
|
|
9
|
+
|
|
10
|
+
operations = [
|
|
11
|
+
migrations.RenameModel(
|
|
12
|
+
old_name="Contact",
|
|
13
|
+
new_name="RegistrationContact",
|
|
14
|
+
),
|
|
15
|
+
migrations.RunSQL(
|
|
16
|
+
"ALTER TABLE netbox_dns_contact_id_seq RENAME TO netbox_dns_registrationcontact_id_seq"
|
|
17
|
+
),
|
|
18
|
+
migrations.RunSQL(
|
|
19
|
+
"ALTER INDEX netbox_dns_contact_pkey RENAME TO netbox_dns_registrationcontact_pkey"
|
|
20
|
+
),
|
|
21
|
+
migrations.RunSQL(
|
|
22
|
+
"ALTER INDEX netbox_dns_contact_contact_id_50e9d89d_like RENAME TO netbox_dns_registrationcontact_contact_id_6ff98464_like"
|
|
23
|
+
),
|
|
24
|
+
migrations.RunSQL(
|
|
25
|
+
"ALTER INDEX netbox_dns_contact_contact_id_key RENAME TO netbox_dns_contact_registrationcontact_id_key"
|
|
26
|
+
),
|
|
27
|
+
]
|
netbox_dns/models/__init__.py
CHANGED
|
@@ -2,7 +2,7 @@ from .zone import *
|
|
|
2
2
|
from .nameserver import *
|
|
3
3
|
from .record import *
|
|
4
4
|
from .view import *
|
|
5
|
-
from .
|
|
5
|
+
from .registration_contact import *
|
|
6
6
|
from .registrar import *
|
|
7
7
|
from .zone_template import *
|
|
8
8
|
from .record_template import *
|
|
@@ -11,5 +11,3 @@ from .record_template import *
|
|
|
11
11
|
# Backwards compatibility fix, will be removed in version 1.1
|
|
12
12
|
# -
|
|
13
13
|
from netbox_dns.choices import *
|
|
14
|
-
|
|
15
|
-
from netbox_dns.signals import ipam_coupling
|
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()
|