netbox-plugin-dns 1.2.6__py3-none-any.whl → 1.2.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.
Potentially problematic release.
This version of netbox-plugin-dns might be problematic. Click here for more details.
- netbox_dns/__init__.py +16 -8
- netbox_dns/api/field_serializers.py +25 -0
- netbox_dns/api/nested_serializers.py +19 -1
- netbox_dns/api/serializers.py +3 -0
- netbox_dns/api/serializers_/dnssec_key_template.py +59 -0
- netbox_dns/api/serializers_/dnssec_policy.py +113 -0
- netbox_dns/api/serializers_/record.py +2 -0
- netbox_dns/api/serializers_/record_template.py +2 -0
- netbox_dns/api/serializers_/zone.py +20 -1
- netbox_dns/api/serializers_/zone_template.py +13 -4
- netbox_dns/api/urls.py +4 -0
- netbox_dns/api/views.py +18 -0
- netbox_dns/choices/__init__.py +2 -0
- netbox_dns/choices/dnssec_key_template.py +63 -0
- netbox_dns/choices/dnssec_policy.py +40 -0
- netbox_dns/choices/record.py +2 -25
- netbox_dns/choices/utilities.py +26 -0
- netbox_dns/choices/zone.py +96 -1
- netbox_dns/fields/__init__.py +1 -0
- netbox_dns/fields/choice_array.py +33 -0
- netbox_dns/fields/timeperiod.py +15 -13
- netbox_dns/filtersets/__init__.py +3 -0
- netbox_dns/filtersets/dnssec_key_template.py +51 -0
- netbox_dns/filtersets/dnssec_policy.py +97 -0
- netbox_dns/filtersets/zone.py +30 -6
- netbox_dns/filtersets/zone_template.py +13 -2
- netbox_dns/forms/__init__.py +2 -0
- netbox_dns/forms/dnssec_key_template.py +189 -0
- netbox_dns/forms/dnssec_policy.py +593 -0
- netbox_dns/forms/nameserver.py +2 -0
- netbox_dns/forms/record_template.py +1 -0
- netbox_dns/forms/zone.py +120 -9
- netbox_dns/forms/zone_template.py +38 -0
- netbox_dns/graphql/__init__.py +7 -3
- netbox_dns/graphql/filters.py +16 -0
- netbox_dns/graphql/schema.py +20 -0
- netbox_dns/graphql/types.py +67 -3
- netbox_dns/locale/de/LC_MESSAGES/django.mo +0 -0
- netbox_dns/locale/fr/LC_MESSAGES/django.mo +0 -0
- netbox_dns/migrations/0015_dnssec.py +168 -0
- netbox_dns/migrations/0016_dnssec_policy_status.py +18 -0
- 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/models/__init__.py +2 -0
- netbox_dns/models/dnssec_key_template.py +114 -0
- netbox_dns/models/dnssec_policy.py +203 -0
- netbox_dns/models/record.py +1 -1
- netbox_dns/models/zone.py +74 -19
- netbox_dns/models/zone_template.py +17 -7
- netbox_dns/navigation.py +49 -0
- netbox_dns/signals/dnssec.py +32 -0
- netbox_dns/tables/__init__.py +2 -0
- netbox_dns/tables/dnssec_key_template.py +48 -0
- netbox_dns/tables/dnssec_policy.py +131 -0
- netbox_dns/tables/zone.py +23 -2
- netbox_dns/tables/zone_template.py +4 -0
- netbox_dns/template_content.py +2 -1
- netbox_dns/templates/netbox_dns/dnsseckeytemplate.html +70 -0
- netbox_dns/templates/netbox_dns/dnssecpolicy.html +155 -0
- netbox_dns/templates/netbox_dns/zone/registration.html +19 -0
- netbox_dns/templates/netbox_dns/zone.html +16 -0
- netbox_dns/templates/netbox_dns/zonetemplate/child.html +46 -0
- netbox_dns/templates/netbox_dns/zonetemplate.html +12 -0
- netbox_dns/urls.py +23 -0
- netbox_dns/utilities/conversions.py +13 -0
- netbox_dns/validators/__init__.py +1 -0
- netbox_dns/validators/dnssec.py +148 -0
- netbox_dns/views/__init__.py +2 -0
- netbox_dns/views/dnssec_key_template.py +87 -0
- netbox_dns/views/dnssec_policy.py +155 -0
- netbox_dns/views/zone.py +11 -1
- {netbox_plugin_dns-1.2.6.dist-info → netbox_plugin_dns-1.2.7.dist-info}/METADATA +3 -2
- {netbox_plugin_dns-1.2.6.dist-info → netbox_plugin_dns-1.2.7.dist-info}/RECORD +76 -50
- {netbox_plugin_dns-1.2.6.dist-info → netbox_plugin_dns-1.2.7.dist-info}/WHEEL +1 -1
- {netbox_plugin_dns-1.2.6.dist-info → netbox_plugin_dns-1.2.7.dist-info/licenses}/LICENSE +0 -0
- {netbox_plugin_dns-1.2.6.dist-info → netbox_plugin_dns-1.2.7.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from django.core.exceptions import ImproperlyConfigured
|
|
2
|
+
|
|
3
|
+
from netbox.plugins.utils import get_plugin_config
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def define_choice_attributes(filter_name=None):
|
|
7
|
+
try:
|
|
8
|
+
if filter_name is not None:
|
|
9
|
+
filter_choices = get_plugin_config("netbox_dns", filter_name, [])
|
|
10
|
+
else:
|
|
11
|
+
filter_choices = []
|
|
12
|
+
except ImproperlyConfigured:
|
|
13
|
+
filter_choices = []
|
|
14
|
+
|
|
15
|
+
def decorator(cls):
|
|
16
|
+
choices = []
|
|
17
|
+
for choice in cls._choices:
|
|
18
|
+
if choice[0] not in filter_choices:
|
|
19
|
+
setattr(cls, choice[0], choice[0])
|
|
20
|
+
choices.append(choice)
|
|
21
|
+
cls._choices = choices
|
|
22
|
+
cls.CHOICES = choices
|
|
23
|
+
|
|
24
|
+
return cls
|
|
25
|
+
|
|
26
|
+
return decorator
|
netbox_dns/choices/zone.py
CHANGED
|
@@ -3,7 +3,10 @@ from django.utils.translation import gettext_lazy as _
|
|
|
3
3
|
from utilities.choices import ChoiceSet
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
__all__ = (
|
|
6
|
+
__all__ = (
|
|
7
|
+
"ZoneStatusChoices",
|
|
8
|
+
"ZoneEPPStatusChoices",
|
|
9
|
+
)
|
|
7
10
|
|
|
8
11
|
|
|
9
12
|
class ZoneStatusChoices(ChoiceSet):
|
|
@@ -22,3 +25,95 @@ class ZoneStatusChoices(ChoiceSet):
|
|
|
22
25
|
(STATUS_PARKED, _("Parked"), "gray"),
|
|
23
26
|
(STATUS_DYNAMIC, _("Dynamic"), "orange"),
|
|
24
27
|
]
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class ZoneEPPStatusChoices(ChoiceSet):
|
|
31
|
+
"""
|
|
32
|
+
Reflects the EPP status of a zone registered as a domain. See
|
|
33
|
+
https://www.icann.org/resources/pages/epp-status-codes-2014-06-16-en
|
|
34
|
+
for details.
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
key = "Zone.epp_status"
|
|
38
|
+
|
|
39
|
+
EPP_STATUS_ADD_PERIOD = "addPeriod"
|
|
40
|
+
EPP_STATUS_AUTO_RENEW_PERIOD = "autoRenewPeriod"
|
|
41
|
+
EPP_STATUS_INACTIVE = "inactive"
|
|
42
|
+
EPP_STATUS_OK = "ok"
|
|
43
|
+
EPP_STATUS_PENDING_CREATE = "pendingCreate"
|
|
44
|
+
EPP_STATUS_PENDING_DELETE = "pendingDelete"
|
|
45
|
+
EPP_STATUS_PENDING_RENEW = "pendingRenew"
|
|
46
|
+
EPP_STATUS_PENDING_RESTORE = "pendingRestore"
|
|
47
|
+
EPP_STATUS_PENDING_TRANSFER = "pendingTransfer"
|
|
48
|
+
EPP_STATUS_PENDING_UPDATE = "pendingUpdate"
|
|
49
|
+
EPP_STATUS_REDEMPTION_PERIOD = "redemptionPeriod"
|
|
50
|
+
EPP_STATUS_RENEW_PERIOD = "renewPeriod"
|
|
51
|
+
EPP_STATUS_SERVER_DELETE_PROHIBITED = "serverDeleteProhibited"
|
|
52
|
+
EPP_STATUS_SERVER_HOLD = "serverHold"
|
|
53
|
+
EPP_STATUS_SERVER_RENER_PROHIBITED = "serverRenewProhibited"
|
|
54
|
+
EPP_STATUS_SERVER_TRANSFER_PROHIBITED = "serverTransferProhibited"
|
|
55
|
+
EPP_STATUS_SERVER_UPDATE_PROHIBITED = "serverUpdateProhibited"
|
|
56
|
+
EPP_STATUS_TRANSFER_PERIOD = "transferPeriod"
|
|
57
|
+
EPP_STATUS_CLIENT_DELETE_PROHIBITED = "clientDeleteProhibited"
|
|
58
|
+
EPP_STATUS_CLIENT_HOLD = "clientHold"
|
|
59
|
+
EPP_STATUS_CLIENT_RENEW_PROHIBITED = "clientRenewProhibited"
|
|
60
|
+
EPP_STATUS_CLIENT_TRANSFER_PROHIBITED = "clientTransferProhibited"
|
|
61
|
+
EPP_STATUS_CLIENT_UPDATE_PROHIBITED = "clientUpdateProhibited"
|
|
62
|
+
|
|
63
|
+
CHOICES = [
|
|
64
|
+
(EPP_STATUS_ADD_PERIOD, EPP_STATUS_ADD_PERIOD, "blue"),
|
|
65
|
+
(EPP_STATUS_AUTO_RENEW_PERIOD, EPP_STATUS_AUTO_RENEW_PERIOD, "blue"),
|
|
66
|
+
(EPP_STATUS_INACTIVE, EPP_STATUS_INACTIVE, "blue"),
|
|
67
|
+
(EPP_STATUS_OK, EPP_STATUS_OK, "blue"),
|
|
68
|
+
(EPP_STATUS_PENDING_CREATE, EPP_STATUS_PENDING_CREATE, "blue"),
|
|
69
|
+
(EPP_STATUS_PENDING_DELETE, EPP_STATUS_PENDING_DELETE, "blue"),
|
|
70
|
+
(EPP_STATUS_PENDING_RENEW, EPP_STATUS_PENDING_RENEW, "blue"),
|
|
71
|
+
(EPP_STATUS_PENDING_RESTORE, EPP_STATUS_PENDING_RESTORE, "blue"),
|
|
72
|
+
(EPP_STATUS_PENDING_TRANSFER, EPP_STATUS_PENDING_TRANSFER, "blue"),
|
|
73
|
+
(EPP_STATUS_PENDING_UPDATE, EPP_STATUS_PENDING_UPDATE, "blue"),
|
|
74
|
+
(EPP_STATUS_REDEMPTION_PERIOD, EPP_STATUS_REDEMPTION_PERIOD, "blue"),
|
|
75
|
+
(EPP_STATUS_RENEW_PERIOD, EPP_STATUS_RENEW_PERIOD, "blue"),
|
|
76
|
+
(
|
|
77
|
+
EPP_STATUS_SERVER_DELETE_PROHIBITED,
|
|
78
|
+
EPP_STATUS_SERVER_DELETE_PROHIBITED,
|
|
79
|
+
"blue",
|
|
80
|
+
),
|
|
81
|
+
(EPP_STATUS_SERVER_HOLD, EPP_STATUS_SERVER_HOLD, "blue"),
|
|
82
|
+
(
|
|
83
|
+
EPP_STATUS_SERVER_RENER_PROHIBITED,
|
|
84
|
+
EPP_STATUS_SERVER_RENER_PROHIBITED,
|
|
85
|
+
"blue",
|
|
86
|
+
),
|
|
87
|
+
(
|
|
88
|
+
EPP_STATUS_SERVER_TRANSFER_PROHIBITED,
|
|
89
|
+
EPP_STATUS_SERVER_TRANSFER_PROHIBITED,
|
|
90
|
+
"blue",
|
|
91
|
+
),
|
|
92
|
+
(
|
|
93
|
+
EPP_STATUS_SERVER_UPDATE_PROHIBITED,
|
|
94
|
+
EPP_STATUS_SERVER_UPDATE_PROHIBITED,
|
|
95
|
+
"blue",
|
|
96
|
+
),
|
|
97
|
+
(EPP_STATUS_TRANSFER_PERIOD, EPP_STATUS_TRANSFER_PERIOD, "blue"),
|
|
98
|
+
(
|
|
99
|
+
EPP_STATUS_CLIENT_DELETE_PROHIBITED,
|
|
100
|
+
EPP_STATUS_CLIENT_DELETE_PROHIBITED,
|
|
101
|
+
"cyan",
|
|
102
|
+
),
|
|
103
|
+
(EPP_STATUS_CLIENT_HOLD, EPP_STATUS_CLIENT_HOLD, "cyan"),
|
|
104
|
+
(
|
|
105
|
+
EPP_STATUS_CLIENT_RENEW_PROHIBITED,
|
|
106
|
+
EPP_STATUS_CLIENT_RENEW_PROHIBITED,
|
|
107
|
+
"cyan",
|
|
108
|
+
),
|
|
109
|
+
(
|
|
110
|
+
EPP_STATUS_CLIENT_TRANSFER_PROHIBITED,
|
|
111
|
+
EPP_STATUS_CLIENT_TRANSFER_PROHIBITED,
|
|
112
|
+
"cyan",
|
|
113
|
+
),
|
|
114
|
+
(
|
|
115
|
+
EPP_STATUS_CLIENT_UPDATE_PROHIBITED,
|
|
116
|
+
EPP_STATUS_CLIENT_UPDATE_PROHIBITED,
|
|
117
|
+
"cyan",
|
|
118
|
+
),
|
|
119
|
+
]
|
netbox_dns/fields/__init__.py
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from django import forms
|
|
2
|
+
from django.contrib.postgres.fields import ArrayField
|
|
3
|
+
from django.db.models import Transform, IntegerField
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ArrayLength(Transform):
|
|
7
|
+
lookup_name = "length"
|
|
8
|
+
function = "cardinality"
|
|
9
|
+
|
|
10
|
+
@property
|
|
11
|
+
def output_field(self):
|
|
12
|
+
return IntegerField()
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class _TypedMultipleChoiceField(forms.TypedMultipleChoiceField):
|
|
16
|
+
def __init__(self, *args, **kwargs):
|
|
17
|
+
kwargs.pop("base_field", None)
|
|
18
|
+
kwargs.pop("max_length", None)
|
|
19
|
+
|
|
20
|
+
super().__init__(*args, **kwargs)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class ChoiceArrayField(ArrayField):
|
|
24
|
+
def formfield(self, **kwargs):
|
|
25
|
+
return super().formfield(
|
|
26
|
+
form_class=_TypedMultipleChoiceField,
|
|
27
|
+
choices=self.base_field.choices,
|
|
28
|
+
coerce=self.base_field.to_python,
|
|
29
|
+
**kwargs,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
ChoiceArrayField.register_lookup(ArrayLength)
|
netbox_dns/fields/timeperiod.py
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
|
-
from django.forms import Field
|
|
2
|
-
from django.utils.dateparse import parse_duration
|
|
1
|
+
from django.forms import Field, TextInput
|
|
3
2
|
from django.core.exceptions import ValidationError
|
|
4
3
|
|
|
4
|
+
from netbox_dns.utilities import iso8601_to_int
|
|
5
5
|
|
|
6
6
|
__all__ = ("TimePeriodField",)
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class TimePeriodField(Field):
|
|
10
|
+
def __init__(self, *args, **kwargs):
|
|
11
|
+
placeholder = kwargs.pop("placeholder", None)
|
|
12
|
+
|
|
13
|
+
if placeholder is not None:
|
|
14
|
+
self.widget = TextInput(attrs={"placeholder": placeholder})
|
|
15
|
+
|
|
16
|
+
return super().__init__(*args, **kwargs)
|
|
17
|
+
|
|
10
18
|
def to_python(self, value):
|
|
11
19
|
if not value:
|
|
12
20
|
return None
|
|
13
21
|
|
|
14
22
|
try:
|
|
15
|
-
return
|
|
16
|
-
except
|
|
17
|
-
|
|
18
|
-
duration
|
|
19
|
-
|
|
20
|
-
raise TypeError
|
|
21
|
-
return int(duration.total_seconds())
|
|
22
|
-
except TypeError:
|
|
23
|
-
raise ValidationError(
|
|
24
|
-
"Enter a valid integer or ISO 8601 duration (W, M and Y are not supported)"
|
|
25
|
-
)
|
|
23
|
+
return iso8601_to_int(value)
|
|
24
|
+
except TypeError:
|
|
25
|
+
raise ValidationError(
|
|
26
|
+
"Enter a valid integer or ISO 8601 duration (W, M and Y are not supported)"
|
|
27
|
+
)
|
|
26
28
|
|
|
27
29
|
def validate(self, value):
|
|
28
30
|
super().validate(value)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import django_filters
|
|
2
|
+
from django.db.models import Q
|
|
3
|
+
from django.utils.translation import gettext as _
|
|
4
|
+
|
|
5
|
+
from netbox.filtersets import NetBoxModelFilterSet
|
|
6
|
+
from tenancy.filtersets import TenancyFilterSet
|
|
7
|
+
|
|
8
|
+
from netbox_dns.models import DNSSECKeyTemplate, DNSSECPolicy
|
|
9
|
+
from netbox_dns.choices import (
|
|
10
|
+
DNSSECKeyTemplateTypeChoices,
|
|
11
|
+
DNSSECKeyTemplateAlgorithmChoices,
|
|
12
|
+
DNSSECKeyTemplateKeySizeChoices,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
__all__ = ("DNSSECKeyTemplateFilterSet",)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class DNSSECKeyTemplateFilterSet(TenancyFilterSet, NetBoxModelFilterSet):
|
|
20
|
+
type = django_filters.MultipleChoiceFilter(
|
|
21
|
+
choices=DNSSECKeyTemplateTypeChoices,
|
|
22
|
+
)
|
|
23
|
+
algorithm = django_filters.MultipleChoiceFilter(
|
|
24
|
+
choices=DNSSECKeyTemplateAlgorithmChoices,
|
|
25
|
+
)
|
|
26
|
+
key_size = django_filters.MultipleChoiceFilter(
|
|
27
|
+
choices=DNSSECKeyTemplateKeySizeChoices,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
policy_id = django_filters.ModelMultipleChoiceFilter(
|
|
31
|
+
field_name="policies",
|
|
32
|
+
queryset=DNSSECPolicy.objects.all(),
|
|
33
|
+
to_field_name="id",
|
|
34
|
+
label=_("DNSSEC Policy IDs"),
|
|
35
|
+
)
|
|
36
|
+
policy = django_filters.ModelMultipleChoiceFilter(
|
|
37
|
+
field_name="policies__name",
|
|
38
|
+
queryset=DNSSECPolicy.objects.all(),
|
|
39
|
+
to_field_name="name",
|
|
40
|
+
label=_("DNSSEC Policies"),
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
class Meta:
|
|
44
|
+
model = DNSSECKeyTemplate
|
|
45
|
+
fields = ("id", "name", "description", "lifetime")
|
|
46
|
+
|
|
47
|
+
def search(self, queryset, name, value):
|
|
48
|
+
if not value.strip():
|
|
49
|
+
return queryset
|
|
50
|
+
qs_filter = Q(name__icontains=value)
|
|
51
|
+
return queryset.filter(qs_filter)
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import django_filters
|
|
2
|
+
|
|
3
|
+
from django.db.models import Q
|
|
4
|
+
from django.utils.translation import gettext as _
|
|
5
|
+
|
|
6
|
+
from netbox.filtersets import NetBoxModelFilterSet
|
|
7
|
+
from tenancy.filtersets import TenancyFilterSet
|
|
8
|
+
from utilities.filters import MultiValueCharFilter
|
|
9
|
+
|
|
10
|
+
from netbox_dns.models import DNSSECPolicy, DNSSECKeyTemplate, Zone, ZoneTemplate
|
|
11
|
+
from netbox_dns.choices import DNSSECPolicyStatusChoices
|
|
12
|
+
|
|
13
|
+
__all__ = ("DNSSECPolicyFilterSet",)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class DNSSECPolicyFilterSet(TenancyFilterSet, NetBoxModelFilterSet):
|
|
17
|
+
class Meta:
|
|
18
|
+
model = DNSSECPolicy
|
|
19
|
+
fields = (
|
|
20
|
+
"id",
|
|
21
|
+
"name",
|
|
22
|
+
"description",
|
|
23
|
+
"status",
|
|
24
|
+
"dnskey_ttl",
|
|
25
|
+
"purge_keys",
|
|
26
|
+
"publish_safety",
|
|
27
|
+
"retire_safety",
|
|
28
|
+
"signatures_jitter",
|
|
29
|
+
"signatures_refresh",
|
|
30
|
+
"signatures_validity",
|
|
31
|
+
"signatures_validity_dnskey",
|
|
32
|
+
"max_zone_ttl",
|
|
33
|
+
"zone_propagation_delay",
|
|
34
|
+
"create_cdnskey",
|
|
35
|
+
"parent_ds_ttl",
|
|
36
|
+
"parent_propagation_delay",
|
|
37
|
+
"use_nsec3",
|
|
38
|
+
"nsec3_iterations",
|
|
39
|
+
"nsec3_opt_out",
|
|
40
|
+
"nsec3_salt_size",
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
status = django_filters.MultipleChoiceFilter(
|
|
44
|
+
choices=DNSSECPolicyStatusChoices,
|
|
45
|
+
)
|
|
46
|
+
cds_digest_types = MultiValueCharFilter(
|
|
47
|
+
method="filter_cds_digest_types",
|
|
48
|
+
label=_("CDS Digest Types"),
|
|
49
|
+
)
|
|
50
|
+
key_template = django_filters.ModelMultipleChoiceFilter(
|
|
51
|
+
field_name="key_templates__name",
|
|
52
|
+
queryset=DNSSECKeyTemplate.objects.all(),
|
|
53
|
+
to_field_name="name",
|
|
54
|
+
label=_("DNSSEC Key Templates"),
|
|
55
|
+
)
|
|
56
|
+
key_template_id = django_filters.ModelMultipleChoiceFilter(
|
|
57
|
+
field_name="key_templates",
|
|
58
|
+
queryset=DNSSECKeyTemplate.objects.all(),
|
|
59
|
+
to_field_name="id",
|
|
60
|
+
label=_("DNSSEC Key Template IDs"),
|
|
61
|
+
)
|
|
62
|
+
zone = django_filters.ModelMultipleChoiceFilter(
|
|
63
|
+
field_name="zones__name",
|
|
64
|
+
queryset=Zone.objects.all(),
|
|
65
|
+
to_field_name="name",
|
|
66
|
+
label=_("Zones"),
|
|
67
|
+
)
|
|
68
|
+
zone_id = django_filters.ModelMultipleChoiceFilter(
|
|
69
|
+
field_name="zones",
|
|
70
|
+
queryset=Zone.objects.all(),
|
|
71
|
+
to_field_name="id",
|
|
72
|
+
label=_("Zone IDs"),
|
|
73
|
+
)
|
|
74
|
+
zone_template = django_filters.ModelMultipleChoiceFilter(
|
|
75
|
+
field_name="zone_templates__name",
|
|
76
|
+
queryset=ZoneTemplate.objects.all(),
|
|
77
|
+
to_field_name="name",
|
|
78
|
+
label=_("Zone Templates"),
|
|
79
|
+
)
|
|
80
|
+
zone_template_id = django_filters.ModelMultipleChoiceFilter(
|
|
81
|
+
field_name="zone_templates",
|
|
82
|
+
queryset=ZoneTemplate.objects.all(),
|
|
83
|
+
to_field_name="id",
|
|
84
|
+
label=_("Zone Template IDs"),
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
def filter_cds_digest_types(self, queryset, name, value):
|
|
88
|
+
if not value:
|
|
89
|
+
return queryset
|
|
90
|
+
|
|
91
|
+
return queryset.filter(cds_digest_types__overlap=value)
|
|
92
|
+
|
|
93
|
+
def search(self, queryset, name, value):
|
|
94
|
+
if not value.strip():
|
|
95
|
+
return queryset
|
|
96
|
+
qs_filter = Q(name__icontains=value)
|
|
97
|
+
return queryset.filter(qs_filter)
|
netbox_dns/filtersets/zone.py
CHANGED
|
@@ -8,8 +8,15 @@ from netbox.filtersets import NetBoxModelFilterSet
|
|
|
8
8
|
from tenancy.filtersets import TenancyFilterSet
|
|
9
9
|
from utilities.filters import MultiValueCharFilter
|
|
10
10
|
|
|
11
|
-
from netbox_dns.models import
|
|
12
|
-
|
|
11
|
+
from netbox_dns.models import (
|
|
12
|
+
View,
|
|
13
|
+
Zone,
|
|
14
|
+
Registrar,
|
|
15
|
+
RegistrationContact,
|
|
16
|
+
NameServer,
|
|
17
|
+
DNSSECPolicy,
|
|
18
|
+
)
|
|
19
|
+
from netbox_dns.choices import ZoneStatusChoices, ZoneEPPStatusChoices
|
|
13
20
|
|
|
14
21
|
|
|
15
22
|
__all__ = ("ZoneFilterSet",)
|
|
@@ -51,9 +58,15 @@ class ZoneFilterSet(TenancyFilterSet, NetBoxModelFilterSet):
|
|
|
51
58
|
to_field_name="name",
|
|
52
59
|
label=_("SOA MName"),
|
|
53
60
|
)
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
label=_("
|
|
61
|
+
dnssec_policy_id = django_filters.ModelMultipleChoiceFilter(
|
|
62
|
+
queryset=DNSSECPolicy.objects.all(),
|
|
63
|
+
label=_("DNSSEC Policy ID"),
|
|
64
|
+
)
|
|
65
|
+
dnssec_policy = django_filters.ModelMultipleChoiceFilter(
|
|
66
|
+
queryset=DNSSECPolicy.objects.all(),
|
|
67
|
+
field_name="dnssec_policy__name",
|
|
68
|
+
to_field_name="name",
|
|
69
|
+
label=_("DNSSEC Policy"),
|
|
57
70
|
)
|
|
58
71
|
rfc2317_prefix = MultiValueCharFilter(
|
|
59
72
|
method="filter_rfc2317_prefix",
|
|
@@ -73,7 +86,7 @@ class ZoneFilterSet(TenancyFilterSet, NetBoxModelFilterSet):
|
|
|
73
86
|
)
|
|
74
87
|
registrar_id = django_filters.ModelMultipleChoiceFilter(
|
|
75
88
|
queryset=Registrar.objects.all(),
|
|
76
|
-
label="Registrar ID",
|
|
89
|
+
label=_("Registrar ID"),
|
|
77
90
|
)
|
|
78
91
|
registrar = django_filters.ModelMultipleChoiceFilter(
|
|
79
92
|
queryset=Registrar.objects.all(),
|
|
@@ -81,6 +94,10 @@ class ZoneFilterSet(TenancyFilterSet, NetBoxModelFilterSet):
|
|
|
81
94
|
to_field_name="name",
|
|
82
95
|
label=_("Registrar"),
|
|
83
96
|
)
|
|
97
|
+
expiration_date = django_filters.DateFromToRangeFilter()
|
|
98
|
+
domain_status = django_filters.MultipleChoiceFilter(
|
|
99
|
+
choices=ZoneEPPStatusChoices,
|
|
100
|
+
)
|
|
84
101
|
registrant_id = django_filters.ModelMultipleChoiceFilter(
|
|
85
102
|
queryset=RegistrationContact.objects.all(),
|
|
86
103
|
label=_("Registrant ID"),
|
|
@@ -121,6 +138,10 @@ class ZoneFilterSet(TenancyFilterSet, NetBoxModelFilterSet):
|
|
|
121
138
|
to_field_name="contact_id",
|
|
122
139
|
label=_("Billing Contact"),
|
|
123
140
|
)
|
|
141
|
+
arpa_network = MultiValueCharFilter(
|
|
142
|
+
method="filter_arpa_network",
|
|
143
|
+
label=_("ARPA Network"),
|
|
144
|
+
)
|
|
124
145
|
active = django_filters.BooleanFilter(
|
|
125
146
|
label=_("Zone is active"),
|
|
126
147
|
)
|
|
@@ -141,7 +162,9 @@ class ZoneFilterSet(TenancyFilterSet, NetBoxModelFilterSet):
|
|
|
141
162
|
"soa_minimum",
|
|
142
163
|
"soa_serial_auto",
|
|
143
164
|
"rfc2317_parent_managed",
|
|
165
|
+
"inline_signing",
|
|
144
166
|
"registry_domain_id",
|
|
167
|
+
"domain_status",
|
|
145
168
|
)
|
|
146
169
|
|
|
147
170
|
def filter_arpa_network(self, queryset, name, value):
|
|
@@ -179,6 +202,7 @@ class ZoneFilterSet(TenancyFilterSet, NetBoxModelFilterSet):
|
|
|
179
202
|
Q(name__icontains=value)
|
|
180
203
|
| Q(status__icontains=value)
|
|
181
204
|
| Q(view__name__icontains=value)
|
|
205
|
+
| Q(dnssec_policy__name__icontains=value)
|
|
182
206
|
| Q(registrar__name__icontains=value)
|
|
183
207
|
| Q(registry_domain_id__icontains=value)
|
|
184
208
|
| Q(registrant__name__icontains=value)
|
|
@@ -12,6 +12,7 @@ from netbox_dns.models import (
|
|
|
12
12
|
Registrar,
|
|
13
13
|
RegistrationContact,
|
|
14
14
|
NameServer,
|
|
15
|
+
DNSSECPolicy,
|
|
15
16
|
)
|
|
16
17
|
|
|
17
18
|
|
|
@@ -47,13 +48,23 @@ class ZoneTemplateFilterSet(TenancyFilterSet, NetBoxModelFilterSet):
|
|
|
47
48
|
queryset=NameServer.objects.all(),
|
|
48
49
|
field_name="soa_mname",
|
|
49
50
|
to_field_name="id",
|
|
50
|
-
label=_("SOA
|
|
51
|
+
label=_("SOA MName ID"),
|
|
51
52
|
)
|
|
52
53
|
soa_mname = django_filters.ModelMultipleChoiceFilter(
|
|
53
54
|
queryset=NameServer.objects.all(),
|
|
54
55
|
field_name="soa_mname__name",
|
|
55
56
|
to_field_name="name",
|
|
56
|
-
label=_("SOA
|
|
57
|
+
label=_("SOA MName"),
|
|
58
|
+
)
|
|
59
|
+
dnssec_policy_id = django_filters.ModelMultipleChoiceFilter(
|
|
60
|
+
queryset=DNSSECPolicy.objects.all(),
|
|
61
|
+
label=_("DNSSEC Policy ID"),
|
|
62
|
+
)
|
|
63
|
+
dnssec_policy = django_filters.ModelMultipleChoiceFilter(
|
|
64
|
+
queryset=DNSSECPolicy.objects.all(),
|
|
65
|
+
field_name="dnssec_policy__name",
|
|
66
|
+
to_field_name="name",
|
|
67
|
+
label=_("DNSSEC Policy"),
|
|
57
68
|
)
|
|
58
69
|
registrar_id = django_filters.ModelMultipleChoiceFilter(
|
|
59
70
|
queryset=Registrar.objects.all(),
|
netbox_dns/forms/__init__.py
CHANGED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
from django import forms
|
|
2
|
+
from django.contrib.postgres.forms import SimpleArrayField
|
|
3
|
+
from django.utils.translation import gettext_lazy as _
|
|
4
|
+
|
|
5
|
+
from netbox.forms import (
|
|
6
|
+
NetBoxModelBulkEditForm,
|
|
7
|
+
NetBoxModelFilterSetForm,
|
|
8
|
+
NetBoxModelImportForm,
|
|
9
|
+
NetBoxModelForm,
|
|
10
|
+
)
|
|
11
|
+
from utilities.forms.fields import (
|
|
12
|
+
TagFilterField,
|
|
13
|
+
CSVModelChoiceField,
|
|
14
|
+
DynamicModelChoiceField,
|
|
15
|
+
DynamicModelMultipleChoiceField,
|
|
16
|
+
)
|
|
17
|
+
from utilities.forms.rendering import FieldSet
|
|
18
|
+
from utilities.forms import add_blank_choice
|
|
19
|
+
from tenancy.models import Tenant, TenantGroup
|
|
20
|
+
from tenancy.forms import TenancyForm, TenancyFilterForm
|
|
21
|
+
|
|
22
|
+
from netbox_dns.models import DNSSECKeyTemplate, DNSSECPolicy
|
|
23
|
+
from netbox_dns.choices import (
|
|
24
|
+
DNSSECKeyTemplateTypeChoices,
|
|
25
|
+
DNSSECKeyTemplateAlgorithmChoices,
|
|
26
|
+
DNSSECKeyTemplateKeySizeChoices,
|
|
27
|
+
)
|
|
28
|
+
from netbox_dns.fields import TimePeriodField
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
__all__ = (
|
|
32
|
+
"DNSSECKeyTemplateForm",
|
|
33
|
+
"DNSSECKeyTemplateFilterForm",
|
|
34
|
+
"DNSSECKeyTemplateImportForm",
|
|
35
|
+
"DNSSECKeyTemplateBulkEditForm",
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class DNSSECKeyTemplateForm(TenancyForm, NetBoxModelForm):
|
|
40
|
+
lifetime = TimePeriodField(
|
|
41
|
+
required=False,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
fieldsets = (
|
|
45
|
+
FieldSet("name", "description", name=_("Attributes")),
|
|
46
|
+
FieldSet("type", "lifetime", "algorithm", "key_size", name=_("Key Properties")),
|
|
47
|
+
FieldSet("tenant_group", "tenant", name=_("Tenancy")),
|
|
48
|
+
FieldSet("tags", name=_("Tags")),
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
class Meta:
|
|
52
|
+
model = DNSSECKeyTemplate
|
|
53
|
+
fields = (
|
|
54
|
+
"name",
|
|
55
|
+
"description",
|
|
56
|
+
"type",
|
|
57
|
+
"lifetime",
|
|
58
|
+
"key_size",
|
|
59
|
+
"algorithm",
|
|
60
|
+
"tenant_group",
|
|
61
|
+
"tenant",
|
|
62
|
+
"tags",
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class DNSSECKeyTemplateFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
|
|
67
|
+
model = DNSSECKeyTemplate
|
|
68
|
+
fieldsets = (
|
|
69
|
+
FieldSet("q", "filter_id", "tag"),
|
|
70
|
+
FieldSet("name", "description", name=_("Attributes")),
|
|
71
|
+
FieldSet("policiy_id", name=_("Policies")),
|
|
72
|
+
FieldSet("type", "lifetime", "algorithm", "key_size", name=_("Key Properties")),
|
|
73
|
+
FieldSet("tenant_group_id", "tenant_id", name=_("Tenancy")),
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
name = forms.CharField(
|
|
77
|
+
required=False,
|
|
78
|
+
)
|
|
79
|
+
description = forms.CharField(
|
|
80
|
+
required=False,
|
|
81
|
+
)
|
|
82
|
+
policy_id = DynamicModelMultipleChoiceField(
|
|
83
|
+
queryset=DNSSECPolicy.objects.all(),
|
|
84
|
+
required=False,
|
|
85
|
+
null_option=_("None"),
|
|
86
|
+
label=_("Policies"),
|
|
87
|
+
)
|
|
88
|
+
type = forms.MultipleChoiceField(
|
|
89
|
+
choices=DNSSECKeyTemplateTypeChoices,
|
|
90
|
+
required=False,
|
|
91
|
+
)
|
|
92
|
+
lifetime = SimpleArrayField(
|
|
93
|
+
base_field=forms.IntegerField(),
|
|
94
|
+
required=False,
|
|
95
|
+
help_text=_("Enter a list of integer lifetime values, separated by comma (,)"),
|
|
96
|
+
)
|
|
97
|
+
algorithm = forms.MultipleChoiceField(
|
|
98
|
+
choices=DNSSECKeyTemplateAlgorithmChoices,
|
|
99
|
+
required=False,
|
|
100
|
+
)
|
|
101
|
+
key_size = SimpleArrayField(
|
|
102
|
+
base_field=forms.ChoiceField(
|
|
103
|
+
choices=DNSSECKeyTemplateKeySizeChoices,
|
|
104
|
+
),
|
|
105
|
+
required=False,
|
|
106
|
+
help_text=_("Enter a list of integer key sizes, separated by comma (,)"),
|
|
107
|
+
)
|
|
108
|
+
tag = TagFilterField(DNSSECKeyTemplate)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
class DNSSECKeyTemplateImportForm(NetBoxModelImportForm):
|
|
112
|
+
lifetime = TimePeriodField(
|
|
113
|
+
required=False,
|
|
114
|
+
label=_("Lifetime"),
|
|
115
|
+
)
|
|
116
|
+
tenant = CSVModelChoiceField(
|
|
117
|
+
queryset=Tenant.objects.all(),
|
|
118
|
+
to_field_name="name",
|
|
119
|
+
required=False,
|
|
120
|
+
label=_("Tenant"),
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
class Meta:
|
|
124
|
+
model = DNSSECKeyTemplate
|
|
125
|
+
fields = (
|
|
126
|
+
"name",
|
|
127
|
+
"description",
|
|
128
|
+
"type",
|
|
129
|
+
"lifetime",
|
|
130
|
+
"algorithm",
|
|
131
|
+
"key_size",
|
|
132
|
+
"tenant",
|
|
133
|
+
"tags",
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
class DNSSECKeyTemplateBulkEditForm(NetBoxModelBulkEditForm):
|
|
138
|
+
model = DNSSECKeyTemplate
|
|
139
|
+
|
|
140
|
+
type = forms.ChoiceField(
|
|
141
|
+
choices=add_blank_choice(DNSSECKeyTemplateTypeChoices),
|
|
142
|
+
required=False,
|
|
143
|
+
label=_("Key Type"),
|
|
144
|
+
)
|
|
145
|
+
lifetime = TimePeriodField(
|
|
146
|
+
required=False,
|
|
147
|
+
label=_("Lifetime"),
|
|
148
|
+
)
|
|
149
|
+
algorithm = forms.ChoiceField(
|
|
150
|
+
choices=add_blank_choice(DNSSECKeyTemplateAlgorithmChoices),
|
|
151
|
+
required=False,
|
|
152
|
+
label=_("Algorithm"),
|
|
153
|
+
)
|
|
154
|
+
key_size = forms.ChoiceField(
|
|
155
|
+
choices=add_blank_choice(DNSSECKeyTemplateKeySizeChoices),
|
|
156
|
+
required=False,
|
|
157
|
+
label=_("Key Size"),
|
|
158
|
+
)
|
|
159
|
+
description = forms.CharField(
|
|
160
|
+
max_length=200,
|
|
161
|
+
required=False,
|
|
162
|
+
label=_("Description"),
|
|
163
|
+
)
|
|
164
|
+
tenant_group = DynamicModelChoiceField(
|
|
165
|
+
queryset=TenantGroup.objects.all(),
|
|
166
|
+
required=False,
|
|
167
|
+
label=_("Tenant Group"),
|
|
168
|
+
)
|
|
169
|
+
tenant = DynamicModelChoiceField(
|
|
170
|
+
queryset=Tenant.objects.all(),
|
|
171
|
+
required=False,
|
|
172
|
+
label=_("Tenant"),
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
fieldsets = (
|
|
176
|
+
FieldSet(
|
|
177
|
+
"description",
|
|
178
|
+
name=_("Attributes"),
|
|
179
|
+
),
|
|
180
|
+
FieldSet("type", "lifetime", "algorithm", "key_size", name=_("Key Properties")),
|
|
181
|
+
FieldSet("tenant_group", "tenant", name=_("Tenancy")),
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
fields = (
|
|
185
|
+
"algorithm",
|
|
186
|
+
"key_size",
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
nullable_fields = ("description", "tenant", "lifetime", "key_size")
|