Add phase2_sa_lifetime_data field on IPSecProfile

This commit is contained in:
Jeremy Stretch 2023-11-14 16:47:12 -05:00
parent 4880111622
commit 130288d08a
12 changed files with 62 additions and 65 deletions

View File

@ -75,9 +75,13 @@
<td>{{ object.get_phase2_group_display }}</td> <td>{{ object.get_phase2_group_display }}</td>
</tr> </tr>
<tr> <tr>
<th scope="row">{% trans "SA Lifetime" %}</th> <th scope="row">{% trans "SA Lifetime (Seconds)" %}</th>
<td>{{ object.phase2_sa_lifetime|placeholder }}</td> <td>{{ object.phase2_sa_lifetime|placeholder }}</td>
</tr> </tr>
<tr>
<th scope="row">{% trans "SA Lifetime (KB)" %}</th>
<td>{{ object.phase2_sa_lifetime_data|placeholder }}</td>
</tr>
</table> </table>
</div> </div>
</div> </div>

View File

@ -113,5 +113,6 @@ class IPSecProfileSerializer(NetBoxModelSerializer):
fields = ( fields = (
'id', 'url', 'display', 'name', 'protocol', 'ike_version', 'phase1_encryption', 'phase1_authentication', 'id', 'url', 'display', 'name', 'protocol', 'ike_version', 'phase1_encryption', 'phase1_authentication',
'phase1_group', 'phase1_sa_lifetime', 'phase2_encryption', 'phase2_authentication', 'phase2_group', 'phase1_group', 'phase1_sa_lifetime', 'phase2_encryption', 'phase2_authentication', 'phase2_group',
'phase2_sa_lifetime', 'comments', 'tags', 'custom_fields', 'created', 'last_updated', 'phase2_sa_lifetime', 'phase2_sa_lifetime_data', 'comments', 'tags', 'custom_fields', 'created',
'last_updated',
) )

View File

@ -125,7 +125,7 @@ class IPSecProfileFilterSet(NetBoxModelFilterSet):
class Meta: class Meta:
model = IPSecProfile model = IPSecProfile
fields = ['id', 'name', 'phase1_sa_lifetime', 'phase2_sa_lifetime'] fields = ['id', 'name', 'phase1_sa_lifetime', 'phase2_sa_lifetime', 'phase2_sa_lifetime_data']
def search(self, queryset, name, value): def search(self, queryset, name, value):
if not value.strip(): if not value.strip():

View File

@ -127,14 +127,24 @@ class IPSecProfileBulkEditForm(NetBoxModelBulkEditForm):
phase2_sa_lifetime = forms.IntegerField( phase2_sa_lifetime = forms.IntegerField(
required=False required=False
) )
phase2_sa_lifetime_data = forms.IntegerField(
required=False
)
comments = CommentField() comments = CommentField()
model = IPSecProfile model = IPSecProfile
fieldsets = ( fieldsets = (
(_('Profile'), ('protocol', 'ike_version', 'description')), (_('Profile'), (
(_('Phase 1 Parameters'), ('phase1_encryption', 'phase1_authentication', 'phase1_group', 'phase1_sa_lifetime')), 'protocol', 'ike_version', 'description',
(_('Phase 2 Parameters'), ('phase2_encryption', 'phase2_authentication', 'phase2_group', 'phase2_sa_lifetime')), )),
(_('Phase 1 Parameters'), (
'phase1_encryption', 'phase1_authentication', 'phase1_group', 'phase1_sa_lifetime',
)),
(_('Phase 2 Parameters'), (
'phase2_encryption', 'phase2_authentication', 'phase2_group', 'phase2_sa_lifetime',
'phase2_sa_lifetime_data',
)),
) )
nullable_fields = ( nullable_fields = (
'description', 'phase1_sa_lifetime', 'phase2_sa_lifetime', 'comments', 'description', 'phase1_sa_lifetime', 'phase2_sa_lifetime', 'phase2_sa_lifetime_data', 'comments',
) )

View File

@ -148,6 +148,6 @@ class IPSecProfileImportForm(NetBoxModelImportForm):
model = IPSecProfile model = IPSecProfile
fields = ( fields = (
'name', 'protocol', 'ike_version', 'phase1_encryption', 'phase1_authentication', 'phase1_group', 'name', 'protocol', 'ike_version', 'phase1_encryption', 'phase1_authentication', 'phase1_group',
'phase1_sa_lifetime', 'phase1_encryption', 'phase1_authentication', 'phase1_group', 'phase1_sa_lifetime', 'phase1_sa_lifetime', 'phase2_encryption', 'phase2_authentication', 'phase2_group', 'phase2_sa_lifetime',
'description', 'comments', 'tags', 'phase2_sa_lifetime_data', 'description', 'comments', 'tags',
) )

View File

@ -72,8 +72,13 @@ class IPSecProfileFilterForm(NetBoxModelFilterSetForm):
fieldsets = ( fieldsets = (
(None, ('q', 'filter_id', 'tag')), (None, ('q', 'filter_id', 'tag')),
(_('Profile'), ('protocol', 'ike_version')), (_('Profile'), ('protocol', 'ike_version')),
(_('Phase 1 Parameters'), ('phase1_encryption', 'phase1_authentication', 'phase1_group', 'phase1_sa_lifetime')), (_('Phase 1 Parameters'), (
(_('Phase 2 Parameters'), ('phase2_encryption', 'phase2_authentication', 'phase2_group', 'phase2_sa_lifetime')), 'phase1_encryption', 'phase1_authentication', 'phase1_group', 'phase1_sa_lifetime',
)),
(_('Phase 2 Parameters'), (
'phase2_encryption', 'phase2_authentication', 'phase2_group', 'phase2_sa_lifetime',
'phase2_sa_lifetime_data',
)),
) )
protocol = forms.MultipleChoiceField( protocol = forms.MultipleChoiceField(
label=_('Protocol'), label=_('Protocol'),
@ -130,4 +135,9 @@ class IPSecProfileFilterForm(NetBoxModelFilterSetForm):
min_value=0, min_value=0,
label=_('SA lifetime') label=_('SA lifetime')
) )
phase2_sa_lifetime_data = forms.IntegerField(
required=False,
min_value=0,
label=_('SA lifetime (data)')
)
tag = TagFilterField(model) tag = TagFilterField(model)

View File

@ -1,4 +1,3 @@
from django import forms
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from dcim.models import Interface from dcim.models import Interface
@ -89,9 +88,16 @@ class IPSecProfileForm(NetBoxModelForm):
comments = CommentField() comments = CommentField()
fieldsets = ( fieldsets = (
(_('Profile'), ('name', 'protocol', 'ike_version', 'description', 'tags')), (_('Profile'), (
(_('Phase 1 Parameters'), ('phase1_encryption', 'phase1_authentication', 'phase1_group', 'phase1_sa_lifetime')), 'name', 'protocol', 'ike_version', 'description', 'tags',
(_('Phase 2 Parameters'), ('phase2_encryption', 'phase2_authentication', 'phase2_group', 'phase2_sa_lifetime')), )),
(_('Phase 1 Parameters'), (
'phase1_encryption', 'phase1_authentication', 'phase1_group', 'phase1_sa_lifetime',
)),
(_('Phase 2 Parameters'), (
'phase2_encryption', 'phase2_authentication', 'phase2_group', 'phase2_sa_lifetime',
'phase2_sa_lifetime_data',
)),
) )
class Meta: class Meta:
@ -99,5 +105,5 @@ class IPSecProfileForm(NetBoxModelForm):
fields = [ fields = [
'name', 'protocol', 'ike_version', 'phase1_encryption', 'phase1_authentication', 'phase1_group', 'name', 'protocol', 'ike_version', 'phase1_encryption', 'phase1_authentication', 'phase1_group',
'phase1_sa_lifetime', 'phase2_encryption', 'phase2_authentication', 'phase2_group', 'phase2_sa_lifetime', 'phase1_sa_lifetime', 'phase2_encryption', 'phase2_authentication', 'phase2_group', 'phase2_sa_lifetime',
'description', 'comments', 'tags', 'phase2_sa_lifetime_data', 'description', 'comments', 'tags',
] ]

View File

@ -33,11 +33,12 @@ class Migration(migrations.Migration):
('phase1_encryption', models.CharField()), ('phase1_encryption', models.CharField()),
('phase1_authentication', models.CharField()), ('phase1_authentication', models.CharField()),
('phase1_group', models.PositiveSmallIntegerField()), ('phase1_group', models.PositiveSmallIntegerField()),
('phase1_sa_lifetime', models.PositiveSmallIntegerField(blank=True, null=True)), ('phase1_sa_lifetime', models.PositiveIntegerField(blank=True, null=True)),
('phase2_encryption', models.CharField()), ('phase2_encryption', models.CharField()),
('phase2_authentication', models.CharField()), ('phase2_authentication', models.CharField()),
('phase2_group', models.PositiveSmallIntegerField()), ('phase2_group', models.PositiveSmallIntegerField()),
('phase2_sa_lifetime', models.PositiveSmallIntegerField(blank=True, null=True)), ('phase2_sa_lifetime', models.PositiveIntegerField(blank=True, null=True)),
('phase2_sa_lifetime_data', models.PositiveIntegerField(blank=True, null=True)),
('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')), ('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
], ],
options={ options={
@ -59,7 +60,7 @@ class Migration(migrations.Migration):
('status', models.CharField(default='active', max_length=50)), ('status', models.CharField(default='active', max_length=50)),
('encapsulation', models.CharField(max_length=50)), ('encapsulation', models.CharField(max_length=50)),
('preshared_key', models.TextField(blank=True)), ('preshared_key', models.TextField(blank=True)),
('tunnel_id', models.PositiveBigIntegerField(blank=True)), ('tunnel_id', models.PositiveBigIntegerField(blank=True, null=True)),
('ipsec_profile', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='tunnels', to='vpn.ipsecprofile')), ('ipsec_profile', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='tunnels', to='vpn.ipsecprofile')),
('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')), ('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
('tenant', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='tunnels', to='tenancy.tenant')), ('tenant', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='tunnels', to='tenancy.tenant')),

View File

@ -1,23 +0,0 @@
# Generated by Django 4.2.6 on 2023-11-08 16:04
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('vpn', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='ipsecprofile',
name='phase1_sa_lifetime',
field=models.PositiveIntegerField(blank=True, null=True),
),
migrations.AlterField(
model_name='ipsecprofile',
name='phase2_sa_lifetime',
field=models.PositiveIntegerField(blank=True, null=True),
),
]

View File

@ -1,18 +0,0 @@
# Generated by Django 4.2.6 on 2023-11-08 16:06
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('vpn', '0002_alter_ipsecprofile_phase1_sa_lifetime_and_more'),
]
operations = [
migrations.AlterField(
model_name='tunnel',
name='tunnel_id',
field=models.PositiveBigIntegerField(blank=True, null=True),
),
]

View File

@ -62,16 +62,22 @@ class IPSecProfile(PrimaryModel):
help_text=_('Diffie-Hellman group') help_text=_('Diffie-Hellman group')
) )
phase2_sa_lifetime = models.PositiveIntegerField( phase2_sa_lifetime = models.PositiveIntegerField(
verbose_name=_('phase 2 SA lifetime'), verbose_name=_('phase 2 SA lifetime (seconds)'),
blank=True, blank=True,
null=True, null=True,
help_text=_('Security association lifetime (in seconds)') help_text=_('Security association lifetime (seconds)')
)
phase2_sa_lifetime_data = models.PositiveIntegerField(
verbose_name=_('phase 2 SA lifetime (KB)'),
blank=True,
null=True,
help_text=_('Security association lifetime (in kilobytes)')
) )
# TODO: Add PFS group? # TODO: Add PFS group?
clone_fields = ( clone_fields = (
'protocol', 'ike_version', 'phase1_encryption', 'phase1_authentication', 'phase1_group', 'phase1_sa_lifetime', 'protocol', 'ike_version', 'phase1_encryption', 'phase1_authentication', 'phase1_group', 'phase1_sa_lifetime',
'phase2_encryption', 'phase2_authentication', 'phase2_group', 'phase2_sa_lifetime', 'phase2_encryption', 'phase2_authentication', 'phase2_group', 'phase2_sa_lifetime', 'phase2_sa_lifetime_data',
) )
class Meta: class Meta:

View File

@ -115,7 +115,7 @@ class IPSecProfileTable(TenancyColumnsMixin, NetBoxTable):
model = IPSecProfile model = IPSecProfile
fields = ( fields = (
'pk', 'id', 'name', 'protocol', 'ike_version', 'phase1_encryption', 'phase1_authentication', 'phase1_group', 'pk', 'id', 'name', 'protocol', 'ike_version', 'phase1_encryption', 'phase1_authentication', 'phase1_group',
'phase1_sa_lifetime', 'phase2_encryption', 'phase2_authentication', 'phase2_group', 'phase1_sa_lifetime', 'phase1_sa_lifetime', 'phase2_encryption', 'phase2_authentication', 'phase2_group', 'phase2_sa_lifetime',
'description', 'comments', 'tags', 'created', 'last_updated', 'phase2_sa_lifetime_data', 'description', 'comments', 'tags', 'created', 'last_updated',
) )
default_columns = ('pk', 'name', 'protocol', 'ike_version', 'description') default_columns = ('pk', 'name', 'protocol', 'ike_version', 'description')