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

122 lines
3.4 KiB
Python
Raw Normal View History

from django.utils.translation import gettext_lazy as _
2021-10-13 14:31:30 -04:00
from dcim.choices import LinkStatusChoices
2021-10-13 09:46:17 -04:00
from dcim.models import Interface
from ipam.models import VLAN
from netbox.forms import NetBoxModelImportForm
from tenancy.models import Tenant
from utilities.forms.fields import CSVChoiceField, CSVModelChoiceField, SlugField
2021-10-20 10:58:15 -04:00
from wireless.choices import *
2021-10-13 09:46:17 -04:00
from wireless.models import *
__all__ = (
'WirelessLANImportForm',
'WirelessLANGroupImportForm',
'WirelessLinkImportForm',
)
class WirelessLANGroupImportForm(NetBoxModelImportForm):
2021-10-13 16:40:12 -04:00
parent = CSVModelChoiceField(
label=_('Parent'),
2021-10-13 16:40:12 -04:00
queryset=WirelessLANGroup.objects.all(),
required=False,
to_field_name='name',
help_text=_('Parent group')
2021-10-13 16:40:12 -04:00
)
slug = SlugField()
class Meta:
model = WirelessLANGroup
fields = ('name', 'slug', 'parent', 'description', 'tags')
2021-10-13 16:40:12 -04:00
class WirelessLANImportForm(NetBoxModelImportForm):
2021-10-13 16:40:12 -04:00
group = CSVModelChoiceField(
label=_('Group'),
2021-10-13 16:40:12 -04:00
queryset=WirelessLANGroup.objects.all(),
required=False,
to_field_name='name',
help_text=_('Assigned group')
2021-10-13 16:40:12 -04:00
)
status = CSVChoiceField(
label=_('Status'),
choices=WirelessLANStatusChoices,
2024-04-22 08:42:20 -07:00
help_text=_('Operational status')
)
vlan = CSVModelChoiceField(
label=_('VLAN'),
queryset=VLAN.objects.all(),
2021-10-20 13:34:39 -04:00
required=False,
to_field_name='name',
help_text=_('Bridged VLAN')
)
tenant = CSVModelChoiceField(
label=_('Tenant'),
queryset=Tenant.objects.all(),
required=False,
to_field_name='name',
help_text=_('Assigned tenant')
)
2021-10-20 10:58:15 -04:00
auth_type = CSVChoiceField(
label=_('Authentication type'),
2021-10-20 10:58:15 -04:00
choices=WirelessAuthTypeChoices,
required=False,
help_text=_('Authentication type')
2021-10-20 10:58:15 -04:00
)
auth_cipher = CSVChoiceField(
label=_('Authentication cipher'),
2021-10-20 10:58:15 -04:00
choices=WirelessAuthCipherChoices,
required=False,
help_text=_('Authentication cipher')
2021-10-20 10:58:15 -04:00
)
class Meta:
2021-10-12 17:02:53 -04:00
model = WirelessLAN
fields = (
'ssid', 'group', 'status', 'vlan', 'tenant', 'auth_type', 'auth_cipher', 'auth_psk', 'description',
'comments', 'tags',
)
2021-10-13 09:46:17 -04:00
class WirelessLinkImportForm(NetBoxModelImportForm):
2021-10-13 14:31:30 -04:00
status = CSVChoiceField(
label=_('Status'),
2021-10-13 14:31:30 -04:00
choices=LinkStatusChoices,
help_text=_('Connection status')
2021-10-13 14:31:30 -04:00
)
2021-10-13 09:46:17 -04:00
interface_a = CSVModelChoiceField(
label=_('Interface A'),
2021-10-13 09:46:17 -04:00
queryset=Interface.objects.all()
)
interface_b = CSVModelChoiceField(
label=_('Interface B'),
2021-10-13 09:46:17 -04:00
queryset=Interface.objects.all()
)
tenant = CSVModelChoiceField(
label=_('Tenant'),
queryset=Tenant.objects.all(),
required=False,
to_field_name='name',
help_text=_('Assigned tenant')
)
2021-10-20 10:58:15 -04:00
auth_type = CSVChoiceField(
label=_('Authentication type'),
2021-10-20 10:58:15 -04:00
choices=WirelessAuthTypeChoices,
required=False,
help_text=_('Authentication type')
2021-10-20 10:58:15 -04:00
)
auth_cipher = CSVChoiceField(
label=_('Authentication cipher'),
2021-10-20 10:58:15 -04:00
choices=WirelessAuthCipherChoices,
required=False,
help_text=_('Authentication cipher')
2021-10-20 10:58:15 -04:00
)
2021-10-13 09:46:17 -04:00
class Meta:
model = WirelessLink
fields = (
'interface_a', 'interface_b', 'ssid', 'tenant', 'auth_type', 'auth_cipher', 'auth_psk', 'description',
'comments', 'tags',
)