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/__init__.py
CHANGED
|
@@ -1,71 +1,136 @@
|
|
|
1
|
-
import
|
|
1
|
+
from django.utils.translation import gettext_lazy as _
|
|
2
|
+
from django.core.exceptions import ImproperlyConfigured
|
|
2
3
|
|
|
3
|
-
from
|
|
4
|
+
from netbox.plugins import PluginConfig
|
|
5
|
+
from netbox.plugins.utils import get_plugin_config
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
# NetBox 3.5.0 - 3.5.7, 3.5.9+
|
|
7
|
-
from extras.plugins import get_plugin_config
|
|
8
|
-
except ImportError:
|
|
9
|
-
# NetBox 3.5.8
|
|
10
|
-
from extras.plugins.utils import get_plugin_config
|
|
7
|
+
__version__ = "1.4.7"
|
|
11
8
|
|
|
12
|
-
|
|
9
|
+
|
|
10
|
+
def _check_list(setting):
|
|
11
|
+
if not isinstance(get_plugin_config("netbox_dns", setting), list):
|
|
12
|
+
raise ImproperlyConfigured(f"{setting} must be a list")
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
class DNSConfig(PluginConfig):
|
|
16
16
|
name = "netbox_dns"
|
|
17
|
-
verbose_name = "NetBox DNS"
|
|
18
|
-
description = "NetBox plugin for DNS data"
|
|
19
|
-
min_version = "3.
|
|
17
|
+
verbose_name = _("NetBox DNS")
|
|
18
|
+
description = _("NetBox plugin for DNS data")
|
|
19
|
+
min_version = "4.3.2"
|
|
20
|
+
max_version = "4.4.99"
|
|
20
21
|
version = __version__
|
|
21
22
|
author = "Peter Eckel"
|
|
22
|
-
author_email = "
|
|
23
|
-
middleware = ["netbox_dns.middleware.IpamCouplingMiddleware"]
|
|
23
|
+
author_email = "pete@netbox-dns.org"
|
|
24
24
|
required_settings = []
|
|
25
25
|
default_settings = {
|
|
26
26
|
"zone_default_ttl": 86400,
|
|
27
|
-
"
|
|
27
|
+
"zone_soa_ttl": 86400,
|
|
28
28
|
"zone_soa_serial": 1,
|
|
29
|
-
"zone_soa_refresh":
|
|
29
|
+
"zone_soa_refresh": 43200,
|
|
30
30
|
"zone_soa_retry": 7200,
|
|
31
|
-
"zone_soa_expire":
|
|
31
|
+
"zone_soa_expire": 2419200,
|
|
32
32
|
"zone_soa_minimum": 3600,
|
|
33
|
-
"
|
|
34
|
-
"
|
|
33
|
+
"zone_active_status": ["active", "dynamic"],
|
|
34
|
+
"zone_expiration_warning_days": 30,
|
|
35
|
+
"filter_record_types": [
|
|
36
|
+
# Obsolete or experimental RRTypes
|
|
37
|
+
"A6", # RFC 6563: Historic
|
|
38
|
+
"AFSDB", # RFC 5864: Obsolete
|
|
39
|
+
"APL", # RFC 3123: Experimental
|
|
40
|
+
"AVC", # https://www.iana.org/assignments/dns-parameters/AVC/avc-completed-template
|
|
41
|
+
"GPOS", # RFC 1712: Experimental
|
|
42
|
+
"KEY", # RFC 3755: Obsolete
|
|
43
|
+
"L32", # RFC 6742: Experimental
|
|
44
|
+
"L64", # RFC 6742: Experimental
|
|
45
|
+
"LP", # RFC 6742: Experimental
|
|
46
|
+
"MB", # RFC 2505: Unlikely to ever be adopted
|
|
47
|
+
"MD", # RFC 973: Obsolete
|
|
48
|
+
"MF", # RFC 973: Obsolete
|
|
49
|
+
"MG", # RFC 2505: Unlikely to ever be adopted
|
|
50
|
+
"MINFO", # RFC 2505: Unlikely to ever be adopted
|
|
51
|
+
"MR", # RFC 2505: Unlikely to ever be adopted
|
|
52
|
+
"NID", # RFC 6742: Experimental
|
|
53
|
+
"NINFO", # Application expired
|
|
54
|
+
"NULL", # RFC 1035: Obsolete
|
|
55
|
+
"NXT", # RFC 3755: Obsolete
|
|
56
|
+
"SIG", # RFC 3755: Obsolete
|
|
57
|
+
"SPF", # RFC 7208: Obsolete
|
|
58
|
+
"WKS", # RFC 1127: Not recommended
|
|
59
|
+
# RRTypes with no current use by any notable application
|
|
60
|
+
# (see https://en.wikipedia.org/wiki/List_of_DNS_record_types)
|
|
61
|
+
"RP",
|
|
62
|
+
"ISDN",
|
|
63
|
+
"RT",
|
|
64
|
+
"X25",
|
|
65
|
+
"NSAP",
|
|
66
|
+
"NSAP_PTR",
|
|
67
|
+
"PX",
|
|
68
|
+
"TYPE0", # Reserved
|
|
69
|
+
"UNSPEC", # Reserved
|
|
70
|
+
# DNSSEC RRTypes that are usually not manually maintained
|
|
71
|
+
"NSEC",
|
|
72
|
+
"NSEC3",
|
|
73
|
+
"RRSIG",
|
|
74
|
+
],
|
|
75
|
+
"filter_record_types+": [],
|
|
76
|
+
"filter_record_types-": [],
|
|
77
|
+
"custom_record_types": [],
|
|
78
|
+
"record_active_status": ["active"],
|
|
79
|
+
"dnssync_disabled": False,
|
|
80
|
+
"dnssync_ipaddress_active_status": ["active", "dhcp", "slaac"],
|
|
81
|
+
"dnssync_conflict_deactivate": False,
|
|
82
|
+
"dnssync_minimum_zone_labels": 2,
|
|
83
|
+
"tolerate_characters_in_zone_labels": "",
|
|
84
|
+
"tolerate_underscores_in_labels": False,
|
|
35
85
|
"tolerate_leading_underscore_types": [
|
|
36
|
-
"
|
|
86
|
+
"CNAME",
|
|
87
|
+
"DNAME",
|
|
37
88
|
"SRV",
|
|
89
|
+
"SVCB",
|
|
90
|
+
"TLSA",
|
|
91
|
+
"TXT",
|
|
38
92
|
],
|
|
39
93
|
"tolerate_non_rfc1035_types": [],
|
|
40
94
|
"enable_root_zones": False,
|
|
41
|
-
"enforce_unique_records":
|
|
95
|
+
"enforce_unique_records": True,
|
|
96
|
+
"enforce_unique_rrset_ttl": True,
|
|
97
|
+
"menu_name": "DNS",
|
|
98
|
+
"top_level_menu": True,
|
|
99
|
+
"convert_names_to_lowercase": False,
|
|
100
|
+
"dnssec_purge_keys": 7776000, # P90D
|
|
101
|
+
"dnssec_publish_safety": 3600, # PT1H
|
|
102
|
+
"dnssec_retire_safety": 3600, # PT1H
|
|
103
|
+
"dnssec_signatures_jitter": 43200, # PT12H
|
|
104
|
+
"dnssec_signatures_refresh": 432000, # P5D
|
|
105
|
+
"dnssec_signatures_validity": 1209600, # P14D
|
|
106
|
+
"dnssec_signatures_validity_dnskey": 1209600, # P14D
|
|
107
|
+
"dnssec_max_zone_ttl": 86400, # P1D
|
|
108
|
+
"dnssec_zone_propagation_delay": 300, # PT5M
|
|
109
|
+
"dnssec_parent_ds_ttl": 86400, # P1D
|
|
110
|
+
"dnssec_parent_propagation_delay": 3600, # PT1H
|
|
111
|
+
"dnssec_dnskey_ttl": 3600, # PT1H
|
|
42
112
|
}
|
|
43
113
|
base_url = "netbox-dns"
|
|
44
114
|
|
|
45
115
|
def ready(self):
|
|
46
|
-
|
|
47
|
-
# Check if required custom fields exist for IPAM coupling
|
|
48
|
-
#
|
|
49
|
-
if get_plugin_config("netbox_dns", "feature_ipam_coupling"):
|
|
50
|
-
from extras.models import CustomField
|
|
51
|
-
from ipam.models import IPAddress
|
|
52
|
-
from django.contrib.contenttypes.models import ContentType
|
|
116
|
+
super().ready()
|
|
53
117
|
|
|
54
|
-
|
|
55
|
-
required_cf = ("ipaddress_dns_record_name", "ipaddress_dns_zone_id")
|
|
118
|
+
import netbox_dns.signals.dnssec # noqa: F401
|
|
56
119
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
print(
|
|
61
|
-
"WARNING: 'feature_ipam_coupling' is enabled, but the required"
|
|
62
|
-
" custom fields for IPAM DNS coupling are missing. Please run"
|
|
63
|
-
" the Django management command 'setup_coupling' to create the"
|
|
64
|
-
" custom fields.",
|
|
65
|
-
file=sys.stderr,
|
|
66
|
-
)
|
|
120
|
+
if not get_plugin_config("netbox_dns", "dnssync_disabled"):
|
|
121
|
+
import netbox_dns.signals.ipam_dnssync # noqa: F401
|
|
122
|
+
import netbox_dns.tables.ipam_dnssync # noqa: F401
|
|
67
123
|
|
|
68
|
-
|
|
124
|
+
for setting in (
|
|
125
|
+
"zone_active_status",
|
|
126
|
+
"record_active_status",
|
|
127
|
+
"dnssync_ipaddress_active_status",
|
|
128
|
+
"tolerate_leading_underscore_types",
|
|
129
|
+
"filter_record_types",
|
|
130
|
+
"filter_record_types+",
|
|
131
|
+
"custom_record_types",
|
|
132
|
+
):
|
|
133
|
+
_check_list(setting)
|
|
69
134
|
|
|
70
135
|
|
|
71
136
|
#
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from django.utils.translation import gettext_lazy as _
|
|
2
|
+
from rest_framework import serializers
|
|
3
|
+
|
|
4
|
+
from netbox_dns.utilities import iso8601_to_int
|
|
5
|
+
|
|
6
|
+
__all__ = ("TimePeriodField",)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class TimePeriodField(serializers.IntegerField):
|
|
10
|
+
default_error_messages = {
|
|
11
|
+
"invalid": _(
|
|
12
|
+
"Enter a positive integer or an ISO8601 duration (W, M and Y are not supported)."
|
|
13
|
+
),
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
def to_internal_value(self, data):
|
|
17
|
+
try:
|
|
18
|
+
return iso8601_to_int(data)
|
|
19
|
+
except TypeError:
|
|
20
|
+
raise serializers.ValidationError(
|
|
21
|
+
"Enter a valid integer or ISO 8601 duration (W, M and Y are not supported)."
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
def to_representation(self, value):
|
|
25
|
+
return value
|
|
@@ -1,35 +1,46 @@
|
|
|
1
|
+
from django.utils.translation import gettext as _
|
|
1
2
|
from rest_framework import serializers
|
|
2
3
|
|
|
3
4
|
from netbox.api.serializers import WritableNestedSerializer
|
|
4
5
|
|
|
5
|
-
from netbox_dns.models import
|
|
6
|
+
from netbox_dns.models import Zone, Record, ZoneTemplate, RecordTemplate, DNSSECPolicy
|
|
7
|
+
from netbox_dns.api.serializers_.view import ViewSerializer
|
|
6
8
|
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
__all__ = (
|
|
11
|
+
"NestedZoneSerializer",
|
|
12
|
+
"NestedRecordSerializer",
|
|
13
|
+
"NestedZoneTemplateSerializer",
|
|
14
|
+
"NestedRecordTemplateSerializer",
|
|
15
|
+
"NestedDNSSECPolicySerializer",
|
|
16
|
+
)
|
|
17
|
+
|
|
15
18
|
|
|
19
|
+
class NestedZoneSerializer(WritableNestedSerializer):
|
|
16
20
|
class Meta:
|
|
17
|
-
model =
|
|
18
|
-
fields = ["id", "url", "display", "name"]
|
|
21
|
+
model = Zone
|
|
19
22
|
|
|
23
|
+
fields = (
|
|
24
|
+
"id",
|
|
25
|
+
"url",
|
|
26
|
+
"display",
|
|
27
|
+
"display_url",
|
|
28
|
+
"name",
|
|
29
|
+
"view",
|
|
30
|
+
"status",
|
|
31
|
+
"active",
|
|
32
|
+
"rfc2317_prefix",
|
|
33
|
+
)
|
|
20
34
|
|
|
21
|
-
#
|
|
22
|
-
# Zones
|
|
23
|
-
#
|
|
24
|
-
class NestedZoneSerializer(WritableNestedSerializer):
|
|
25
35
|
url = serializers.HyperlinkedIdentityField(
|
|
26
36
|
view_name="plugins-api:netbox_dns-api:zone-detail"
|
|
27
37
|
)
|
|
28
|
-
view =
|
|
38
|
+
view = ViewSerializer(
|
|
39
|
+
nested=True,
|
|
29
40
|
many=False,
|
|
30
41
|
required=False,
|
|
31
42
|
read_only=True,
|
|
32
|
-
help_text="View the zone belongs to",
|
|
43
|
+
help_text=_("View the zone belongs to"),
|
|
33
44
|
)
|
|
34
45
|
active = serializers.BooleanField(
|
|
35
46
|
required=False,
|
|
@@ -37,35 +48,65 @@ class NestedZoneSerializer(WritableNestedSerializer):
|
|
|
37
48
|
allow_null=True,
|
|
38
49
|
)
|
|
39
50
|
|
|
51
|
+
def to_representation(self, instance):
|
|
52
|
+
# +
|
|
53
|
+
# Workaround for the problem that the serializer does not return the
|
|
54
|
+
# annotation "active" when called with "many=False". See issue
|
|
55
|
+
# https://github.com/peteeckel/netbox-plugin-dns/issues/132
|
|
56
|
+
#
|
|
57
|
+
# TODO: Investigate root cause, probably in DRF.
|
|
58
|
+
# -
|
|
59
|
+
representation = super().to_representation(instance)
|
|
60
|
+
if representation.get("active") is None:
|
|
61
|
+
representation["active"] = instance.is_active
|
|
62
|
+
|
|
63
|
+
return representation
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class NestedZoneTemplateSerializer(WritableNestedSerializer):
|
|
40
67
|
class Meta:
|
|
41
|
-
model =
|
|
42
|
-
fields = ["id", "url", "display", "name", "view", "status", "active"]
|
|
68
|
+
model = ZoneTemplate
|
|
43
69
|
|
|
70
|
+
fields = (
|
|
71
|
+
"id",
|
|
72
|
+
"url",
|
|
73
|
+
"name",
|
|
74
|
+
"display",
|
|
75
|
+
"display_url",
|
|
76
|
+
"description",
|
|
77
|
+
)
|
|
44
78
|
|
|
45
|
-
#
|
|
46
|
-
# Nameservers
|
|
47
|
-
#
|
|
48
|
-
class NestedNameServerSerializer(WritableNestedSerializer):
|
|
49
79
|
url = serializers.HyperlinkedIdentityField(
|
|
50
|
-
view_name="plugins-api:netbox_dns-api:
|
|
80
|
+
view_name="plugins-api:netbox_dns-api:zonetemplate-detail"
|
|
51
81
|
)
|
|
52
82
|
|
|
83
|
+
|
|
84
|
+
class NestedRecordSerializer(WritableNestedSerializer):
|
|
53
85
|
class Meta:
|
|
54
|
-
model =
|
|
55
|
-
fields = ["id", "url", "display", "name"]
|
|
86
|
+
model = Record
|
|
56
87
|
|
|
88
|
+
fields = (
|
|
89
|
+
"id",
|
|
90
|
+
"url",
|
|
91
|
+
"display",
|
|
92
|
+
"display_url",
|
|
93
|
+
"type",
|
|
94
|
+
"name",
|
|
95
|
+
"value",
|
|
96
|
+
"status",
|
|
97
|
+
"ttl",
|
|
98
|
+
"zone",
|
|
99
|
+
"managed",
|
|
100
|
+
"active",
|
|
101
|
+
)
|
|
57
102
|
|
|
58
|
-
#
|
|
59
|
-
# Records
|
|
60
|
-
#
|
|
61
|
-
class NestedRecordSerializer(WritableNestedSerializer):
|
|
62
103
|
url = serializers.HyperlinkedIdentityField(
|
|
63
104
|
view_name="plugins-api:netbox_dns-api:record-detail"
|
|
64
105
|
)
|
|
65
106
|
zone = NestedZoneSerializer(
|
|
66
107
|
many=False,
|
|
67
108
|
required=False,
|
|
68
|
-
help_text="Zone the record belongs to",
|
|
109
|
+
help_text=_("Zone the record belongs to"),
|
|
69
110
|
)
|
|
70
111
|
active = serializers.BooleanField(
|
|
71
112
|
required=False,
|
|
@@ -73,43 +114,45 @@ class NestedRecordSerializer(WritableNestedSerializer):
|
|
|
73
114
|
allow_null=True,
|
|
74
115
|
)
|
|
75
116
|
|
|
117
|
+
|
|
118
|
+
class NestedRecordTemplateSerializer(WritableNestedSerializer):
|
|
76
119
|
class Meta:
|
|
77
|
-
model =
|
|
78
|
-
|
|
120
|
+
model = RecordTemplate
|
|
121
|
+
|
|
122
|
+
fields = (
|
|
79
123
|
"id",
|
|
80
124
|
"url",
|
|
81
125
|
"display",
|
|
126
|
+
"display_url",
|
|
82
127
|
"type",
|
|
83
128
|
"name",
|
|
129
|
+
"record_name",
|
|
84
130
|
"value",
|
|
85
131
|
"status",
|
|
86
132
|
"ttl",
|
|
87
|
-
"
|
|
88
|
-
|
|
89
|
-
]
|
|
133
|
+
"description",
|
|
134
|
+
)
|
|
90
135
|
|
|
91
|
-
|
|
92
|
-
#
|
|
93
|
-
# Registrars
|
|
94
|
-
#
|
|
95
|
-
class NestedRegistrarSerializer(WritableNestedSerializer):
|
|
96
136
|
url = serializers.HyperlinkedIdentityField(
|
|
97
|
-
view_name="plugins-api:netbox_dns-api:
|
|
137
|
+
view_name="plugins-api:netbox_dns-api:recordtemplate-detail"
|
|
98
138
|
)
|
|
99
139
|
|
|
140
|
+
|
|
141
|
+
class NestedDNSSECPolicySerializer(WritableNestedSerializer):
|
|
100
142
|
class Meta:
|
|
101
|
-
model =
|
|
102
|
-
fields = ["display", "id", "url", "name", "iana_id"]
|
|
143
|
+
model = DNSSECPolicy
|
|
103
144
|
|
|
145
|
+
fields = (
|
|
146
|
+
"id",
|
|
147
|
+
"url",
|
|
148
|
+
"display",
|
|
149
|
+
"display_url",
|
|
150
|
+
"name",
|
|
151
|
+
"description",
|
|
152
|
+
"status",
|
|
153
|
+
"inline_signing",
|
|
154
|
+
)
|
|
104
155
|
|
|
105
|
-
#
|
|
106
|
-
# Contacts
|
|
107
|
-
#
|
|
108
|
-
class NestedContactSerializer(WritableNestedSerializer):
|
|
109
156
|
url = serializers.HyperlinkedIdentityField(
|
|
110
|
-
view_name="plugins-api:netbox_dns-api:
|
|
157
|
+
view_name="plugins-api:netbox_dns-api:dnssecpolicy-detail"
|
|
111
158
|
)
|
|
112
|
-
|
|
113
|
-
class Meta:
|
|
114
|
-
model = Contact
|
|
115
|
-
fields = ["display", "id", "url", "name", "contact_id"]
|