Skip to content

Commit 5b0b366

Browse files
committed
#9816: Promote IKE & IPSec proposals and policies to primary models
1 parent 3faf485 commit 5b0b366

File tree

13 files changed

+65
-52
lines changed

13 files changed

+65
-52
lines changed

docs/development/models.md

+4
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ These are considered the "core" application models which are used to model netwo
6262
* [tenancy.Tenant](../models/tenancy/tenant.md)
6363
* [virtualization.Cluster](../models/virtualization/cluster.md)
6464
* [virtualization.VirtualMachine](../models/virtualization/virtualmachine.md)
65+
* [vpn.IKEPolicy](../models/vpn/ikepolicy.md)
66+
* [vpn.IKEProposal](../models/vpn/ikeproposal.md)
67+
* [vpn.IPSecPolicy](../models/vpn/ipsecpolicy.md)
6568
* [vpn.IPSecProfile](../models/vpn/ipsecprofile.md)
69+
* [vpn.IPSecProposal](../models/vpn/ipsecproposal.md)
6670
* [vpn.L2VPN](../models/vpn/l2vpn.md)
6771
* [vpn.Tunnel](../models/vpn/tunnel.md)
6872
* [wireless.WirelessLAN](../models/wireless/wirelesslan.md)

netbox/templates/vpn/ikepolicy.html

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ <h5 class="card-header">{% trans "IKE Policy" %}</h5>
4848
</div>
4949
<div class="col col-md-6">
5050
{% include 'inc/panels/custom_fields.html' %}
51+
{% include 'inc/panels/comments.html' %}
5152
{% include 'inc/panels/tags.html' %}
5253
{% plugin_right_page object %}
5354
</div>

netbox/templates/vpn/ikeproposal.html

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ <h5 class="card-header">{% trans "IKE Proposal" %}</h5>
5151
</div>
5252
<div class="col col-md-6">
5353
{% include 'inc/panels/custom_fields.html' %}
54+
{% include 'inc/panels/comments.html' %}
5455
{% include 'inc/panels/tags.html' %}
5556
{% plugin_right_page object %}
5657
</div>

netbox/templates/vpn/ipsecpolicy.html

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ <h5 class="card-header">{% trans "IPSec Policy" %}</h5>
3535
</div>
3636
<div class="col col-md-6">
3737
{% include 'inc/panels/custom_fields.html' %}
38+
{% include 'inc/panels/comments.html' %}
3839
{% include 'inc/panels/tags.html' %}
3940
{% plugin_right_page object %}
4041
</div>

netbox/templates/vpn/ipsecproposal.html

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ <h5 class="card-header">{% trans "IPSec Proposal" %}</h5>
4747
</div>
4848
<div class="col col-md-6">
4949
{% include 'inc/panels/custom_fields.html' %}
50+
{% include 'inc/panels/comments.html' %}
5051
{% include 'inc/panels/tags.html' %}
5152
{% plugin_right_page object %}
5253
</div>

netbox/vpn/api/serializers.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ class Meta:
107107
model = IKEProposal
108108
fields = (
109109
'id', 'url', 'display', 'name', 'description', 'authentication_method', 'encryption_algorithm',
110-
'authentication_algorithm', 'group', 'sa_lifetime', 'tags', 'custom_fields', 'created', 'last_updated',
110+
'authentication_algorithm', 'group', 'sa_lifetime', 'comments', 'tags', 'custom_fields', 'created',
111+
'last_updated',
111112
)
112113

113114

@@ -131,8 +132,8 @@ class IKEPolicySerializer(NetBoxModelSerializer):
131132
class Meta:
132133
model = IKEPolicy
133134
fields = (
134-
'id', 'url', 'display', 'name', 'description', 'version', 'mode', 'proposals', 'preshared_key', 'tags',
135-
'custom_fields', 'created', 'last_updated',
135+
'id', 'url', 'display', 'name', 'description', 'version', 'mode', 'proposals', 'preshared_key', 'comments',
136+
'tags', 'custom_fields', 'created', 'last_updated',
136137
)
137138

138139

@@ -151,7 +152,7 @@ class Meta:
151152
model = IPSecProposal
152153
fields = (
153154
'id', 'url', 'display', 'name', 'description', 'encryption_algorithm', 'authentication_algorithm',
154-
'sa_lifetime_seconds', 'sa_lifetime_data', 'tags', 'custom_fields', 'created', 'last_updated',
155+
'sa_lifetime_seconds', 'sa_lifetime_data', 'comments', 'tags', 'custom_fields', 'created', 'last_updated',
155156
)
156157

157158

@@ -173,8 +174,8 @@ class IPSecPolicySerializer(NetBoxModelSerializer):
173174
class Meta:
174175
model = IPSecPolicy
175176
fields = (
176-
'id', 'url', 'display', 'name', 'description', 'proposals', 'pfs_group', 'tags', 'custom_fields', 'created',
177-
'last_updated',
177+
'id', 'url', 'display', 'name', 'description', 'proposals', 'pfs_group', 'comments', 'tags',
178+
'custom_fields', 'created', 'last_updated',
178179
)
179180

180181

netbox/vpn/filtersets.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ def search(self, queryset, name, value):
128128
return queryset
129129
return queryset.filter(
130130
Q(name__icontains=value) |
131-
Q(description__icontains=value)
131+
Q(description__icontains=value) |
132+
Q(comments__icontains=value)
132133
)
133134

134135

@@ -155,7 +156,8 @@ def search(self, queryset, name, value):
155156
return queryset
156157
return queryset.filter(
157158
Q(name__icontains=value) |
158-
Q(description__icontains=value)
159+
Q(description__icontains=value) |
160+
Q(comments__icontains=value)
159161
)
160162

161163

@@ -176,7 +178,8 @@ def search(self, queryset, name, value):
176178
return queryset
177179
return queryset.filter(
178180
Q(name__icontains=value) |
179-
Q(description__icontains=value)
181+
Q(description__icontains=value) |
182+
Q(comments__icontains=value)
180183
)
181184

182185

@@ -200,7 +203,8 @@ def search(self, queryset, name, value):
200203
return queryset
201204
return queryset.filter(
202205
Q(name__icontains=value) |
203-
Q(description__icontains=value)
206+
Q(description__icontains=value) |
207+
Q(comments__icontains=value)
204208
)
205209

206210

netbox/vpn/forms/bulk_import.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class Meta:
147147
model = IKEProposal
148148
fields = (
149149
'name', 'description', 'authentication_method', 'encryption_algorithm', 'authentication_algorithm',
150-
'group', 'sa_lifetime', 'tags',
150+
'group', 'sa_lifetime', 'comments', 'tags',
151151
)
152152

153153

@@ -169,7 +169,7 @@ class IKEPolicyImportForm(NetBoxModelImportForm):
169169
class Meta:
170170
model = IKEPolicy
171171
fields = (
172-
'name', 'description', 'version', 'mode', 'proposals', 'preshared_key', 'tags',
172+
'name', 'description', 'version', 'mode', 'proposals', 'preshared_key', 'comments', 'tags',
173173
)
174174

175175

@@ -187,7 +187,7 @@ class Meta:
187187
model = IPSecProposal
188188
fields = (
189189
'name', 'description', 'encryption_algorithm', 'authentication_algorithm', 'sa_lifetime_seconds',
190-
'sa_lifetime_data', 'tags',
190+
'sa_lifetime_data', 'comments', 'tags',
191191
)
192192

193193

@@ -205,7 +205,7 @@ class IPSecPolicyImportForm(NetBoxModelImportForm):
205205
class Meta:
206206
model = IPSecPolicy
207207
fields = (
208-
'name', 'description', 'proposals', 'pfs_group', 'tags',
208+
'name', 'description', 'proposals', 'pfs_group', 'comments', 'tags',
209209
)
210210

211211

netbox/vpn/forms/model_forms.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ class Meta:
280280
model = IKEProposal
281281
fields = [
282282
'name', 'description', 'authentication_method', 'encryption_algorithm', 'authentication_algorithm', 'group',
283-
'sa_lifetime', 'tags',
283+
'sa_lifetime', 'comments', 'tags',
284284
]
285285

286286

@@ -298,7 +298,7 @@ class IKEPolicyForm(NetBoxModelForm):
298298
class Meta:
299299
model = IKEPolicy
300300
fields = [
301-
'name', 'description', 'version', 'mode', 'proposals', 'preshared_key', 'tags',
301+
'name', 'description', 'version', 'mode', 'proposals', 'preshared_key', 'comments', 'tags',
302302
]
303303

304304

@@ -315,7 +315,7 @@ class Meta:
315315
model = IPSecProposal
316316
fields = [
317317
'name', 'description', 'encryption_algorithm', 'authentication_algorithm', 'sa_lifetime_seconds',
318-
'sa_lifetime_data', 'tags',
318+
'sa_lifetime_data', 'comments', 'tags',
319319
]
320320

321321

@@ -333,7 +333,7 @@ class IPSecPolicyForm(NetBoxModelForm):
333333
class Meta:
334334
model = IPSecPolicy
335335
fields = [
336-
'name', 'description', 'proposals', 'pfs_group', 'tags',
336+
'name', 'description', 'proposals', 'pfs_group', 'comments', 'tags',
337337
]
338338

339339

netbox/vpn/migrations/0001_initial.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ class Migration(migrations.Migration):
2323
('created', models.DateTimeField(auto_now_add=True, null=True)),
2424
('last_updated', models.DateTimeField(auto_now=True, null=True)),
2525
('custom_field_data', models.JSONField(blank=True, default=dict, encoder=utilities.json.CustomFieldJSONEncoder)),
26-
('name', models.CharField(max_length=100, unique=True)),
2726
('description', models.CharField(blank=True, max_length=200)),
27+
('comments', models.TextField(blank=True)),
28+
('name', models.CharField(max_length=100, unique=True)),
2829
('version', models.PositiveSmallIntegerField(default=2)),
2930
('mode', models.CharField()),
3031
('preshared_key', models.TextField(blank=True)),
@@ -42,8 +43,9 @@ class Migration(migrations.Migration):
4243
('created', models.DateTimeField(auto_now_add=True, null=True)),
4344
('last_updated', models.DateTimeField(auto_now=True, null=True)),
4445
('custom_field_data', models.JSONField(blank=True, default=dict, encoder=utilities.json.CustomFieldJSONEncoder)),
45-
('name', models.CharField(max_length=100, unique=True)),
4646
('description', models.CharField(blank=True, max_length=200)),
47+
('comments', models.TextField(blank=True)),
48+
('name', models.CharField(max_length=100, unique=True)),
4749
('pfs_group', models.PositiveSmallIntegerField(blank=True, null=True)),
4850
],
4951
options={
@@ -123,8 +125,9 @@ class Migration(migrations.Migration):
123125
('created', models.DateTimeField(auto_now_add=True, null=True)),
124126
('last_updated', models.DateTimeField(auto_now=True, null=True)),
125127
('custom_field_data', models.JSONField(blank=True, default=dict, encoder=utilities.json.CustomFieldJSONEncoder)),
126-
('name', models.CharField(max_length=100, unique=True)),
127128
('description', models.CharField(blank=True, max_length=200)),
129+
('comments', models.TextField(blank=True)),
130+
('name', models.CharField(max_length=100, unique=True)),
128131
('encryption_algorithm', models.CharField()),
129132
('authentication_algorithm', models.CharField()),
130133
('sa_lifetime_seconds', models.PositiveIntegerField(blank=True, null=True)),
@@ -154,8 +157,9 @@ class Migration(migrations.Migration):
154157
('created', models.DateTimeField(auto_now_add=True, null=True)),
155158
('last_updated', models.DateTimeField(auto_now=True, null=True)),
156159
('custom_field_data', models.JSONField(blank=True, default=dict, encoder=utilities.json.CustomFieldJSONEncoder)),
157-
('name', models.CharField(max_length=100, unique=True)),
158160
('description', models.CharField(blank=True, max_length=200)),
161+
('comments', models.TextField(blank=True)),
162+
('name', models.CharField(max_length=100, unique=True)),
159163
('authentication_method', models.CharField()),
160164
('encryption_algorithm', models.CharField()),
161165
('authentication_algorithm', models.CharField()),

netbox/vpn/models/crypto.py

+5-25
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from django.urls import reverse
33
from django.utils.translation import gettext_lazy as _
44

5-
from netbox.models import NetBoxModel, PrimaryModel
5+
from netbox.models import PrimaryModel
66
from vpn.choices import *
77

88
__all__ = (
@@ -18,17 +18,12 @@
1818
# IKE
1919
#
2020

21-
class IKEProposal(NetBoxModel):
21+
class IKEProposal(PrimaryModel):
2222
name = models.CharField(
2323
verbose_name=_('name'),
2424
max_length=100,
2525
unique=True
2626
)
27-
description = models.CharField(
28-
verbose_name=_('description'),
29-
max_length=200,
30-
blank=True
31-
)
3227
authentication_method = models.CharField(
3328
verbose_name=('authentication method'),
3429
choices=AuthenticationMethodChoices
@@ -69,17 +64,12 @@ def get_absolute_url(self):
6964
return reverse('vpn:ikeproposal', args=[self.pk])
7065

7166

72-
class IKEPolicy(NetBoxModel):
67+
class IKEPolicy(PrimaryModel):
7368
name = models.CharField(
7469
verbose_name=_('name'),
7570
max_length=100,
7671
unique=True
7772
)
78-
description = models.CharField(
79-
verbose_name=_('description'),
80-
max_length=200,
81-
blank=True
82-
)
8373
version = models.PositiveSmallIntegerField(
8474
verbose_name=_('version'),
8575
choices=IKEVersionChoices,
@@ -122,17 +112,12 @@ def get_absolute_url(self):
122112
# IPSec
123113
#
124114

125-
class IPSecProposal(NetBoxModel):
115+
class IPSecProposal(PrimaryModel):
126116
name = models.CharField(
127117
verbose_name=_('name'),
128118
max_length=100,
129119
unique=True
130120
)
131-
description = models.CharField(
132-
verbose_name=_('description'),
133-
max_length=200,
134-
blank=True
135-
)
136121
encryption_algorithm = models.CharField(
137122
verbose_name=_('encryption'),
138123
choices=EncryptionAlgorithmChoices
@@ -170,17 +155,12 @@ def get_absolute_url(self):
170155
return reverse('vpn:ipsecproposal', args=[self.pk])
171156

172157

173-
class IPSecPolicy(NetBoxModel):
158+
class IPSecPolicy(PrimaryModel):
174159
name = models.CharField(
175160
verbose_name=_('name'),
176161
max_length=100,
177162
unique=True
178163
)
179-
description = models.CharField(
180-
verbose_name=_('description'),
181-
max_length=200,
182-
blank=True
183-
)
184164
proposals = models.ManyToManyField(
185165
to='vpn.IPSecProposal',
186166
related_name='ipsec_policies',

netbox/vpn/search.py

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class IKEProposalIndex(SearchIndex):
2020
fields = (
2121
('name', 100),
2222
('description', 500),
23+
('comments', 5000),
2324
)
2425
display_attrs = ('description',)
2526

@@ -30,6 +31,7 @@ class IKEPolicyIndex(SearchIndex):
3031
fields = (
3132
('name', 100),
3233
('description', 500),
34+
('comments', 5000),
3335
)
3436
display_attrs = ('description',)
3537

@@ -40,6 +42,7 @@ class IPSecProposalIndex(SearchIndex):
4042
fields = (
4143
('name', 100),
4244
('description', 500),
45+
('comments', 5000),
4346
)
4447
display_attrs = ('description',)
4548

@@ -50,6 +53,7 @@ class IPSecPolicyIndex(SearchIndex):
5053
fields = (
5154
('name', 100),
5255
('description', 500),
56+
('comments', 5000),
5357
)
5458
display_attrs = ('description',)
5559

0 commit comments

Comments
 (0)