1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Add wireless authentication attributes

This commit is contained in:
jeremystretch
2021-10-20 10:58:15 -04:00
parent 0c72c20d2a
commit a66501250e
14 changed files with 252 additions and 21 deletions

View File

@@ -4,6 +4,7 @@ from dcim.choices import LinkStatusChoices
from extras.forms import AddRemoveTagsForm, CustomFieldModelBulkEditForm
from ipam.models import VLAN
from utilities.forms import BootstrapMixin, DynamicModelChoiceField
from wireless.choices import *
from wireless.constants import SSID_MAX_LENGTH
from wireless.models import *
@@ -52,9 +53,20 @@ class WirelessLANBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldMode
description = forms.CharField(
required=False
)
auth_type = forms.ChoiceField(
choices=WirelessAuthTypeChoices,
required=False
)
auth_cipher = forms.ChoiceField(
choices=WirelessAuthCipherChoices,
required=False
)
auth_psk = forms.CharField(
required=False
)
class Meta:
nullable_fields = ['ssid', 'group', 'vlan', 'description']
nullable_fields = ['ssid', 'group', 'vlan', 'description', 'auth_type', 'auth_cipher', 'auth_psk']
class WirelessLinkBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldModelBulkEditForm):
@@ -73,6 +85,17 @@ class WirelessLinkBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldMod
description = forms.CharField(
required=False
)
auth_type = forms.ChoiceField(
choices=WirelessAuthTypeChoices,
required=False
)
auth_cipher = forms.ChoiceField(
choices=WirelessAuthCipherChoices,
required=False
)
auth_psk = forms.CharField(
required=False
)
class Meta:
nullable_fields = ['ssid', 'description']
nullable_fields = ['ssid', 'description', 'auth_type', 'auth_cipher', 'auth_psk']

View File

@@ -3,6 +3,7 @@ from dcim.models import Interface
from extras.forms import CustomFieldModelCSVForm
from ipam.models import VLAN
from utilities.forms import CSVChoiceField, CSVModelChoiceField, SlugField
from wireless.choices import *
from wireless.models import *
__all__ = (
@@ -38,10 +39,20 @@ class WirelessLANCSVForm(CustomFieldModelCSVForm):
to_field_name='name',
help_text='Bridged VLAN'
)
auth_type = CSVChoiceField(
choices=WirelessAuthTypeChoices,
required=False,
help_text='Authentication type'
)
auth_cipher = CSVChoiceField(
choices=WirelessAuthCipherChoices,
required=False,
help_text='Authentication cipher'
)
class Meta:
model = WirelessLAN
fields = ('ssid', 'group', 'description', 'vlan')
fields = ('ssid', 'group', 'description', 'vlan', 'auth_type', 'auth_cipher', 'auth_psk')
class WirelessLinkCSVForm(CustomFieldModelCSVForm):
@@ -55,7 +66,17 @@ class WirelessLinkCSVForm(CustomFieldModelCSVForm):
interface_b = CSVModelChoiceField(
queryset=Interface.objects.all()
)
auth_type = CSVChoiceField(
choices=WirelessAuthTypeChoices,
required=False,
help_text='Authentication type'
)
auth_cipher = CSVChoiceField(
choices=WirelessAuthCipherChoices,
required=False,
help_text='Authentication cipher'
)
class Meta:
model = WirelessLink
fields = ('interface_a', 'interface_b', 'ssid', 'description')
fields = ('interface_a', 'interface_b', 'ssid', 'description', 'auth_type', 'auth_cipher', 'auth_psk')

View File

@@ -6,6 +6,7 @@ from extras.forms import CustomFieldModelFilterForm
from utilities.forms import (
add_blank_choice, BootstrapMixin, DynamicModelMultipleChoiceField, StaticSelect, TagFilterField,
)
from wireless.choices import *
from wireless.models import *
__all__ = (
@@ -52,6 +53,19 @@ class WirelessLANFilterForm(BootstrapMixin, CustomFieldModelFilterForm):
label=_('Group'),
fetch_trigger='open'
)
auth_type = forms.ChoiceField(
required=False,
choices=add_blank_choice(WirelessAuthTypeChoices),
widget=StaticSelect()
)
auth_cipher = forms.ChoiceField(
required=False,
choices=add_blank_choice(WirelessAuthCipherChoices),
widget=StaticSelect()
)
auth_psk = forms.CharField(
required=False
)
tag = TagFilterField(model)
@@ -74,4 +88,17 @@ class WirelessLinkFilterForm(BootstrapMixin, CustomFieldModelFilterForm):
choices=add_blank_choice(LinkStatusChoices),
widget=StaticSelect()
)
auth_type = forms.ChoiceField(
required=False,
choices=add_blank_choice(WirelessAuthTypeChoices),
widget=StaticSelect()
)
auth_cipher = forms.ChoiceField(
required=False,
choices=add_blank_choice(WirelessAuthCipherChoices),
widget=StaticSelect()
)
auth_psk = forms.CharField(
required=False
)
tag = TagFilterField(model)

View File

@@ -35,7 +35,8 @@ class WirelessLANForm(BootstrapMixin, CustomFieldModelForm):
)
vlan = DynamicModelChoiceField(
queryset=VLAN.objects.all(),
required=False
required=False,
label='VLAN'
)
tags = DynamicModelMultipleChoiceField(
queryset=Tag.objects.all(),
@@ -45,12 +46,17 @@ class WirelessLANForm(BootstrapMixin, CustomFieldModelForm):
class Meta:
model = WirelessLAN
fields = [
'ssid', 'group', 'description', 'vlan', 'tags',
'ssid', 'group', 'description', 'vlan', 'auth_type', 'auth_cipher', 'auth_psk', 'tags',
]
fieldsets = (
('Wireless LAN', ('ssid', 'group', 'description', 'tags')),
('VLAN', ('vlan',)),
('Authentication', ('auth_type', 'auth_cipher', 'auth_psk')),
)
widgets = {
'auth_type': StaticSelect,
'auth_cipher': StaticSelect,
}
class WirelessLinkForm(BootstrapMixin, CustomFieldModelForm):
@@ -94,8 +100,15 @@ class WirelessLinkForm(BootstrapMixin, CustomFieldModelForm):
class Meta:
model = WirelessLink
fields = [
'device_a', 'interface_a', 'device_b', 'interface_b', 'status', 'ssid', 'description', 'tags',
'device_a', 'interface_a', 'device_b', 'interface_b', 'status', 'ssid', 'description', 'auth_type',
'auth_cipher', 'auth_psk', 'tags',
]
fieldsets = (
('Link', ('device_a', 'interface_a', 'device_b', 'interface_b', 'status', 'ssid', 'description', 'tags')),
('Authentication', ('auth_type', 'auth_cipher', 'auth_psk')),
)
widgets = {
'status': StaticSelect,
'auth_type': StaticSelect,
'auth_cipher': StaticSelect,
}