netbox-plugin-dns 0.22.8__py3-none-any.whl → 1.0.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 +4 -15
- 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 +34 -0
- netbox_dns/api/serializers_/zone.py +159 -0
- netbox_dns/api/views.py +13 -13
- netbox_dns/fields/network.py +21 -22
- netbox_dns/fields/rfc2317.py +3 -3
- 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 +65 -38
- netbox_dns/forms/registrar.py +45 -15
- netbox_dns/forms/view.py +23 -9
- netbox_dns/forms/zone.py +182 -188
- 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 +143 -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 +558 -0
- netbox_dns/migrations/{0013_add_nameserver_zone_record_description.py → 0002_contact_description_registrar_description.py} +4 -9
- netbox_dns/migrations/0003_default_view.py +15 -0
- netbox_dns/migrations/0004_create_and_assign_default_view.py +26 -0
- netbox_dns/migrations/0005_alter_zone_view_not_null.py +18 -0
- netbox_dns/migrations/0020_netbox_3_4.py +1 -1
- netbox_dns/models/contact.py +6 -1
- netbox_dns/models/nameserver.py +5 -1
- netbox_dns/models/record.py +32 -34
- netbox_dns/models/registrar.py +5 -1
- netbox_dns/models/view.py +54 -1
- netbox_dns/models/zone.py +68 -54
- netbox_dns/navigation.py +1 -15
- netbox_dns/signals/ipam_coupling.py +3 -9
- netbox_dns/tables/contact.py +1 -0
- netbox_dns/tables/nameserver.py +0 -2
- netbox_dns/tables/registrar.py +1 -0
- netbox_dns/tables/view.py +9 -2
- netbox_dns/template_content.py +4 -8
- 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 +25 -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 +148 -149
- netbox_dns/urls/__init__.py +17 -0
- netbox_dns/urls/contact.py +51 -0
- netbox_dns/urls/nameserver.py +69 -0
- netbox_dns/urls/record.py +41 -0
- netbox_dns/urls/registrar.py +63 -0
- netbox_dns/urls/view.py +39 -0
- netbox_dns/urls/zone.py +57 -0
- 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 +14 -29
- 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.8.dist-info → netbox_plugin_dns-1.0.0.dist-info}/METADATA +27 -13
- netbox_plugin_dns-1.0.0.dist-info/RECORD +112 -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_dns/urls.py +0 -297
- netbox_plugin_dns-0.22.8.dist-info/RECORD +0 -117
- /netbox_dns/{filters → filtersets}/__init__.py +0 -0
- {netbox_plugin_dns-0.22.8.dist-info → netbox_plugin_dns-1.0.0.dist-info}/LICENSE +0 -0
- {netbox_plugin_dns-0.22.8.dist-info → netbox_plugin_dns-1.0.0.dist-info}/WHEEL +0 -0
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,143 @@
|
|
|
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: Annotated["NetBoxDNSViewType", strawberry.lazy("netbox_dns.graphql.types")]
|
|
40
|
+
nameservers: (
|
|
41
|
+
Annotated[
|
|
42
|
+
"NetBoxDNSNameServerType", strawberry.lazy("netbox_dns.graphql.types")
|
|
43
|
+
]
|
|
44
|
+
| None
|
|
45
|
+
)
|
|
46
|
+
default_ttl: BigInt
|
|
47
|
+
soa_ttl: BigInt
|
|
48
|
+
soa_mname: Annotated[
|
|
49
|
+
"NetBoxDNSNameServerType", strawberry.lazy("netbox_dns.graphql.types")
|
|
50
|
+
]
|
|
51
|
+
soa_rname: str
|
|
52
|
+
soa_serial: BigInt
|
|
53
|
+
soa_refresh: BigInt
|
|
54
|
+
soa_retry: BigInt
|
|
55
|
+
soa_expire: BigInt
|
|
56
|
+
soa_minimum: BigInt
|
|
57
|
+
soa_serial_auto: bool
|
|
58
|
+
description: str | None
|
|
59
|
+
arpa_network: str | None
|
|
60
|
+
tenant: Annotated["TenantType", strawberry.lazy("tenancy.graphql.types")] | None
|
|
61
|
+
registrar: (
|
|
62
|
+
Annotated["NetBoxDNSRegistrarType", strawberry.lazy("netbox_dns.graphql.types")]
|
|
63
|
+
| None
|
|
64
|
+
)
|
|
65
|
+
registry_domain_id: str | None
|
|
66
|
+
registrant: (
|
|
67
|
+
Annotated["NetBoxDNSContactType", strawberry.lazy("netbox_dns.graphql.types")]
|
|
68
|
+
| None
|
|
69
|
+
)
|
|
70
|
+
admin_c: (
|
|
71
|
+
Annotated["NetBoxDNSContactType", strawberry.lazy("netbox_dns.graphql.types")]
|
|
72
|
+
| None
|
|
73
|
+
)
|
|
74
|
+
tech_c: (
|
|
75
|
+
Annotated["NetBoxDNSContactType", strawberry.lazy("netbox_dns.graphql.types")]
|
|
76
|
+
| None
|
|
77
|
+
)
|
|
78
|
+
billing_c: (
|
|
79
|
+
Annotated["NetBoxDNSContactType", strawberry.lazy("netbox_dns.graphql.types")]
|
|
80
|
+
| None
|
|
81
|
+
)
|
|
82
|
+
rfc2317_prefix: str | None
|
|
83
|
+
rfc2317_parent_managed: str
|
|
84
|
+
rfc2317_parent_zone: (
|
|
85
|
+
Annotated["NetBoxDNSZoneType", strawberry.lazy("netbox_dns.graphql.types")]
|
|
86
|
+
| None
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
@strawberry_django.type(Record, fields="__all__", filters=NetBoxDNSRecordFilter)
|
|
91
|
+
class NetBoxDNSRecordType(NetBoxObjectType):
|
|
92
|
+
name: str
|
|
93
|
+
zone: Annotated["NetBoxDNSZoneType", strawberry.lazy("netbox_dns.graphql.types")]
|
|
94
|
+
type: str
|
|
95
|
+
value: str
|
|
96
|
+
status: str
|
|
97
|
+
ttl: BigInt | None
|
|
98
|
+
managed: bool
|
|
99
|
+
ptr_record: (
|
|
100
|
+
Annotated["NetBoxDNSRecordType", strawberry.lazy("netbox_dns.graphql.types")]
|
|
101
|
+
| None
|
|
102
|
+
)
|
|
103
|
+
disable_ptr: bool
|
|
104
|
+
description: str | None
|
|
105
|
+
tenant: Annotated["TenantType", strawberry.lazy("tenancy.graphql.types")] | None
|
|
106
|
+
ip_address: str | None
|
|
107
|
+
ipam_ip_address: (
|
|
108
|
+
Annotated["IPAddressType", strawberry.lazy("ipam.graphql.types")] | None
|
|
109
|
+
)
|
|
110
|
+
rfc2317_cname_record: (
|
|
111
|
+
Annotated["NetBoxDNSRecordType", strawberry.lazy("netbox_dns.graphql.types")]
|
|
112
|
+
| None
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
@strawberry_django.type(Contact, fields="__all__", filters=NetBoxDNSContactFilter)
|
|
117
|
+
class NetBoxDNSContactType(NetBoxObjectType):
|
|
118
|
+
name: str
|
|
119
|
+
contact_id: str
|
|
120
|
+
description: str
|
|
121
|
+
organization: str
|
|
122
|
+
street: str
|
|
123
|
+
city: str
|
|
124
|
+
state_province: str
|
|
125
|
+
postal_code: str
|
|
126
|
+
country: str
|
|
127
|
+
phone: str
|
|
128
|
+
phone_ext: str
|
|
129
|
+
fax: str
|
|
130
|
+
fax_ext: str
|
|
131
|
+
email: str
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
@strawberry_django.type(Registrar, fields="__all__", filters=NetBoxDNSRegistrarFilter)
|
|
135
|
+
class NetBoxDNSRegistrarType(NetBoxObjectType):
|
|
136
|
+
name: str
|
|
137
|
+
description: str
|
|
138
|
+
iana_id: int
|
|
139
|
+
referral_url: str
|
|
140
|
+
whois_server: str
|
|
141
|
+
address: str
|
|
142
|
+
abuse_email: str
|
|
143
|
+
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, managed=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)
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
from django.core.management.base import BaseCommand
|
|
1
|
+
from django.core.management.base import BaseCommand
|
|
2
2
|
|
|
3
|
-
from
|
|
3
|
+
from core.models import ObjectType
|
|
4
4
|
from extras.models import CustomField
|
|
5
5
|
from extras.choices import CustomFieldTypeChoices
|
|
6
6
|
from ipam.models import IPAddress
|
|
7
|
-
from netbox_dns.models import
|
|
7
|
+
from netbox_dns.models import Zone
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class Command(BaseCommand):
|
|
@@ -17,7 +17,7 @@ class Command(BaseCommand):
|
|
|
17
17
|
parser.add_argument("--verbose", action="store_true", help="Verbose output")
|
|
18
18
|
|
|
19
19
|
def handle(self, *model_names, **options):
|
|
20
|
-
ipaddress_object_type =
|
|
20
|
+
ipaddress_object_type = ObjectType.objects.get_for_model(IPAddress)
|
|
21
21
|
|
|
22
22
|
if options["remove"]:
|
|
23
23
|
for cf in (
|
|
@@ -28,18 +28,18 @@ class Command(BaseCommand):
|
|
|
28
28
|
):
|
|
29
29
|
try:
|
|
30
30
|
CustomField.objects.get(
|
|
31
|
-
name=cf,
|
|
31
|
+
name=cf, object_types=ipaddress_object_type
|
|
32
32
|
).delete()
|
|
33
33
|
if options.get("verbose"):
|
|
34
34
|
self.stdout.write(f"Custom field '{cf}' removed")
|
|
35
|
-
except:
|
|
35
|
+
except CustomField.DoesNotExist:
|
|
36
36
|
pass
|
|
37
37
|
|
|
38
38
|
else:
|
|
39
39
|
if not CustomField.objects.filter(
|
|
40
40
|
name="ipaddress_dns_record_name",
|
|
41
41
|
type=CustomFieldTypeChoices.TYPE_TEXT,
|
|
42
|
-
|
|
42
|
+
object_types=ipaddress_object_type,
|
|
43
43
|
).exists():
|
|
44
44
|
cf_name = CustomField.objects.create(
|
|
45
45
|
name="ipaddress_dns_record_name",
|
|
@@ -48,7 +48,7 @@ class Command(BaseCommand):
|
|
|
48
48
|
required=False,
|
|
49
49
|
group_name="DNS",
|
|
50
50
|
)
|
|
51
|
-
cf_name.
|
|
51
|
+
cf_name.object_types.set([ipaddress_object_type])
|
|
52
52
|
if options.get("verbose"):
|
|
53
53
|
self.stdout.write(
|
|
54
54
|
"Created custom field 'ipaddress_dns_record_name'"
|
|
@@ -57,7 +57,7 @@ class Command(BaseCommand):
|
|
|
57
57
|
if not CustomField.objects.filter(
|
|
58
58
|
name="ipaddress_dns_record_ttl",
|
|
59
59
|
type=CustomFieldTypeChoices.TYPE_INTEGER,
|
|
60
|
-
|
|
60
|
+
object_types=ipaddress_object_type,
|
|
61
61
|
).exists():
|
|
62
62
|
cf_ttl = CustomField.objects.create(
|
|
63
63
|
name="ipaddress_dns_record_ttl",
|
|
@@ -68,14 +68,14 @@ class Command(BaseCommand):
|
|
|
68
68
|
required=False,
|
|
69
69
|
group_name="DNS",
|
|
70
70
|
)
|
|
71
|
-
cf_ttl.
|
|
71
|
+
cf_ttl.object_types.set([ipaddress_object_type])
|
|
72
72
|
if options.get("verbose"):
|
|
73
73
|
self.stdout.write("Created custom field 'ipaddress_dns_record_ttl'")
|
|
74
74
|
|
|
75
75
|
if not CustomField.objects.filter(
|
|
76
76
|
name="ipaddress_dns_record_disable_ptr",
|
|
77
77
|
type=CustomFieldTypeChoices.TYPE_BOOLEAN,
|
|
78
|
-
|
|
78
|
+
object_types=ipaddress_object_type,
|
|
79
79
|
).exists():
|
|
80
80
|
cf_disable_ptr = CustomField.objects.create(
|
|
81
81
|
name="ipaddress_dns_record_disable_ptr",
|
|
@@ -85,7 +85,7 @@ class Command(BaseCommand):
|
|
|
85
85
|
default=False,
|
|
86
86
|
group_name="DNS",
|
|
87
87
|
)
|
|
88
|
-
cf_disable_ptr.
|
|
88
|
+
cf_disable_ptr.object_types.set([ipaddress_object_type])
|
|
89
89
|
if options.get("verbose"):
|
|
90
90
|
self.stdout.write(
|
|
91
91
|
"Created custom field 'ipaddress_dns_record_disable_ptr'"
|
|
@@ -94,16 +94,16 @@ class Command(BaseCommand):
|
|
|
94
94
|
if not CustomField.objects.filter(
|
|
95
95
|
name="ipaddress_dns_zone_id",
|
|
96
96
|
type=CustomFieldTypeChoices.TYPE_OBJECT,
|
|
97
|
-
|
|
97
|
+
object_types=ipaddress_object_type,
|
|
98
98
|
).exists():
|
|
99
99
|
cf_zone = CustomField.objects.create(
|
|
100
100
|
name="ipaddress_dns_zone_id",
|
|
101
101
|
label="Zone",
|
|
102
102
|
type=CustomFieldTypeChoices.TYPE_OBJECT,
|
|
103
|
-
|
|
103
|
+
related_object_type=ObjectType.objects.get_for_model(Zone),
|
|
104
104
|
required=False,
|
|
105
105
|
group_name="DNS",
|
|
106
106
|
)
|
|
107
|
-
cf_zone.
|
|
107
|
+
cf_zone.object_types.set([ipaddress_object_type])
|
|
108
108
|
if options.get("verbose"):
|
|
109
109
|
self.stdout.write("Created custom field 'ipaddress_dns_zone_id'")
|
|
@@ -9,35 +9,8 @@ import netbox_dns.fields.network
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class Migration(migrations.Migration):
|
|
12
|
-
replaces = [
|
|
13
|
-
("netbox_dns", "0001_initial"),
|
|
14
|
-
("netbox_dns", "0015_add_record_status"),
|
|
15
|
-
("netbox_dns", "0013_add_nameserver_zone_record_description"),
|
|
16
|
-
("netbox_dns", "0011_add_view_model"),
|
|
17
|
-
("netbox_dns", "0002_zone_default_ttl"),
|
|
18
|
-
("netbox_dns", "0003_soa_managed_records"),
|
|
19
|
-
("netbox_dns", "0004_create_ptr_for_a_aaaa_records"),
|
|
20
|
-
("netbox_dns", "0006_zone_soa_serial_auto"),
|
|
21
|
-
("netbox_dns", "0007_alter_zone_soa_serial_auto"),
|
|
22
|
-
("netbox_dns", "0005_update_ns_records"),
|
|
23
|
-
("netbox_dns", "0008_zone_status_names"),
|
|
24
|
-
("netbox_dns", "0009_netbox32"),
|
|
25
|
-
("netbox_dns", "0010_update_soa_records"),
|
|
26
|
-
("netbox_dns", "0012_adjust_zone_and_record"),
|
|
27
|
-
("netbox_dns", "0014_add_view_description"),
|
|
28
|
-
("netbox_dns", "0016_cleanup_ptr_records"),
|
|
29
|
-
("netbox_dns", "0017_alter_record_ttl"),
|
|
30
|
-
("netbox_dns", "0018_zone_arpa_network"),
|
|
31
|
-
("netbox_dns", "0019_update_ns_ttl"),
|
|
32
|
-
]
|
|
33
|
-
|
|
34
|
-
initial = True
|
|
35
|
-
|
|
36
12
|
dependencies = [
|
|
37
|
-
("extras", "0072_created_datetimefield"),
|
|
38
|
-
("extras", "0062_clear_secrets_changelog"),
|
|
39
13
|
("extras", "0073_journalentry_tags_custom_fields"),
|
|
40
|
-
("extras", "0059_exporttemplate_as_attachment"),
|
|
41
14
|
]
|
|
42
15
|
|
|
43
16
|
operations = [
|