netbox-plugin-dns 0.22.9__py3-none-any.whl → 1.0b1__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 +3 -14
- netbox_dns/api/nested_serializers.py +4 -60
- netbox_dns/api/serializers.py +8 -314
- netbox_dns/api/serializers_/__init__.py +0 -0
- netbox_dns/api/serializers_/contact.py +37 -0
- netbox_dns/api/serializers_/nameserver.py +39 -0
- netbox_dns/api/serializers_/record.py +90 -0
- netbox_dns/api/serializers_/registrar.py +31 -0
- netbox_dns/api/serializers_/view.py +29 -0
- netbox_dns/api/serializers_/zone.py +170 -0
- netbox_dns/api/views.py +13 -13
- netbox_dns/fields/network.py +1 -1
- netbox_dns/fields/rfc2317.py +1 -1
- netbox_dns/{filters → filtersets}/contact.py +2 -1
- netbox_dns/filtersets/nameserver.py +37 -0
- netbox_dns/{filters → filtersets}/record.py +51 -6
- netbox_dns/{filters → filtersets}/registrar.py +2 -1
- netbox_dns/{filters → filtersets}/view.py +2 -2
- netbox_dns/filtersets/zone.py +205 -0
- netbox_dns/forms/contact.py +61 -33
- netbox_dns/forms/nameserver.py +21 -8
- netbox_dns/forms/record.py +35 -36
- netbox_dns/forms/registrar.py +45 -15
- netbox_dns/forms/view.py +19 -8
- netbox_dns/forms/zone.py +112 -87
- netbox_dns/graphql/__init__.py +17 -27
- netbox_dns/graphql/filters.py +49 -0
- netbox_dns/graphql/schema.py +66 -7
- netbox_dns/graphql/types.py +146 -0
- netbox_dns/management/commands/cleanup_database.py +0 -4
- netbox_dns/management/commands/cleanup_rrset_ttl.py +3 -5
- netbox_dns/management/commands/setup_coupling.py +15 -15
- netbox_dns/management/commands/update_soa.py +1 -1
- netbox_dns/migrations/0001_squashed_netbox_dns_0_15.py +0 -27
- netbox_dns/migrations/0001_squashed_netbox_dns_0_22.py +556 -0
- netbox_dns/migrations/{0013_add_nameserver_zone_record_description.py → 0002_contact_description_registrar_description.py} +4 -9
- netbox_dns/migrations/0020_netbox_3_4.py +1 -1
- netbox_dns/models/contact.py +6 -1
- netbox_dns/models/nameserver.py +3 -3
- netbox_dns/models/record.py +8 -15
- netbox_dns/models/registrar.py +5 -1
- netbox_dns/models/view.py +1 -1
- netbox_dns/models/zone.py +6 -9
- netbox_dns/navigation.py +1 -15
- netbox_dns/signals/ipam_coupling.py +3 -8
- netbox_dns/tables/contact.py +1 -0
- netbox_dns/tables/nameserver.py +0 -2
- netbox_dns/tables/registrar.py +1 -0
- netbox_dns/template_content.py +3 -7
- netbox_dns/templates/netbox_dns/contact.html +60 -56
- netbox_dns/templates/netbox_dns/nameserver.html +27 -27
- netbox_dns/templates/netbox_dns/record.html +92 -94
- netbox_dns/templates/netbox_dns/registrar.html +38 -36
- netbox_dns/templates/netbox_dns/view.html +21 -21
- netbox_dns/templates/netbox_dns/zone/base.html +5 -3
- netbox_dns/templates/netbox_dns/zone/child.html +3 -3
- netbox_dns/templates/netbox_dns/zone/managed_record.html +1 -1
- netbox_dns/templates/netbox_dns/zone/record.html +3 -3
- netbox_dns/templates/netbox_dns/zone/registration.html +26 -27
- netbox_dns/templates/netbox_dns/zone/rfc2317_child_zone.html +1 -1
- netbox_dns/templates/netbox_dns/zone.html +150 -149
- netbox_dns/utilities/__init__.py +1 -6
- netbox_dns/utilities/ipam_coupling.py +2 -7
- netbox_dns/validators/dns_name.py +4 -9
- netbox_dns/validators/rfc2317.py +2 -2
- netbox_dns/views/contact.py +4 -4
- netbox_dns/views/nameserver.py +5 -5
- netbox_dns/views/record.py +19 -12
- netbox_dns/views/registrar.py +4 -4
- netbox_dns/views/view.py +4 -4
- netbox_dns/views/zone.py +7 -8
- {netbox_plugin_dns-0.22.9.dist-info → netbox_plugin_dns-1.0b1.dist-info}/METADATA +5 -7
- netbox_plugin_dns-1.0b1.dist-info/RECORD +103 -0
- netbox_dns/filters/nameserver.py +0 -18
- netbox_dns/filters/zone.py +0 -112
- netbox_dns/graphql/contact.py +0 -19
- netbox_dns/graphql/nameserver.py +0 -19
- netbox_dns/graphql/record.py +0 -19
- netbox_dns/graphql/registrar.py +0 -19
- netbox_dns/graphql/view.py +0 -19
- netbox_dns/graphql/zone.py +0 -19
- netbox_dns/migrations/0001_initial.py +0 -115
- netbox_dns/migrations/0002_zone_default_ttl.py +0 -18
- netbox_dns/migrations/0003_soa_managed_records.py +0 -112
- netbox_dns/migrations/0004_create_ptr_for_a_aaaa_records.py +0 -80
- netbox_dns/migrations/0005_update_ns_records.py +0 -41
- netbox_dns/migrations/0006_zone_soa_serial_auto.py +0 -29
- netbox_dns/migrations/0007_alter_zone_soa_serial_auto.py +0 -17
- netbox_dns/migrations/0008_zone_status_names.py +0 -21
- netbox_dns/migrations/0009_netbox32.py +0 -71
- netbox_dns/migrations/0010_update_soa_records.py +0 -58
- netbox_dns/migrations/0011_add_view_model.py +0 -70
- netbox_dns/migrations/0012_adjust_zone_and_record.py +0 -17
- netbox_dns/migrations/0014_add_view_description.py +0 -16
- netbox_dns/migrations/0015_add_record_status.py +0 -17
- netbox_dns/migrations/0016_cleanup_ptr_records.py +0 -38
- netbox_dns/migrations/0017_alter_record_ttl.py +0 -17
- netbox_dns/migrations/0018_zone_arpa_network.py +0 -51
- netbox_dns/migrations/0019_update_ns_ttl.py +0 -19
- netbox_plugin_dns-0.22.9.dist-info/RECORD +0 -117
- /netbox_dns/{filters → filtersets}/__init__.py +0 -0
- {netbox_plugin_dns-0.22.9.dist-info → netbox_plugin_dns-1.0b1.dist-info}/LICENSE +0 -0
- {netbox_plugin_dns-0.22.9.dist-info → netbox_plugin_dns-1.0b1.dist-info}/WHEEL +0 -0
netbox_dns/forms/zone.py
CHANGED
|
@@ -19,6 +19,7 @@ from utilities.forms.fields import (
|
|
|
19
19
|
DynamicModelChoiceField,
|
|
20
20
|
)
|
|
21
21
|
from utilities.forms.widgets import BulkEditNullBooleanSelect, APISelect
|
|
22
|
+
from utilities.forms.rendering import FieldSet
|
|
22
23
|
from utilities.forms import add_blank_choice
|
|
23
24
|
from tenancy.models import Tenant
|
|
24
25
|
from tenancy.forms import TenancyForm, TenancyFilterForm
|
|
@@ -106,51 +107,43 @@ class ZoneForm(TenancyForm, NetBoxModelForm):
|
|
|
106
107
|
)
|
|
107
108
|
|
|
108
109
|
fieldsets = (
|
|
109
|
-
(
|
|
110
|
-
"
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
"description",
|
|
118
|
-
),
|
|
110
|
+
FieldSet(
|
|
111
|
+
"view",
|
|
112
|
+
"name",
|
|
113
|
+
"status",
|
|
114
|
+
"nameservers",
|
|
115
|
+
"default_ttl",
|
|
116
|
+
"description",
|
|
117
|
+
name="Zone",
|
|
119
118
|
),
|
|
120
|
-
(
|
|
121
|
-
"
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
"soa_serial",
|
|
132
|
-
),
|
|
119
|
+
FieldSet(
|
|
120
|
+
"soa_ttl",
|
|
121
|
+
"soa_mname",
|
|
122
|
+
"soa_rname",
|
|
123
|
+
"soa_refresh",
|
|
124
|
+
"soa_retry",
|
|
125
|
+
"soa_expire",
|
|
126
|
+
"soa_minimum",
|
|
127
|
+
"soa_serial_auto",
|
|
128
|
+
"soa_serial",
|
|
129
|
+
name="SOA",
|
|
133
130
|
),
|
|
134
|
-
(
|
|
135
|
-
"
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
"rfc2317_parent_managed",
|
|
139
|
-
),
|
|
131
|
+
FieldSet(
|
|
132
|
+
"rfc2317_prefix",
|
|
133
|
+
"rfc2317_parent_managed",
|
|
134
|
+
name="RFC 2317",
|
|
140
135
|
),
|
|
141
|
-
(
|
|
142
|
-
"
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
"billing_c",
|
|
150
|
-
),
|
|
136
|
+
FieldSet(
|
|
137
|
+
"registrar",
|
|
138
|
+
"registry_domain_id",
|
|
139
|
+
"registrant",
|
|
140
|
+
"admin_c",
|
|
141
|
+
"tech_c",
|
|
142
|
+
"billing_c",
|
|
143
|
+
name="Domain Registration",
|
|
151
144
|
),
|
|
152
|
-
("
|
|
153
|
-
("
|
|
145
|
+
FieldSet("tags", name="Tags"),
|
|
146
|
+
FieldSet("tenant", name="Tenancy"),
|
|
154
147
|
)
|
|
155
148
|
|
|
156
149
|
def __init__(self, *args, **kwargs):
|
|
@@ -248,9 +241,20 @@ class ZoneForm(TenancyForm, NetBoxModelForm):
|
|
|
248
241
|
class ZoneFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
|
|
249
242
|
model = Zone
|
|
250
243
|
fieldsets = (
|
|
251
|
-
(
|
|
252
|
-
(
|
|
253
|
-
|
|
244
|
+
FieldSet("q", "filter_id", "tag"),
|
|
245
|
+
FieldSet(
|
|
246
|
+
"view_id", "status", "name", "nameservers", "description", name="Attributes"
|
|
247
|
+
),
|
|
248
|
+
FieldSet(
|
|
249
|
+
"registrar_id",
|
|
250
|
+
"registry_domain_id",
|
|
251
|
+
"registrant_id",
|
|
252
|
+
"admin_c_id",
|
|
253
|
+
"tech_c_id",
|
|
254
|
+
"billing_c_id",
|
|
255
|
+
name="Registration",
|
|
256
|
+
),
|
|
257
|
+
FieldSet("tenant_group_id", "tenant_id", name="Tenancy"),
|
|
254
258
|
)
|
|
255
259
|
|
|
256
260
|
view_id = DynamicModelMultipleChoiceField(
|
|
@@ -264,12 +268,43 @@ class ZoneFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
|
|
|
264
268
|
)
|
|
265
269
|
name = forms.CharField(
|
|
266
270
|
required=False,
|
|
267
|
-
label="Name",
|
|
268
271
|
)
|
|
269
272
|
nameservers = DynamicModelMultipleChoiceField(
|
|
270
273
|
queryset=NameServer.objects.all(),
|
|
271
274
|
required=False,
|
|
272
275
|
)
|
|
276
|
+
description = forms.CharField(
|
|
277
|
+
required=False,
|
|
278
|
+
)
|
|
279
|
+
registrar_id = DynamicModelMultipleChoiceField(
|
|
280
|
+
queryset=Registrar.objects.all(),
|
|
281
|
+
required=False,
|
|
282
|
+
label="Registrar",
|
|
283
|
+
)
|
|
284
|
+
registry_domain_id = forms.CharField(
|
|
285
|
+
required=False,
|
|
286
|
+
label="Registry Domain ID",
|
|
287
|
+
)
|
|
288
|
+
registrant_id = DynamicModelMultipleChoiceField(
|
|
289
|
+
queryset=Contact.objects.all(),
|
|
290
|
+
required=False,
|
|
291
|
+
label="Registrant",
|
|
292
|
+
)
|
|
293
|
+
admin_c_id = DynamicModelMultipleChoiceField(
|
|
294
|
+
queryset=Contact.objects.all(),
|
|
295
|
+
required=False,
|
|
296
|
+
label="Admin-C",
|
|
297
|
+
)
|
|
298
|
+
tech_c_id = DynamicModelMultipleChoiceField(
|
|
299
|
+
queryset=Contact.objects.all(),
|
|
300
|
+
required=False,
|
|
301
|
+
label="Tech-C",
|
|
302
|
+
)
|
|
303
|
+
billing_c_id = DynamicModelMultipleChoiceField(
|
|
304
|
+
queryset=Contact.objects.all(),
|
|
305
|
+
required=False,
|
|
306
|
+
label="Billing-C",
|
|
307
|
+
)
|
|
273
308
|
tag = TagFilterField(Zone)
|
|
274
309
|
|
|
275
310
|
|
|
@@ -656,50 +691,43 @@ class ZoneBulkEditForm(NetBoxModelBulkEditForm):
|
|
|
656
691
|
model = Zone
|
|
657
692
|
|
|
658
693
|
fieldsets = (
|
|
659
|
-
(
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
"description",
|
|
667
|
-
"tenant",
|
|
668
|
-
),
|
|
694
|
+
FieldSet(
|
|
695
|
+
"view",
|
|
696
|
+
"status",
|
|
697
|
+
"nameservers",
|
|
698
|
+
"default_ttl",
|
|
699
|
+
"description",
|
|
700
|
+
name="Attributes",
|
|
669
701
|
),
|
|
670
|
-
(
|
|
671
|
-
"
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
"soa_minimum",
|
|
682
|
-
),
|
|
702
|
+
FieldSet(
|
|
703
|
+
"soa_ttl",
|
|
704
|
+
"soa_mname",
|
|
705
|
+
"soa_rname",
|
|
706
|
+
"soa_refresh",
|
|
707
|
+
"soa_retry",
|
|
708
|
+
"soa_expire",
|
|
709
|
+
"soa_minimum",
|
|
710
|
+
"soa_serial_auto",
|
|
711
|
+
"soa_serial",
|
|
712
|
+
name="SOA",
|
|
683
713
|
),
|
|
684
|
-
(
|
|
685
|
-
"
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
"rfc2317_parent_managed",
|
|
689
|
-
),
|
|
714
|
+
FieldSet(
|
|
715
|
+
"rfc2317_prefix",
|
|
716
|
+
"rfc2317_parent_managed",
|
|
717
|
+
name="RFC 2317",
|
|
690
718
|
),
|
|
691
|
-
(
|
|
692
|
-
"
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
"billing_c",
|
|
700
|
-
),
|
|
719
|
+
FieldSet(
|
|
720
|
+
"registrar",
|
|
721
|
+
"registry_domain_id",
|
|
722
|
+
"registrant",
|
|
723
|
+
"admin_c",
|
|
724
|
+
"tech_c",
|
|
725
|
+
"billing_c",
|
|
726
|
+
name="Domain Registration",
|
|
701
727
|
),
|
|
728
|
+
FieldSet("tenant_group", "tenant", name="Tenancy"),
|
|
702
729
|
)
|
|
730
|
+
|
|
703
731
|
nullable_fields = (
|
|
704
732
|
"view",
|
|
705
733
|
"description",
|
|
@@ -713,9 +741,6 @@ class ZoneBulkEditForm(NetBoxModelBulkEditForm):
|
|
|
713
741
|
)
|
|
714
742
|
|
|
715
743
|
def clean(self):
|
|
716
|
-
"""
|
|
717
|
-
If soa_serial_auto is True, set soa_serial to None.
|
|
718
|
-
"""
|
|
719
744
|
cleaned_data = super().clean()
|
|
720
745
|
if cleaned_data.get("soa_serial_auto"):
|
|
721
746
|
cleaned_data["soa_serial"] = None
|
netbox_dns/graphql/__init__.py
CHANGED
|
@@ -1,27 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def convert_field_to_string(field, registry=None):
|
|
19
|
-
return graphene.String(description=field.help_text, required=not field.null)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
from .schema import *
|
|
23
|
-
|
|
24
|
-
from .view import *
|
|
25
|
-
from .zone import *
|
|
26
|
-
from .nameserver import *
|
|
27
|
-
from .record import *
|
|
1
|
+
from .schema import (
|
|
2
|
+
NetBoxDNSViewQuery,
|
|
3
|
+
NetBoxDNSNameServerQuery,
|
|
4
|
+
NetBoxDNSContactQuery,
|
|
5
|
+
NetBoxDNSRegistrarQuery,
|
|
6
|
+
NetBoxDNSZoneQuery,
|
|
7
|
+
NetBoxDNSRecordQuery,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
schema = [
|
|
11
|
+
NetBoxDNSNameServerQuery,
|
|
12
|
+
NetBoxDNSViewQuery,
|
|
13
|
+
NetBoxDNSZoneQuery,
|
|
14
|
+
NetBoxDNSRecordQuery,
|
|
15
|
+
NetBoxDNSContactQuery,
|
|
16
|
+
NetBoxDNSRegistrarQuery,
|
|
17
|
+
]
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import strawberry_django
|
|
2
|
+
|
|
3
|
+
from netbox.graphql.filter_mixins import autotype_decorator, BaseFilterMixin
|
|
4
|
+
|
|
5
|
+
from netbox_dns.models import NameServer, View, Zone, Record, Contact, Registrar
|
|
6
|
+
from netbox_dns.filtersets import (
|
|
7
|
+
NameServerFilterSet,
|
|
8
|
+
ViewFilterSet,
|
|
9
|
+
ZoneFilterSet,
|
|
10
|
+
RecordFilterSet,
|
|
11
|
+
ContactFilterSet,
|
|
12
|
+
RegistrarFilterSet,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@strawberry_django.filter(NameServer, lookups=True)
|
|
17
|
+
@autotype_decorator(NameServerFilterSet)
|
|
18
|
+
class NetBoxDNSNameServerFilter(BaseFilterMixin):
|
|
19
|
+
pass
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@strawberry_django.filter(View, lookups=True)
|
|
23
|
+
@autotype_decorator(ViewFilterSet)
|
|
24
|
+
class NetBoxDNSViewFilter(BaseFilterMixin):
|
|
25
|
+
pass
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@strawberry_django.filter(Zone, lookups=True)
|
|
29
|
+
@autotype_decorator(ZoneFilterSet)
|
|
30
|
+
class NetBoxDNSZoneFilter(BaseFilterMixin):
|
|
31
|
+
rfc2317_prefix: str | None
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@strawberry_django.filter(Record, lookups=True)
|
|
35
|
+
@autotype_decorator(RecordFilterSet)
|
|
36
|
+
class NetBoxDNSRecordFilter(BaseFilterMixin):
|
|
37
|
+
ip_address: str | None
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@strawberry_django.filter(Contact, lookups=True)
|
|
41
|
+
@autotype_decorator(ContactFilterSet)
|
|
42
|
+
class NetBoxDNSContactFilter(BaseFilterMixin):
|
|
43
|
+
pass
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@strawberry_django.filter(Registrar, lookups=True)
|
|
47
|
+
@autotype_decorator(RegistrarFilterSet)
|
|
48
|
+
class NetBoxDNSRegistrarFilter(BaseFilterMixin):
|
|
49
|
+
pass
|
netbox_dns/graphql/schema.py
CHANGED
|
@@ -1,11 +1,70 @@
|
|
|
1
|
-
from
|
|
2
|
-
from .nameserver import NameServerQuery
|
|
3
|
-
from .zone import ZoneQuery
|
|
4
|
-
from .record import RecordQuery
|
|
1
|
+
from typing import List
|
|
5
2
|
|
|
3
|
+
import strawberry
|
|
4
|
+
import strawberry_django
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
from netbox_dns.models import NameServer, View, Zone, Record, Contact, Registrar
|
|
7
|
+
from .types import (
|
|
8
|
+
NetBoxDNSNameServerType,
|
|
9
|
+
NetBoxDNSViewType,
|
|
10
|
+
NetBoxDNSZoneType,
|
|
11
|
+
NetBoxDNSRecordType,
|
|
12
|
+
NetBoxDNSContactType,
|
|
13
|
+
NetBoxDNSRegistrarType,
|
|
14
|
+
)
|
|
9
15
|
|
|
10
16
|
|
|
11
|
-
|
|
17
|
+
@strawberry.type
|
|
18
|
+
class NetBoxDNSNameServerQuery:
|
|
19
|
+
@strawberry.field
|
|
20
|
+
def netbox_dns_nameserver(self, id: int) -> NetBoxDNSNameServerType:
|
|
21
|
+
return NameServer.objects.get(pk=id)
|
|
22
|
+
|
|
23
|
+
netbox_dns_nameserver_list: List[NetBoxDNSNameServerType] = (
|
|
24
|
+
strawberry_django.field()
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@strawberry.type
|
|
29
|
+
class NetBoxDNSViewQuery:
|
|
30
|
+
@strawberry.field
|
|
31
|
+
def netbox_dns_view(self, id: int) -> NetBoxDNSViewType:
|
|
32
|
+
return View.objects.get(pk=id)
|
|
33
|
+
|
|
34
|
+
netbox_dns_view_list: List[NetBoxDNSViewType] = strawberry_django.field()
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@strawberry.type
|
|
38
|
+
class NetBoxDNSZoneQuery:
|
|
39
|
+
@strawberry.field
|
|
40
|
+
def netbox_dns_zone(self, id: int) -> NetBoxDNSZoneType:
|
|
41
|
+
return Zone.objects.get(pk=id)
|
|
42
|
+
|
|
43
|
+
netbox_dns_zone_list: List[NetBoxDNSZoneType] = strawberry_django.field()
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@strawberry.type
|
|
47
|
+
class NetBoxDNSRecordQuery:
|
|
48
|
+
@strawberry.field
|
|
49
|
+
def netbox_dns_record(self, id: int) -> NetBoxDNSRecordType:
|
|
50
|
+
return Record.objects.get(pk=id)
|
|
51
|
+
|
|
52
|
+
netbox_dns_record_list: List[NetBoxDNSRecordType] = strawberry_django.field()
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
@strawberry.type
|
|
56
|
+
class NetBoxDNSContactQuery:
|
|
57
|
+
@strawberry.field
|
|
58
|
+
def netbox_dns_contact(self, id: int) -> NetBoxDNSContactType:
|
|
59
|
+
return Contact.objects.get(pk=id)
|
|
60
|
+
|
|
61
|
+
netbox_dns_contact_list: List[NetBoxDNSContactType] = strawberry_django.field()
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@strawberry.type
|
|
65
|
+
class NetBoxDNSRegistrarQuery:
|
|
66
|
+
@strawberry.field
|
|
67
|
+
def netbox_dns_registrar(self, id: int) -> NetBoxDNSRegistrarType:
|
|
68
|
+
return Registrar.objects.get(pk=id)
|
|
69
|
+
|
|
70
|
+
netbox_dns_registrar_list: List[NetBoxDNSRegistrarType] = strawberry_django.field()
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
from typing import Annotated
|
|
2
|
+
|
|
3
|
+
import strawberry
|
|
4
|
+
import strawberry_django
|
|
5
|
+
|
|
6
|
+
from netbox.graphql.types import NetBoxObjectType
|
|
7
|
+
from netbox.graphql.scalars import BigInt
|
|
8
|
+
|
|
9
|
+
from netbox_dns.models import NameServer, View, Zone, Record, Contact, Registrar
|
|
10
|
+
from .filters import (
|
|
11
|
+
NetBoxDNSNameServerFilter,
|
|
12
|
+
NetBoxDNSViewFilter,
|
|
13
|
+
NetBoxDNSZoneFilter,
|
|
14
|
+
NetBoxDNSRecordFilter,
|
|
15
|
+
NetBoxDNSContactFilter,
|
|
16
|
+
NetBoxDNSRegistrarFilter,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@strawberry_django.type(NameServer, fields="__all__", filters=NetBoxDNSNameServerFilter)
|
|
21
|
+
class NetBoxDNSNameServerType(NetBoxObjectType):
|
|
22
|
+
name: str
|
|
23
|
+
description: str
|
|
24
|
+
tenant: Annotated["TenantType", strawberry.lazy("tenancy.graphql.types")] | None
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@strawberry_django.type(View, fields="__all__", filters=NetBoxDNSViewFilter)
|
|
28
|
+
class NetBoxDNSViewType(NetBoxObjectType):
|
|
29
|
+
name: str
|
|
30
|
+
description: str
|
|
31
|
+
tenant: Annotated["TenantType", strawberry.lazy("tenancy.graphql.types")] | None
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@strawberry_django.type(Zone, fields="__all__", filters=NetBoxDNSZoneFilter)
|
|
35
|
+
class NetBoxDNSZoneType(NetBoxObjectType):
|
|
36
|
+
name: str
|
|
37
|
+
status: str
|
|
38
|
+
active: bool
|
|
39
|
+
view: (
|
|
40
|
+
Annotated["NetBoxDNSViewType", strawberry.lazy("netbox_dns.graphql.types")]
|
|
41
|
+
| None
|
|
42
|
+
)
|
|
43
|
+
nameservers: (
|
|
44
|
+
Annotated[
|
|
45
|
+
"NetBoxDNSNameServerType", strawberry.lazy("netbox_dns.graphql.types")
|
|
46
|
+
]
|
|
47
|
+
| None
|
|
48
|
+
)
|
|
49
|
+
default_ttl: BigInt
|
|
50
|
+
soa_ttl: BigInt
|
|
51
|
+
soa_mname: Annotated[
|
|
52
|
+
"NetBoxDNSNameServerType", strawberry.lazy("netbox_dns.graphql.types")
|
|
53
|
+
]
|
|
54
|
+
soa_rname: str
|
|
55
|
+
soa_serial: BigInt
|
|
56
|
+
soa_refresh: BigInt
|
|
57
|
+
soa_retry: BigInt
|
|
58
|
+
soa_expire: BigInt
|
|
59
|
+
soa_minimum: BigInt
|
|
60
|
+
soa_serial_auto: bool
|
|
61
|
+
description: str | None
|
|
62
|
+
arpa_network: str | None
|
|
63
|
+
tenant: Annotated["TenantType", strawberry.lazy("tenancy.graphql.types")] | None
|
|
64
|
+
registrar: (
|
|
65
|
+
Annotated["NetBoxDNSRegistrarType", strawberry.lazy("netbox_dns.graphql.types")]
|
|
66
|
+
| None
|
|
67
|
+
)
|
|
68
|
+
registry_domain_id: str | None
|
|
69
|
+
registrant: (
|
|
70
|
+
Annotated["NetBoxDNSContactType", strawberry.lazy("netbox_dns.graphql.types")]
|
|
71
|
+
| None
|
|
72
|
+
)
|
|
73
|
+
admin_c: (
|
|
74
|
+
Annotated["NetBoxDNSContactType", strawberry.lazy("netbox_dns.graphql.types")]
|
|
75
|
+
| None
|
|
76
|
+
)
|
|
77
|
+
tech_c: (
|
|
78
|
+
Annotated["NetBoxDNSContactType", strawberry.lazy("netbox_dns.graphql.types")]
|
|
79
|
+
| None
|
|
80
|
+
)
|
|
81
|
+
billing_c: (
|
|
82
|
+
Annotated["NetBoxDNSContactType", strawberry.lazy("netbox_dns.graphql.types")]
|
|
83
|
+
| None
|
|
84
|
+
)
|
|
85
|
+
rfc2317_prefix: str | None
|
|
86
|
+
rfc2317_parent_managed: str
|
|
87
|
+
rfc2317_parent_zone: (
|
|
88
|
+
Annotated["NetBoxDNSZoneType", strawberry.lazy("netbox_dns.graphql.types")]
|
|
89
|
+
| None
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
@strawberry_django.type(Record, fields="__all__", filters=NetBoxDNSRecordFilter)
|
|
94
|
+
class NetBoxDNSRecordType(NetBoxObjectType):
|
|
95
|
+
name: str
|
|
96
|
+
zone: Annotated["NetBoxDNSZoneType", strawberry.lazy("netbox_dns.graphql.types")]
|
|
97
|
+
type: str
|
|
98
|
+
value: str
|
|
99
|
+
status: str
|
|
100
|
+
ttl: BigInt | None
|
|
101
|
+
managed: bool
|
|
102
|
+
ptr_record: (
|
|
103
|
+
Annotated["NetBoxDNSRecordType", strawberry.lazy("netbox_dns.graphql.types")]
|
|
104
|
+
| None
|
|
105
|
+
)
|
|
106
|
+
disable_ptr: bool
|
|
107
|
+
description: str | None
|
|
108
|
+
tenant: Annotated["TenantType", strawberry.lazy("tenancy.graphql.types")] | None
|
|
109
|
+
ip_address: str | None
|
|
110
|
+
ipam_ip_address: (
|
|
111
|
+
Annotated["IPAddressType", strawberry.lazy("ipam.graphql.types")] | None
|
|
112
|
+
)
|
|
113
|
+
rfc2317_cname_record: (
|
|
114
|
+
Annotated["NetBoxDNSRecordType", strawberry.lazy("netbox_dns.graphql.types")]
|
|
115
|
+
| None
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
@strawberry_django.type(Contact, fields="__all__", filters=NetBoxDNSContactFilter)
|
|
120
|
+
class NetBoxDNSContactType(NetBoxObjectType):
|
|
121
|
+
name: str
|
|
122
|
+
contact_id: str
|
|
123
|
+
description: str
|
|
124
|
+
organization: str
|
|
125
|
+
street: str
|
|
126
|
+
city: str
|
|
127
|
+
state_province: str
|
|
128
|
+
postal_code: str
|
|
129
|
+
country: str
|
|
130
|
+
phone: str
|
|
131
|
+
phone_ext: str
|
|
132
|
+
fax: str
|
|
133
|
+
fax_ext: str
|
|
134
|
+
email: str
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
@strawberry_django.type(Registrar, fields="__all__", filters=NetBoxDNSRegistrarFilter)
|
|
138
|
+
class NetBoxDNSRegistrarType(NetBoxObjectType):
|
|
139
|
+
name: str
|
|
140
|
+
description: str
|
|
141
|
+
iana_id: int
|
|
142
|
+
referral_url: str
|
|
143
|
+
whois_server: str
|
|
144
|
+
address: str
|
|
145
|
+
abuse_email: str
|
|
146
|
+
abuse_phone: str
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import dns
|
|
2
|
-
from dns import rdtypes, rdata, rdatatype, rdataclass
|
|
3
|
-
|
|
4
1
|
from netaddr import IPAddress, IPNetwork, AddrFormatError
|
|
5
2
|
|
|
6
3
|
from django.core.management.base import BaseCommand
|
|
@@ -10,7 +7,6 @@ from netbox_dns.models import (
|
|
|
10
7
|
ZoneStatusChoices,
|
|
11
8
|
Record,
|
|
12
9
|
RecordTypeChoices,
|
|
13
|
-
RecordClassChoices,
|
|
14
10
|
)
|
|
15
11
|
|
|
16
12
|
|
|
@@ -29,12 +29,10 @@ class Command(BaseCommand):
|
|
|
29
29
|
self.stdout.write("RRSet cleanup completed.")
|
|
30
30
|
|
|
31
31
|
def cleanup_rrset_ttl(self, **options):
|
|
32
|
-
verbose = options.get("verbosity") > 1
|
|
33
|
-
|
|
34
32
|
ttl_records = (
|
|
35
33
|
Record.objects.filter(ttl__isnull=False)
|
|
36
34
|
.exclude(type=RecordTypeChoices.SOA)
|
|
37
|
-
.exclude(type=RecordTypeChoices.PTR,
|
|
35
|
+
.exclude(type=RecordTypeChoices.PTR, maanged=True)
|
|
38
36
|
)
|
|
39
37
|
for record in ttl_records:
|
|
40
38
|
records = Record.objects.filter(
|
|
@@ -45,7 +43,7 @@ class Command(BaseCommand):
|
|
|
45
43
|
|
|
46
44
|
if records.count() == 1:
|
|
47
45
|
if options.get("verbosity") > 2:
|
|
48
|
-
self.stdout.write(f"Ignoring single record {record.
|
|
46
|
+
self.stdout.write(f"Ignoring single record {record.pk} ({record})")
|
|
49
47
|
continue
|
|
50
48
|
|
|
51
49
|
if options.get("max"):
|
|
@@ -56,7 +54,7 @@ class Command(BaseCommand):
|
|
|
56
54
|
for record in records.exclude(ttl=ttl):
|
|
57
55
|
if options.get("verbosity") > 1:
|
|
58
56
|
self.stdout.write(
|
|
59
|
-
f"Updating TTL for record {record.
|
|
57
|
+
f"Updating TTL for record {record.pk} ({record}) to {ttl}"
|
|
60
58
|
)
|
|
61
59
|
record.ttl = ttl
|
|
62
60
|
record.save(update_fields=["ttl"], update_rrset_ttl=False)
|