netbox-plugin-dns 0.21.4__py3-none-any.whl → 1.4.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.
- netbox_dns/__init__.py +106 -41
- netbox_dns/api/field_serializers.py +25 -0
- netbox_dns/api/nested_serializers.py +95 -52
- netbox_dns/api/serializers.py +14 -296
- netbox_dns/api/serializers_/__init__.py +0 -0
- netbox_dns/api/serializers_/dnssec_key_template.py +69 -0
- netbox_dns/api/serializers_/dnssec_policy.py +165 -0
- netbox_dns/api/serializers_/nameserver.py +56 -0
- netbox_dns/api/serializers_/prefix.py +18 -0
- netbox_dns/api/serializers_/record.py +105 -0
- netbox_dns/api/serializers_/record_template.py +71 -0
- netbox_dns/api/serializers_/registrar.py +45 -0
- netbox_dns/api/serializers_/registration_contact.py +50 -0
- netbox_dns/api/serializers_/view.py +81 -0
- netbox_dns/api/serializers_/zone.py +247 -0
- netbox_dns/api/serializers_/zone_template.py +157 -0
- netbox_dns/api/urls.py +13 -2
- netbox_dns/api/views.py +96 -58
- netbox_dns/choices/__init__.py +4 -0
- netbox_dns/choices/dnssec_key_template.py +67 -0
- netbox_dns/choices/dnssec_policy.py +40 -0
- netbox_dns/choices/record.py +104 -0
- netbox_dns/choices/utilities.py +4 -0
- netbox_dns/choices/zone.py +119 -0
- netbox_dns/fields/__init__.py +4 -0
- netbox_dns/fields/address.py +22 -16
- netbox_dns/fields/choice_array.py +33 -0
- netbox_dns/fields/ipam.py +15 -0
- netbox_dns/fields/network.py +42 -18
- netbox_dns/fields/rfc2317.py +97 -0
- netbox_dns/fields/timeperiod.py +33 -0
- netbox_dns/filters.py +7 -0
- netbox_dns/filtersets/__init__.py +12 -0
- netbox_dns/filtersets/dnssec_key_template.py +57 -0
- netbox_dns/filtersets/dnssec_policy.py +101 -0
- netbox_dns/filtersets/nameserver.py +46 -0
- netbox_dns/filtersets/record.py +135 -0
- netbox_dns/filtersets/record_template.py +59 -0
- netbox_dns/{filters → filtersets}/registrar.py +8 -1
- netbox_dns/{filters/contact.py → filtersets/registration_contact.py} +9 -3
- netbox_dns/filtersets/view.py +45 -0
- netbox_dns/filtersets/zone.py +254 -0
- netbox_dns/filtersets/zone_template.py +165 -0
- netbox_dns/forms/__init__.py +5 -1
- netbox_dns/forms/dnssec_key_template.py +250 -0
- netbox_dns/forms/dnssec_policy.py +654 -0
- netbox_dns/forms/nameserver.py +121 -27
- netbox_dns/forms/record.py +215 -104
- netbox_dns/forms/record_template.py +285 -0
- netbox_dns/forms/registrar.py +108 -31
- netbox_dns/forms/registration_contact.py +282 -0
- netbox_dns/forms/view.py +331 -20
- netbox_dns/forms/zone.py +769 -373
- netbox_dns/forms/zone_template.py +463 -0
- netbox_dns/graphql/__init__.py +25 -22
- netbox_dns/graphql/enums.py +41 -0
- netbox_dns/graphql/filter_lookups.py +13 -0
- netbox_dns/graphql/filters/__init__.py +12 -0
- netbox_dns/graphql/filters/dnssec_key_template.py +63 -0
- netbox_dns/graphql/filters/dnssec_policy.py +124 -0
- netbox_dns/graphql/filters/nameserver.py +32 -0
- netbox_dns/graphql/filters/record.py +89 -0
- netbox_dns/graphql/filters/record_template.py +55 -0
- netbox_dns/graphql/filters/registrar.py +30 -0
- netbox_dns/graphql/filters/registration_contact.py +27 -0
- netbox_dns/graphql/filters/view.py +28 -0
- netbox_dns/graphql/filters/zone.py +147 -0
- netbox_dns/graphql/filters/zone_template.py +97 -0
- netbox_dns/graphql/schema.py +89 -7
- netbox_dns/graphql/types.py +355 -0
- netbox_dns/locale/de/LC_MESSAGES/django.mo +0 -0
- netbox_dns/locale/en/LC_MESSAGES/django.mo +0 -0
- netbox_dns/locale/fr/LC_MESSAGES/django.mo +0 -0
- netbox_dns/management/commands/cleanup_database.py +175 -156
- netbox_dns/management/commands/cleanup_rrset_ttl.py +64 -0
- netbox_dns/management/commands/rebuild_dnssync.py +23 -0
- netbox_dns/management/commands/setup_dnssync.py +140 -0
- netbox_dns/migrations/0001_squashed_netbox_dns_0_15.py +0 -27
- netbox_dns/migrations/0001_squashed_netbox_dns_0_22.py +557 -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/0006_templating.py +172 -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 +36 -0
- netbox_dns/migrations/0010_view_ip_address_filter.py +18 -0
- netbox_dns/migrations/0011_rename_related_fields.py +63 -0
- netbox_dns/migrations/0012_natural_ordering.py +88 -0
- netbox_dns/migrations/0013_zonetemplate_soa_mname_zonetemplate_soa_rname.py +30 -0
- netbox_dns/migrations/0014_alter_unique_constraints_lowercase.py +42 -0
- netbox_dns/migrations/0015_dnssec.py +168 -0
- netbox_dns/migrations/{0015_add_record_status.py → 0016_dnssec_policy_status.py} +5 -4
- netbox_dns/migrations/0017_dnssec_policy_zone_zone_template.py +41 -0
- netbox_dns/migrations/0018_zone_domain_status_zone_expiration_date.py +23 -0
- netbox_dns/migrations/0019_dnssecpolicy_parental_agents.py +25 -0
- netbox_dns/migrations/0020_netbox_3_4.py +1 -1
- netbox_dns/migrations/0020_remove_dnssecpolicy_parental_agents_and_more.py +29 -0
- netbox_dns/migrations/0021_alter_record_ptr_record.py +25 -0
- netbox_dns/migrations/0021_record_ip_address.py +1 -1
- netbox_dns/migrations/0022_alter_record_ipam_ip_address.py +26 -0
- netbox_dns/migrations/0023_disable_ptr_false.py +27 -0
- netbox_dns/migrations/0024_zonetemplate_parental_agents.py +25 -0
- netbox_dns/migrations/0025_remove_zone_inline_signing_and_more.py +22 -0
- netbox_dns/migrations/0026_alter_dnssecpolicy_nsec3_opt_out.py +18 -0
- netbox_dns/migrations/0026_domain_registration.py +1 -1
- netbox_dns/migrations/0027_zone_comments.py +18 -0
- netbox_dns/migrations/0028_alter_zone_default_ttl_alter_zone_soa_minimum_and_more.py +54 -0
- netbox_dns/migrations/0028_rfc2317_fields.py +44 -0
- netbox_dns/migrations/0029_alter_registrationcontact_street.py +18 -0
- netbox_dns/migrations/0029_record_fqdn.py +30 -0
- netbox_dns/mixins/__init__.py +1 -0
- netbox_dns/mixins/object_modification.py +57 -0
- netbox_dns/models/__init__.py +5 -1
- netbox_dns/models/dnssec_key_template.py +114 -0
- netbox_dns/models/dnssec_policy.py +203 -0
- netbox_dns/models/nameserver.py +61 -30
- netbox_dns/models/record.py +781 -234
- netbox_dns/models/record_template.py +198 -0
- netbox_dns/models/registrar.py +34 -15
- netbox_dns/models/{contact.py → registration_contact.py} +72 -43
- netbox_dns/models/view.py +129 -9
- netbox_dns/models/zone.py +806 -242
- netbox_dns/models/zone_template.py +209 -0
- netbox_dns/navigation.py +176 -76
- netbox_dns/signals/__init__.py +0 -0
- netbox_dns/signals/dnssec.py +32 -0
- netbox_dns/signals/ipam_dnssync.py +216 -0
- netbox_dns/tables/__init__.py +5 -1
- netbox_dns/tables/dnssec_key_template.py +49 -0
- netbox_dns/tables/dnssec_policy.py +140 -0
- netbox_dns/tables/ipam_dnssync.py +12 -0
- netbox_dns/tables/nameserver.py +14 -17
- netbox_dns/tables/record.py +117 -59
- netbox_dns/tables/record_template.py +91 -0
- netbox_dns/tables/registrar.py +20 -10
- netbox_dns/tables/{contact.py → registration_contact.py} +22 -11
- netbox_dns/tables/view.py +47 -3
- netbox_dns/tables/zone.py +62 -31
- netbox_dns/tables/zone_template.py +78 -0
- netbox_dns/template_content.py +124 -38
- netbox_dns/templates/netbox_dns/dnsseckeytemplate.html +70 -0
- netbox_dns/templates/netbox_dns/dnssecpolicy.html +163 -0
- netbox_dns/templates/netbox_dns/nameserver.html +31 -28
- netbox_dns/templates/netbox_dns/record/managed.html +2 -1
- netbox_dns/templates/netbox_dns/record/related.html +17 -6
- netbox_dns/templates/netbox_dns/record.html +140 -93
- netbox_dns/templates/netbox_dns/recordtemplate.html +96 -0
- netbox_dns/templates/netbox_dns/registrar.html +41 -34
- netbox_dns/templates/netbox_dns/registrationcontact.html +76 -0
- netbox_dns/templates/netbox_dns/view/button.html +10 -0
- netbox_dns/templates/netbox_dns/view/prefix.html +44 -0
- netbox_dns/templates/netbox_dns/view/related.html +33 -0
- netbox_dns/templates/netbox_dns/view.html +62 -18
- netbox_dns/templates/netbox_dns/zone/base.html +6 -3
- netbox_dns/templates/netbox_dns/zone/child.html +6 -5
- netbox_dns/templates/netbox_dns/zone/child_zone.html +18 -0
- netbox_dns/templates/netbox_dns/zone/delegation_record.html +18 -0
- netbox_dns/templates/netbox_dns/zone/managed_record.html +1 -1
- netbox_dns/templates/netbox_dns/zone/record.html +6 -5
- netbox_dns/templates/netbox_dns/zone/registration.html +43 -24
- netbox_dns/templates/netbox_dns/zone/rfc2317_child_zone.html +18 -0
- netbox_dns/templates/netbox_dns/zone.html +178 -119
- netbox_dns/templates/netbox_dns/zonetemplate/child.html +46 -0
- netbox_dns/templates/netbox_dns/zonetemplate.html +124 -0
- netbox_dns/templatetags/netbox_dns.py +10 -0
- netbox_dns/urls.py +50 -210
- netbox_dns/utilities/__init__.py +3 -0
- netbox_dns/{utilities.py → utilities/conversions.py} +55 -7
- netbox_dns/utilities/dns.py +11 -0
- netbox_dns/utilities/ipam_dnssync.py +370 -0
- netbox_dns/validators/__init__.py +4 -0
- netbox_dns/validators/dns_name.py +116 -0
- netbox_dns/validators/dns_value.py +147 -0
- netbox_dns/validators/dnssec.py +148 -0
- netbox_dns/validators/rfc2317.py +28 -0
- netbox_dns/views/__init__.py +5 -1
- netbox_dns/views/dnssec_key_template.py +78 -0
- netbox_dns/views/dnssec_policy.py +146 -0
- netbox_dns/views/nameserver.py +34 -15
- netbox_dns/views/record.py +156 -15
- netbox_dns/views/record_template.py +93 -0
- netbox_dns/views/registrar.py +32 -13
- netbox_dns/views/registration_contact.py +101 -0
- netbox_dns/views/view.py +58 -14
- netbox_dns/views/zone.py +130 -33
- netbox_dns/views/zone_template.py +82 -0
- netbox_plugin_dns-1.4.7.dist-info/METADATA +132 -0
- netbox_plugin_dns-1.4.7.dist-info/RECORD +201 -0
- {netbox_plugin_dns-0.21.4.dist-info → netbox_plugin_dns-1.4.7.dist-info}/WHEEL +2 -1
- {netbox_plugin_dns-0.21.4.dist-info → netbox_plugin_dns-1.4.7.dist-info/licenses}/LICENSE +2 -1
- netbox_plugin_dns-1.4.7.dist-info/top_level.txt +1 -0
- netbox_dns/filters/__init__.py +0 -6
- netbox_dns/filters/nameserver.py +0 -18
- netbox_dns/filters/record.py +0 -53
- netbox_dns/filters/view.py +0 -18
- netbox_dns/filters/zone.py +0 -112
- netbox_dns/forms/contact.py +0 -211
- 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/management/commands/setup_coupling.py +0 -75
- netbox_dns/management/commands/update_soa.py +0 -22
- netbox_dns/middleware.py +0 -226
- 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/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/templates/netbox_dns/contact.html +0 -71
- netbox_dns/templates/netbox_dns/related_dns_objects.html +0 -21
- netbox_dns/templatetags/view_helpers.py +0 -15
- netbox_dns/validators.py +0 -57
- netbox_dns/views/contact.py +0 -83
- netbox_plugin_dns-0.21.4.dist-info/METADATA +0 -101
- netbox_plugin_dns-0.21.4.dist-info/RECORD +0 -110
netbox_dns/forms/nameserver.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from django import forms
|
|
2
|
+
from django.utils.translation import gettext_lazy as _
|
|
2
3
|
|
|
3
4
|
from netbox.forms import (
|
|
4
5
|
NetBoxModelBulkEditForm,
|
|
@@ -11,15 +12,53 @@ from utilities.forms.fields import (
|
|
|
11
12
|
TagFilterField,
|
|
12
13
|
CSVModelChoiceField,
|
|
13
14
|
DynamicModelChoiceField,
|
|
15
|
+
DynamicModelMultipleChoiceField,
|
|
14
16
|
)
|
|
15
|
-
from
|
|
17
|
+
from utilities.forms.rendering import FieldSet
|
|
18
|
+
from tenancy.models import Tenant, TenantGroup
|
|
16
19
|
from tenancy.forms import TenancyForm, TenancyFilterForm
|
|
17
20
|
|
|
18
|
-
from netbox_dns.models import NameServer
|
|
21
|
+
from netbox_dns.models import NameServer, Zone
|
|
19
22
|
from netbox_dns.utilities import name_to_unicode
|
|
20
23
|
|
|
21
24
|
|
|
25
|
+
__all__ = (
|
|
26
|
+
"NameServerForm",
|
|
27
|
+
"NameServerFilterForm",
|
|
28
|
+
"NameServerImportForm",
|
|
29
|
+
"NameServerBulkEditForm",
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
|
|
22
33
|
class NameServerForm(TenancyForm, NetBoxModelForm):
|
|
34
|
+
class Meta:
|
|
35
|
+
model = NameServer
|
|
36
|
+
|
|
37
|
+
fields = (
|
|
38
|
+
"name",
|
|
39
|
+
"description",
|
|
40
|
+
"tags",
|
|
41
|
+
"tenant_group",
|
|
42
|
+
"tenant",
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
fieldsets = (
|
|
46
|
+
FieldSet(
|
|
47
|
+
"name",
|
|
48
|
+
"description",
|
|
49
|
+
name=_("Nameserver"),
|
|
50
|
+
),
|
|
51
|
+
FieldSet(
|
|
52
|
+
"tenant_group",
|
|
53
|
+
"tenant",
|
|
54
|
+
name=_("Tenancy"),
|
|
55
|
+
),
|
|
56
|
+
FieldSet(
|
|
57
|
+
"tags",
|
|
58
|
+
name=_("Tags"),
|
|
59
|
+
),
|
|
60
|
+
)
|
|
61
|
+
|
|
23
62
|
def __init__(self, *args, **kwargs):
|
|
24
63
|
super().__init__(*args, **kwargs)
|
|
25
64
|
|
|
@@ -27,40 +66,59 @@ class NameServerForm(TenancyForm, NetBoxModelForm):
|
|
|
27
66
|
if initial_name:
|
|
28
67
|
self.initial["name"] = name_to_unicode(initial_name)
|
|
29
68
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
("
|
|
69
|
+
name = forms.CharField(
|
|
70
|
+
required=True,
|
|
71
|
+
label=_("Name"),
|
|
33
72
|
)
|
|
34
73
|
|
|
35
|
-
class Meta:
|
|
36
|
-
model = NameServer
|
|
37
|
-
fields = ("name", "description", "tags", "tenant")
|
|
38
|
-
|
|
39
74
|
|
|
40
75
|
class NameServerFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
|
|
41
76
|
model = NameServer
|
|
42
77
|
|
|
78
|
+
fieldsets = (
|
|
79
|
+
FieldSet(
|
|
80
|
+
"q",
|
|
81
|
+
"filter_id",
|
|
82
|
+
"tag",
|
|
83
|
+
),
|
|
84
|
+
FieldSet(
|
|
85
|
+
"name",
|
|
86
|
+
"zone_id",
|
|
87
|
+
"soa_zone_id",
|
|
88
|
+
"description",
|
|
89
|
+
name=_("Attributes"),
|
|
90
|
+
),
|
|
91
|
+
FieldSet(
|
|
92
|
+
"tenant_group_id",
|
|
93
|
+
"tenant_id",
|
|
94
|
+
name=_("Tenancy"),
|
|
95
|
+
),
|
|
96
|
+
)
|
|
97
|
+
|
|
43
98
|
name = forms.CharField(
|
|
44
99
|
required=False,
|
|
45
|
-
label="Name",
|
|
100
|
+
label=_("Name"),
|
|
46
101
|
)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
(None
|
|
51
|
-
("
|
|
52
|
-
("Tenant", ("tenant_group_id", "tenant_id")),
|
|
102
|
+
zone_id = DynamicModelMultipleChoiceField(
|
|
103
|
+
queryset=Zone.objects.all(),
|
|
104
|
+
required=False,
|
|
105
|
+
null_option=_("None"),
|
|
106
|
+
label=_("Zones"),
|
|
53
107
|
)
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
108
|
+
soa_zone_id = DynamicModelMultipleChoiceField(
|
|
109
|
+
queryset=Zone.objects.all(),
|
|
110
|
+
required=False,
|
|
111
|
+
null_option=_("None"),
|
|
112
|
+
label=_("SOA Zones"),
|
|
113
|
+
)
|
|
114
|
+
description = forms.CharField(
|
|
60
115
|
required=False,
|
|
61
|
-
|
|
116
|
+
label=_("Description"),
|
|
62
117
|
)
|
|
118
|
+
tag = TagFilterField(NameServer)
|
|
63
119
|
|
|
120
|
+
|
|
121
|
+
class NameServerImportForm(NetBoxModelImportForm):
|
|
64
122
|
class Meta:
|
|
65
123
|
model = NameServer
|
|
66
124
|
|
|
@@ -68,14 +126,50 @@ class NameServerImportForm(NetBoxModelImportForm):
|
|
|
68
126
|
"name",
|
|
69
127
|
"description",
|
|
70
128
|
"tenant",
|
|
129
|
+
"tags",
|
|
71
130
|
)
|
|
72
131
|
|
|
132
|
+
name = forms.CharField(
|
|
133
|
+
label=_("Name"),
|
|
134
|
+
)
|
|
135
|
+
tenant = CSVModelChoiceField(
|
|
136
|
+
queryset=Tenant.objects.all(),
|
|
137
|
+
to_field_name="name",
|
|
138
|
+
required=False,
|
|
139
|
+
label=_("Tenant"),
|
|
140
|
+
)
|
|
141
|
+
|
|
73
142
|
|
|
74
143
|
class NameServerBulkEditForm(NetBoxModelBulkEditForm):
|
|
75
144
|
model = NameServer
|
|
76
145
|
|
|
77
|
-
|
|
78
|
-
|
|
146
|
+
fieldsets = (
|
|
147
|
+
FieldSet(
|
|
148
|
+
"description",
|
|
149
|
+
"tenant_group",
|
|
150
|
+
"tenant",
|
|
151
|
+
"tags",
|
|
152
|
+
name=_("Attributes"),
|
|
153
|
+
),
|
|
154
|
+
)
|
|
79
155
|
|
|
80
|
-
|
|
81
|
-
|
|
156
|
+
nullable_fields = (
|
|
157
|
+
"description",
|
|
158
|
+
"tenant",
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
description = forms.CharField(
|
|
162
|
+
max_length=200,
|
|
163
|
+
required=False,
|
|
164
|
+
label=_("Description"),
|
|
165
|
+
)
|
|
166
|
+
tenant_group = DynamicModelChoiceField(
|
|
167
|
+
queryset=TenantGroup.objects.all(),
|
|
168
|
+
required=False,
|
|
169
|
+
label=_("Tenant Group"),
|
|
170
|
+
)
|
|
171
|
+
tenant = DynamicModelChoiceField(
|
|
172
|
+
queryset=Tenant.objects.all(),
|
|
173
|
+
required=False,
|
|
174
|
+
label=_("Tenant"),
|
|
175
|
+
)
|
netbox_dns/forms/record.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from django import forms
|
|
2
|
-
from django.
|
|
2
|
+
from django.utils.translation import gettext_lazy as _
|
|
3
3
|
|
|
4
4
|
from netbox.forms import (
|
|
5
5
|
NetBoxModelBulkEditForm,
|
|
@@ -14,50 +14,27 @@ from utilities.forms.fields import (
|
|
|
14
14
|
CSVModelChoiceField,
|
|
15
15
|
DynamicModelChoiceField,
|
|
16
16
|
)
|
|
17
|
-
from utilities.forms.widgets import BulkEditNullBooleanSelect
|
|
18
|
-
from utilities.forms import add_blank_choice
|
|
19
|
-
from
|
|
17
|
+
from utilities.forms.widgets import BulkEditNullBooleanSelect
|
|
18
|
+
from utilities.forms import BOOLEAN_WITH_BLANK_CHOICES, add_blank_choice
|
|
19
|
+
from utilities.forms.rendering import FieldSet
|
|
20
|
+
from tenancy.models import Tenant, TenantGroup
|
|
20
21
|
from tenancy.forms import TenancyForm, TenancyFilterForm
|
|
21
22
|
|
|
22
|
-
from netbox_dns.models import View, Zone, Record
|
|
23
|
+
from netbox_dns.models import View, Zone, Record
|
|
24
|
+
from netbox_dns.choices import RecordSelectableTypeChoices, RecordStatusChoices
|
|
23
25
|
from netbox_dns.utilities import name_to_unicode
|
|
26
|
+
from netbox_dns.fields import TimePeriodField
|
|
24
27
|
|
|
25
28
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
self.initial["name"] = name_to_unicode(initial_name)
|
|
33
|
-
|
|
34
|
-
disable_ptr = forms.BooleanField(
|
|
35
|
-
label="Disable PTR",
|
|
36
|
-
required=False,
|
|
37
|
-
)
|
|
38
|
-
ttl = forms.IntegerField(
|
|
39
|
-
required=False,
|
|
40
|
-
label="TTL",
|
|
41
|
-
)
|
|
29
|
+
__all__ = (
|
|
30
|
+
"RecordForm",
|
|
31
|
+
"RecordFilterForm",
|
|
32
|
+
"RecordImportForm",
|
|
33
|
+
"RecordBulkEditForm",
|
|
34
|
+
)
|
|
42
35
|
|
|
43
|
-
fieldsets = (
|
|
44
|
-
(
|
|
45
|
-
"Record",
|
|
46
|
-
(
|
|
47
|
-
"name",
|
|
48
|
-
"zone",
|
|
49
|
-
"type",
|
|
50
|
-
"value",
|
|
51
|
-
"status",
|
|
52
|
-
"ttl",
|
|
53
|
-
"disable_ptr",
|
|
54
|
-
"description",
|
|
55
|
-
"tags",
|
|
56
|
-
),
|
|
57
|
-
),
|
|
58
|
-
("Tenancy", ("tenant_group", "tenant")),
|
|
59
|
-
)
|
|
60
36
|
|
|
37
|
+
class RecordForm(TenancyForm, NetBoxModelForm):
|
|
61
38
|
class Meta:
|
|
62
39
|
model = Record
|
|
63
40
|
|
|
@@ -70,49 +47,178 @@ class RecordForm(TenancyForm, NetBoxModelForm):
|
|
|
70
47
|
"ttl",
|
|
71
48
|
"disable_ptr",
|
|
72
49
|
"description",
|
|
73
|
-
"
|
|
50
|
+
"tenant_group",
|
|
74
51
|
"tenant",
|
|
52
|
+
"tags",
|
|
75
53
|
)
|
|
76
54
|
|
|
55
|
+
labels = {
|
|
56
|
+
"disable_ptr": _("Disable PTR"),
|
|
57
|
+
"ttl": _("TTL"),
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
fieldsets = (
|
|
61
|
+
FieldSet(
|
|
62
|
+
"name",
|
|
63
|
+
"view",
|
|
64
|
+
"zone",
|
|
65
|
+
"type",
|
|
66
|
+
"value",
|
|
67
|
+
"status",
|
|
68
|
+
"ttl",
|
|
69
|
+
"disable_ptr",
|
|
70
|
+
"description",
|
|
71
|
+
name=_("Record"),
|
|
72
|
+
),
|
|
73
|
+
FieldSet(
|
|
74
|
+
"tenant_group",
|
|
75
|
+
"tenant",
|
|
76
|
+
name=_("Tenancy"),
|
|
77
|
+
),
|
|
78
|
+
FieldSet(
|
|
79
|
+
"tags",
|
|
80
|
+
name=_("Tags"),
|
|
81
|
+
),
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
def __init__(self, *args, **kwargs):
|
|
85
|
+
super().__init__(*args, **kwargs)
|
|
86
|
+
|
|
87
|
+
initial_name = self.initial.get("name")
|
|
88
|
+
if initial_name:
|
|
89
|
+
self.initial["name"] = name_to_unicode(initial_name)
|
|
90
|
+
|
|
91
|
+
view = DynamicModelChoiceField(
|
|
92
|
+
queryset=View.objects.all(),
|
|
93
|
+
required=False,
|
|
94
|
+
initial_params={
|
|
95
|
+
"zones": "$zone",
|
|
96
|
+
},
|
|
97
|
+
label=_("View"),
|
|
98
|
+
)
|
|
99
|
+
zone = DynamicModelChoiceField(
|
|
100
|
+
queryset=Zone.objects.all(),
|
|
101
|
+
required=True,
|
|
102
|
+
query_params={
|
|
103
|
+
"view_id": "$view",
|
|
104
|
+
},
|
|
105
|
+
label=_("Zone"),
|
|
106
|
+
)
|
|
107
|
+
type = forms.ChoiceField(
|
|
108
|
+
choices=add_blank_choice(RecordSelectableTypeChoices),
|
|
109
|
+
required=True,
|
|
110
|
+
label=_("Type"),
|
|
111
|
+
)
|
|
112
|
+
|
|
77
113
|
|
|
78
114
|
class RecordFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
|
|
79
115
|
model = Record
|
|
116
|
+
|
|
80
117
|
fieldsets = (
|
|
81
|
-
(
|
|
82
|
-
|
|
83
|
-
|
|
118
|
+
FieldSet(
|
|
119
|
+
"q",
|
|
120
|
+
"filter_id",
|
|
121
|
+
"tag",
|
|
122
|
+
),
|
|
123
|
+
FieldSet(
|
|
124
|
+
"name",
|
|
125
|
+
"view_id",
|
|
126
|
+
"zone_id",
|
|
127
|
+
"fqdn",
|
|
128
|
+
"type",
|
|
129
|
+
"value",
|
|
130
|
+
"status",
|
|
131
|
+
"ttl",
|
|
132
|
+
"disable_ptr",
|
|
133
|
+
"description",
|
|
134
|
+
"active",
|
|
135
|
+
name=_("Attributes"),
|
|
136
|
+
),
|
|
137
|
+
FieldSet(
|
|
138
|
+
"tenant_group_id",
|
|
139
|
+
"tenant_id",
|
|
140
|
+
name=_("Tenancy"),
|
|
141
|
+
),
|
|
84
142
|
)
|
|
85
143
|
|
|
86
144
|
type = forms.MultipleChoiceField(
|
|
87
|
-
choices=
|
|
145
|
+
choices=RecordSelectableTypeChoices,
|
|
88
146
|
required=False,
|
|
147
|
+
label=_("Type"),
|
|
89
148
|
)
|
|
90
149
|
name = forms.CharField(
|
|
91
150
|
required=False,
|
|
92
|
-
label="Name",
|
|
151
|
+
label=_("Name"),
|
|
152
|
+
)
|
|
153
|
+
fqdn = forms.CharField(
|
|
154
|
+
required=False,
|
|
155
|
+
label=_("FQDN"),
|
|
93
156
|
)
|
|
94
157
|
value = forms.CharField(
|
|
95
158
|
required=False,
|
|
96
|
-
label="Value",
|
|
159
|
+
label=_("Value"),
|
|
97
160
|
)
|
|
98
|
-
|
|
99
|
-
choices=add_blank_choice(RecordStatusChoices),
|
|
161
|
+
disable_ptr = forms.NullBooleanField(
|
|
100
162
|
required=False,
|
|
163
|
+
widget=forms.Select(choices=BOOLEAN_WITH_BLANK_CHOICES),
|
|
164
|
+
label=_("Disable PTR"),
|
|
101
165
|
)
|
|
102
|
-
|
|
103
|
-
|
|
166
|
+
status = forms.MultipleChoiceField(
|
|
167
|
+
choices=RecordStatusChoices,
|
|
168
|
+
required=False,
|
|
169
|
+
label=_("Status"),
|
|
170
|
+
)
|
|
171
|
+
ttl = TimePeriodField(
|
|
104
172
|
required=False,
|
|
105
|
-
label="
|
|
173
|
+
label=_("TTL"),
|
|
106
174
|
)
|
|
107
175
|
view_id = DynamicModelMultipleChoiceField(
|
|
108
176
|
queryset=View.objects.all(),
|
|
109
177
|
required=False,
|
|
110
|
-
label="View",
|
|
178
|
+
label=_("View"),
|
|
179
|
+
)
|
|
180
|
+
zone_id = DynamicModelMultipleChoiceField(
|
|
181
|
+
queryset=Zone.objects.all(),
|
|
182
|
+
required=False,
|
|
183
|
+
label=_("Zone"),
|
|
184
|
+
query_params={
|
|
185
|
+
"view_id": "$view_id",
|
|
186
|
+
},
|
|
187
|
+
)
|
|
188
|
+
active = forms.NullBooleanField(
|
|
189
|
+
required=False,
|
|
190
|
+
widget=forms.Select(choices=BOOLEAN_WITH_BLANK_CHOICES),
|
|
191
|
+
label=_("Active"),
|
|
192
|
+
)
|
|
193
|
+
description = forms.CharField(
|
|
194
|
+
required=False,
|
|
195
|
+
label=_("Description"),
|
|
111
196
|
)
|
|
112
197
|
tag = TagFilterField(Record)
|
|
113
198
|
|
|
114
199
|
|
|
115
200
|
class RecordImportForm(NetBoxModelImportForm):
|
|
201
|
+
class Meta:
|
|
202
|
+
model = Record
|
|
203
|
+
|
|
204
|
+
fields = (
|
|
205
|
+
"zone",
|
|
206
|
+
"view",
|
|
207
|
+
"type",
|
|
208
|
+
"name",
|
|
209
|
+
"value",
|
|
210
|
+
"ttl",
|
|
211
|
+
"disable_ptr",
|
|
212
|
+
"description",
|
|
213
|
+
"tenant",
|
|
214
|
+
"tags",
|
|
215
|
+
)
|
|
216
|
+
|
|
217
|
+
labels = {
|
|
218
|
+
"disable_ptr": _("Disable PTR"),
|
|
219
|
+
"ttl": _("TTL"),
|
|
220
|
+
}
|
|
221
|
+
|
|
116
222
|
def __init__(self, *args, **kwargs):
|
|
117
223
|
super().__init__(*args, **kwargs)
|
|
118
224
|
|
|
@@ -123,47 +229,45 @@ class RecordImportForm(NetBoxModelImportForm):
|
|
|
123
229
|
except forms.ValidationError:
|
|
124
230
|
pass
|
|
125
231
|
|
|
126
|
-
if view:
|
|
127
|
-
self.fields["zone"].queryset =
|
|
232
|
+
if view is not None:
|
|
233
|
+
self.fields["zone"].queryset = view.zones
|
|
128
234
|
else:
|
|
129
|
-
self.fields["zone"].queryset =
|
|
235
|
+
self.fields["zone"].queryset = View.get_default_view().zones
|
|
130
236
|
|
|
131
237
|
zone = CSVModelChoiceField(
|
|
132
238
|
queryset=Zone.objects.all(),
|
|
133
239
|
to_field_name="name",
|
|
134
240
|
required=True,
|
|
135
|
-
|
|
241
|
+
label=_("Zone"),
|
|
242
|
+
error_messages={
|
|
243
|
+
"invalid_choice": _("Zone %(value)s not found"),
|
|
244
|
+
},
|
|
136
245
|
)
|
|
137
246
|
view = CSVModelChoiceField(
|
|
138
247
|
queryset=View.objects.all(),
|
|
139
248
|
to_field_name="name",
|
|
140
249
|
required=False,
|
|
141
|
-
|
|
250
|
+
label=_("View"),
|
|
251
|
+
error_messages={
|
|
252
|
+
"invalid_choice": _("View %(value)s not found"),
|
|
253
|
+
},
|
|
254
|
+
help_text=_("This field is required if the zone is not in the default view"),
|
|
142
255
|
)
|
|
143
256
|
type = CSVChoiceField(
|
|
144
|
-
choices=
|
|
257
|
+
choices=RecordSelectableTypeChoices,
|
|
145
258
|
required=True,
|
|
146
|
-
|
|
259
|
+
label=_("Type"),
|
|
147
260
|
)
|
|
148
261
|
status = CSVChoiceField(
|
|
149
262
|
choices=RecordStatusChoices,
|
|
150
263
|
required=False,
|
|
151
|
-
|
|
152
|
-
)
|
|
153
|
-
ttl = forms.IntegerField(
|
|
154
|
-
required=False,
|
|
155
|
-
help_text="TTL",
|
|
156
|
-
)
|
|
157
|
-
disable_ptr = forms.BooleanField(
|
|
158
|
-
required=False,
|
|
159
|
-
label="Disable PTR",
|
|
160
|
-
help_text="Disable generation of a PTR record",
|
|
264
|
+
label=_("Status"),
|
|
161
265
|
)
|
|
162
266
|
tenant = CSVModelChoiceField(
|
|
163
267
|
queryset=Tenant.objects.all(),
|
|
164
268
|
to_field_name="name",
|
|
165
269
|
required=False,
|
|
166
|
-
|
|
270
|
+
label=_("Tenant"),
|
|
167
271
|
)
|
|
168
272
|
|
|
169
273
|
def is_valid(self):
|
|
@@ -174,67 +278,74 @@ class RecordImportForm(NetBoxModelImportForm):
|
|
|
174
278
|
|
|
175
279
|
return is_valid
|
|
176
280
|
|
|
177
|
-
class Meta:
|
|
178
|
-
model = Record
|
|
179
281
|
|
|
180
|
-
|
|
282
|
+
class RecordBulkEditForm(NetBoxModelBulkEditForm):
|
|
283
|
+
model = Record
|
|
284
|
+
|
|
285
|
+
fieldsets = (
|
|
286
|
+
FieldSet(
|
|
181
287
|
"zone",
|
|
182
|
-
"view",
|
|
183
288
|
"type",
|
|
184
|
-
"name",
|
|
185
289
|
"value",
|
|
290
|
+
"status",
|
|
186
291
|
"ttl",
|
|
187
292
|
"disable_ptr",
|
|
188
293
|
"description",
|
|
294
|
+
name=_("Attributes"),
|
|
295
|
+
),
|
|
296
|
+
FieldSet(
|
|
297
|
+
"tenant_group",
|
|
189
298
|
"tenant",
|
|
190
|
-
|
|
191
|
-
|
|
299
|
+
name=_("Tenancy"),
|
|
300
|
+
),
|
|
301
|
+
)
|
|
192
302
|
|
|
193
|
-
|
|
194
|
-
|
|
303
|
+
nullable_fields = (
|
|
304
|
+
"description",
|
|
305
|
+
"ttl",
|
|
306
|
+
"tenant",
|
|
307
|
+
)
|
|
195
308
|
|
|
196
309
|
zone = DynamicModelChoiceField(
|
|
197
310
|
queryset=Zone.objects.all(),
|
|
198
311
|
required=False,
|
|
199
|
-
|
|
200
|
-
attrs={"data-url": reverse_lazy("plugins-api:netbox_dns-api:zone-list")}
|
|
201
|
-
),
|
|
312
|
+
label=_("Zone"),
|
|
202
313
|
)
|
|
203
314
|
type = forms.ChoiceField(
|
|
204
|
-
choices=add_blank_choice(
|
|
315
|
+
choices=add_blank_choice(RecordSelectableTypeChoices),
|
|
205
316
|
required=False,
|
|
317
|
+
label=_("Type"),
|
|
206
318
|
)
|
|
207
319
|
value = forms.CharField(
|
|
208
320
|
required=False,
|
|
209
|
-
label="Value",
|
|
321
|
+
label=_("Value"),
|
|
210
322
|
)
|
|
211
323
|
status = forms.ChoiceField(
|
|
212
324
|
choices=add_blank_choice(RecordStatusChoices),
|
|
213
325
|
required=False,
|
|
326
|
+
label=_("Status"),
|
|
214
327
|
)
|
|
215
|
-
ttl =
|
|
328
|
+
ttl = TimePeriodField(
|
|
216
329
|
required=False,
|
|
217
|
-
label="TTL",
|
|
330
|
+
label=_("TTL"),
|
|
218
331
|
)
|
|
219
332
|
disable_ptr = forms.NullBooleanField(
|
|
220
|
-
required=False,
|
|
333
|
+
required=False,
|
|
334
|
+
widget=BulkEditNullBooleanSelect(),
|
|
335
|
+
label=_("Disable PTR"),
|
|
221
336
|
)
|
|
222
|
-
description = forms.CharField(
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
"tenant",
|
|
237
|
-
),
|
|
238
|
-
),
|
|
337
|
+
description = forms.CharField(
|
|
338
|
+
max_length=200,
|
|
339
|
+
required=False,
|
|
340
|
+
label=_("Description"),
|
|
341
|
+
)
|
|
342
|
+
tenant_group = DynamicModelChoiceField(
|
|
343
|
+
queryset=TenantGroup.objects.all(),
|
|
344
|
+
required=False,
|
|
345
|
+
label=_("Tenant Group"),
|
|
346
|
+
)
|
|
347
|
+
tenant = DynamicModelChoiceField(
|
|
348
|
+
queryset=Tenant.objects.all(),
|
|
349
|
+
required=False,
|
|
350
|
+
label=_("Tenant"),
|
|
239
351
|
)
|
|
240
|
-
nullable_fields = ("description", "ttl", "tenant")
|