Example #1
0
File: forms.py Project: wuwx/netbox
class IPAddressBulkEditForm(BootstrapMixin, AddRemoveTagsForm,
                            CustomFieldBulkEditForm):
    pk = forms.ModelMultipleChoiceField(queryset=IPAddress.objects.all(),
                                        widget=forms.MultipleHiddenInput())
    vrf = forms.ModelChoiceField(queryset=VRF.objects.all(),
                                 required=False,
                                 label='VRF',
                                 widget=APISelect(api_url="/api/ipam/vrfs/"))
    mask_length = forms.IntegerField(min_value=1,
                                     max_value=128,
                                     required=False)
    tenant = forms.ModelChoiceField(
        queryset=Tenant.objects.all(),
        required=False,
        widget=APISelect(api_url="/api/tenancy/tenants/"))
    status = forms.ChoiceField(
        choices=add_blank_choice(IPADDRESS_STATUS_CHOICES),
        required=False,
        widget=StaticSelect2())
    role = forms.ChoiceField(choices=add_blank_choice(IPADDRESS_ROLE_CHOICES),
                             required=False,
                             widget=StaticSelect2())
    description = forms.CharField(max_length=100, required=False)

    class Meta:
        nullable_fields = [
            'vrf',
            'role',
            'tenant',
            'description',
        ]
Example #2
0
 class Meta:
     model = VirtualMachine
     fields = [
         'name',
         'status',
         'cluster_group',
         'cluster',
         'role',
         'tenant_group',
         'tenant',
         'platform',
         'primary_ip4',
         'primary_ip6',
         'vcpus',
         'memory',
         'disk',
         'comments',
         'tags',
         'local_context_data',
     ]
     help_texts = {
         'local_context_data':
         "Local config context data overwrites all sources contexts in the final rendered "
         "config context",
     }
     widgets = {
         "status": StaticSelect2(),
         'primary_ip4': StaticSelect2(),
         'primary_ip6': StaticSelect2(),
     }
Example #3
0
class IPAddressBulkEditForm(BootstrapMixin, AddRemoveTagsForm,
                            CustomFieldBulkEditForm):
    pk = forms.ModelMultipleChoiceField(queryset=IPAddress.objects.all(),
                                        widget=forms.MultipleHiddenInput())
    vrf = DynamicModelChoiceField(queryset=VRF.objects.all(),
                                  required=False,
                                  label='VRF')
    mask_length = forms.IntegerField(min_value=IPADDRESS_MASK_LENGTH_MIN,
                                     max_value=IPADDRESS_MASK_LENGTH_MAX,
                                     required=False)
    tenant = DynamicModelChoiceField(queryset=Tenant.objects.all(),
                                     required=False)
    status = forms.ChoiceField(
        choices=add_blank_choice(IPAddressStatusChoices),
        required=False,
        widget=StaticSelect2())
    role = forms.ChoiceField(choices=add_blank_choice(IPAddressRoleChoices),
                             required=False,
                             widget=StaticSelect2())
    dns_name = forms.CharField(max_length=255, required=False)
    description = forms.CharField(max_length=100, required=False)

    class Meta:
        nullable_fields = [
            'vrf',
            'role',
            'tenant',
            'dns_name',
            'description',
        ]
Example #4
0
 class Meta:
     model = IPAddress
     fields = [
         'address',
         'vrf',
         'status',
         'role',
         'dns_name',
         'description',
         'primary_for_parent',
         'nat_site',
         'nat_rack',
         'nat_device',
         'nat_cluster',
         'nat_virtual_machine',
         'nat_vrf',
         'nat_inside',
         'tenant_group',
         'tenant',
         'tags',
     ]
     widgets = {
         'status': StaticSelect2(),
         'role': StaticSelect2(),
     }
Example #5
0
class IPAddressFilterForm(BootstrapMixin, TenancyFilterForm, CustomFieldFilterForm):
    model = IPAddress
    field_order = [
        'q', 'parent', 'family', 'mask_length', 'vrf_id', 'present_in_vrf_id', 'status', 'role',
        'assigned_to_interface', 'tenant_group_id', 'tenant_id',
    ]
    q = forms.CharField(
        required=False,
        label=_('Search')
    )
    parent = forms.CharField(
        required=False,
        widget=forms.TextInput(
            attrs={
                'placeholder': 'Prefix',
            }
        ),
        label='Parent Prefix'
    )
    family = forms.ChoiceField(
        required=False,
        choices=add_blank_choice(IPAddressFamilyChoices),
        label=_('Address family'),
        widget=StaticSelect2()
    )
    mask_length = forms.ChoiceField(
        required=False,
        choices=IPADDRESS_MASK_LENGTH_CHOICES,
        label=_('Mask length'),
        widget=StaticSelect2()
    )
    vrf_id = DynamicModelMultipleChoiceField(
        queryset=VRF.objects.all(),
        required=False,
        label=_('Assigned VRF'),
        null_option='Global'
    )
    present_in_vrf_id = DynamicModelChoiceField(
        queryset=VRF.objects.all(),
        required=False,
        label=_('Present in VRF')
    )
    status = forms.MultipleChoiceField(
        choices=IPAddressStatusChoices,
        required=False,
        widget=StaticSelect2Multiple()
    )
    role = forms.MultipleChoiceField(
        choices=IPAddressRoleChoices,
        required=False,
        widget=StaticSelect2Multiple()
    )
    assigned_to_interface = forms.NullBooleanField(
        required=False,
        label=_('Assigned to an interface'),
        widget=StaticSelect2(
            choices=BOOLEAN_WITH_BLANK_CHOICES
        )
    )
    tag = TagFilterField(model)
class ServiceRuleForm(BootstrapMixin, forms.ModelForm):
    service = forms.ModelChoiceField(queryset=Service.objects.all(),
                                     widget=StaticSelect2())

    description = forms.CharField(
        required=False,
        label="Description",
    )

    device_role = DynamicModelMultipleChoiceField(
        queryset=DeviceRole.objects.all(),
        required=True,
    )

    device_type = DynamicModelMultipleChoiceField(
        queryset=DeviceType.objects.all(),
        required=False,
        label='Model',
        display_field="model",
        widget=APISelectMultiple())

    template = forms.ModelChoiceField(
        queryset=Template.objects.order_by('name'), widget=StaticSelect2())

    class Meta:
        model = Template
        fields = [
            'service', 'device_role', 'device_type', 'template', 'description'
        ]
Example #7
0
class ScheduledTaskCreateForm(BootstrapMixin, forms.Form):
    model = ScheduledTask
    pk = forms.ModelMultipleChoiceField(queryset=Device.objects.all(), widget=forms.MultipleHiddenInput())
    task_type = forms.ChoiceField(
        choices=TaskTypeChoices, required=True, label="Job Type", initial="", widget=StaticSelect2()
    )
    scheduled_time = forms.DateTimeField(
        label="Scheduled Time",
        required=False,
        widget=DateTimePicker(),
    )
    mw_duration = forms.IntegerField(
        required=True,
        initial=6,
        label="MW Duration, Hrs.",
    )

    start_now = ["scheduled_time"]

    transfer_method = forms.ChoiceField(
        choices=TaskTransferMethod,
        required=True,
        label="Transfer Method",
        initial=DEFAULT_TRANSFER_METHOD,
        widget=StaticSelect2(),
    )

    class Meta:
        start_now = ["scheduled_time"]

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.fields["mw_duration"].widget.attrs["max"] = 8
        self.fields["mw_duration"].widget.attrs["min"] = 1
Example #8
0
class ObjectChangeFilterForm(BootstrapMixin, forms.Form):
    model = ObjectChange
    q = forms.CharField(
        required=False,
        label='Search'
    )
    time_after = forms.DateTimeField(
        label='After',
        required=False,
        widget=DateTimePicker()
    )
    time_before = forms.DateTimeField(
        label='Before',
        required=False,
        widget=DateTimePicker()
    )
    action = forms.ChoiceField(
        choices=add_blank_choice(ObjectChangeActionChoices),
        required=False,
        widget=StaticSelect2()
    )
    # TODO: Convert to DynamicModelMultipleChoiceField once we have an API endpoint for users
    user = forms.ModelChoiceField(
        queryset=User.objects.order_by('username'),
        required=False,
        widget=StaticSelect2()
    )
    changed_object_type = forms.ModelChoiceField(
        queryset=ContentType.objects.order_by('model'),
        required=False,
        widget=ContentTypeSelect(),
        label='Object Type'
    )
Example #9
0
class PrefixFilterForm(BootstrapMixin, TenancyFilterForm,
                       CustomFieldFilterForm):
    model = Prefix
    field_order = [
        'q',
        'within_include',
        'family',
        'mask_length',
        'vrf_id',
        'status',
        'region',
        'site',
        'role',
        'tenant_group',
        'tenant',
        'is_pool',
        'expand',
    ]
    mask_length__lte = forms.IntegerField(widget=forms.HiddenInput())
    q = forms.CharField(required=False, label='Search')
    within_include = forms.CharField(
        required=False,
        widget=forms.TextInput(attrs={
            'placeholder': 'Prefix',
        }),
        label='Search within')
    family = forms.ChoiceField(
        required=False,
        choices=add_blank_choice(IPAddressFamilyChoices),
        label='Address family',
        widget=StaticSelect2())
    mask_length = forms.ChoiceField(required=False,
                                    choices=PREFIX_MASK_LENGTH_CHOICES,
                                    label='Mask length',
                                    widget=StaticSelect2())
    vrf_id = DynamicModelMultipleChoiceField(queryset=VRF.objects.all(),
                                             required=False,
                                             label='VRF',
                                             null_option='Global')
    status = forms.MultipleChoiceField(choices=PrefixStatusChoices,
                                       required=False,
                                       widget=StaticSelect2Multiple())
    region = DynamicModelMultipleChoiceField(queryset=Region.objects.all(),
                                             to_field_name='slug',
                                             required=False)
    site = DynamicModelMultipleChoiceField(queryset=Site.objects.all(),
                                           to_field_name='slug',
                                           required=False,
                                           null_option='None',
                                           query_params={'region': '$region'})
    role = DynamicModelMultipleChoiceField(queryset=Role.objects.all(),
                                           to_field_name='slug',
                                           required=False,
                                           null_option='None')
    is_pool = forms.NullBooleanField(
        required=False,
        label='Is a pool',
        widget=StaticSelect2(choices=BOOLEAN_WITH_BLANK_CHOICES))
    tag = TagFilterField(model)
Example #10
0
File: forms.py Project: wuwx/netbox
class PrefixFilterForm(BootstrapMixin, CustomFieldFilterForm):
    model = Prefix
    q = forms.CharField(required=False, label='Search')
    within_include = forms.CharField(
        required=False,
        widget=forms.TextInput(attrs={
            'placeholder': 'Prefix',
        }),
        label='Search within')
    family = forms.ChoiceField(required=False,
                               choices=IP_FAMILY_CHOICES,
                               label='Address family',
                               widget=StaticSelect2())
    mask_length = forms.ChoiceField(required=False,
                                    choices=PREFIX_MASK_LENGTH_CHOICES,
                                    label='Mask length',
                                    widget=StaticSelect2())
    vrf = FilterChoiceField(queryset=VRF.objects.all(),
                            to_field_name='rd',
                            label='VRF',
                            null_label='-- Global --',
                            widget=APISelectMultiple(
                                api_url="/api/ipam/vrfs/",
                                value_field="rd",
                                null_option=True,
                            ))
    tenant = FilterChoiceField(queryset=Tenant.objects.all(),
                               to_field_name='slug',
                               null_label='-- None --',
                               widget=APISelectMultiple(
                                   api_url="/api/tenancy/tenants/",
                                   value_field="slug",
                                   null_option=True,
                               ))
    status = forms.MultipleChoiceField(choices=PREFIX_STATUS_CHOICES,
                                       required=False,
                                       widget=StaticSelect2Multiple())
    site = FilterChoiceField(queryset=Site.objects.all(),
                             to_field_name='slug',
                             null_label='-- None --',
                             widget=APISelectMultiple(
                                 api_url="/api/dcim/sites/",
                                 value_field="slug",
                                 null_option=True,
                             ))
    role = FilterChoiceField(queryset=Role.objects.all(),
                             to_field_name='slug',
                             null_label='-- None --',
                             widget=APISelectMultiple(
                                 api_url="/api/ipam/roles/",
                                 value_field="slug",
                                 null_option=True,
                             ))
    is_pool = forms.NullBooleanField(
        required=False,
        label='Is a pool',
        widget=StaticSelect2(choices=BOOLEAN_WITH_BLANK_CHOICES))
    expand = forms.BooleanField(required=False,
                                label='Expand prefix hierarchy')
Example #11
0
class IPAddressFilterForm(BootstrapMixin, CustomFieldFilterForm):
    model = IPAddress
    q = forms.CharField(
        required=False,
        label='Search'
    )
    parent = forms.CharField(
        required=False,
        widget=forms.TextInput(
            attrs={
                'placeholder': 'Prefix',
            }
        ),
        label='Parent Prefix'
    )
    family = forms.ChoiceField(
        required=False,
        choices=IP_FAMILY_CHOICES,
        label='Address family',
        widget=StaticSelect2()
    )
    mask_length = forms.ChoiceField(
        required=False,
        choices=IPADDRESS_MASK_LENGTH_CHOICES,
        label='Mask length',
        widget=StaticSelect2()
    )
    vrf = FilterChoiceField(
        queryset=VRF.objects.all(),
        to_field_name='rd',
        label='VRF',
        null_label='-- Global --',
        widget=APISelectMultiple(
            api_url="/api/ipam/vrfs/",
            value_field="slug",
            null_option=True,
        )
    )
    tenant = FilterChoiceField(
        queryset=Tenant.objects.all(),
        to_field_name='slug',
        null_label='-- None --',
        widget=APISelectMultiple(
            api_url="/api/tenancy/tenants/",
            value_field="slug",
            null_option=True,
        )
    )
    status = forms.MultipleChoiceField(
        choices=IPADDRESS_STATUS_CHOICES,
        required=False,
        widget=StaticSelect2Multiple()
    )
    role = forms.MultipleChoiceField(
        choices=IPADDRESS_ROLE_CHOICES,
        required=False,
        widget=StaticSelect2Multiple()
    )
Example #12
0
File: forms.py Project: cfck/netbox
class IPAddressFilterForm(BootstrapMixin, TenancyFilterForm, CustomFieldFilterForm):
    model = IPAddress
    field_order = [
        'q', 'parent', 'family', 'mask_length', 'vrf_id', 'status', 'role', 'assigned_to_interface', 'tenant_group',
        'tenant',
    ]
    q = forms.CharField(
        required=False,
        label='Search'
    )
    parent = forms.CharField(
        required=False,
        widget=forms.TextInput(
            attrs={
                'placeholder': 'Prefix',
            }
        ),
        label='Parent Prefix'
    )
    family = forms.ChoiceField(
        required=False,
        choices=IP_FAMILY_CHOICES,
        label='Address family',
        widget=StaticSelect2()
    )
    mask_length = forms.ChoiceField(
        required=False,
        choices=IPADDRESS_MASK_LENGTH_CHOICES,
        label='Mask length',
        widget=StaticSelect2()
    )
    vrf_id = FilterChoiceField(
        queryset=VRF.objects.all(),
        label='VRF',
        null_label='-- Global --',
        widget=APISelectMultiple(
            api_url="/api/ipam/vrfs/",
            null_option=True,
        )
    )
    status = forms.MultipleChoiceField(
        choices=IPADDRESS_STATUS_CHOICES,
        required=False,
        widget=StaticSelect2Multiple()
    )
    role = forms.MultipleChoiceField(
        choices=IPADDRESS_ROLE_CHOICES,
        required=False,
        widget=StaticSelect2Multiple()
    )
    assigned_to_interface = forms.NullBooleanField(
        required=False,
        label='Assigned to an interface',
        widget=StaticSelect2(
            choices=BOOLEAN_WITH_BLANK_CHOICES
        )
    )
Example #13
0
 class Meta:
     model = IPAddress
     fields = [
         'address', 'vrf', 'status', 'role', 'dns_name', 'description', 'tenant_group', 'tenant',
     ]
     widgets = {
         'status': StaticSelect2(),
         'role': StaticSelect2(),
     }
class ServiceMappingForm(BootstrapMixin, forms.ModelForm):
    service = forms.ModelChoiceField(queryset=Service.objects.all(),
                                     widget=StaticSelect2())

    device = forms.ModelChoiceField(queryset=Device.objects.all(),
                                    widget=StaticSelect2())

    class Meta:
        model = ServiceMapping
        fields = ['service', 'device']
Example #15
0
 class Meta:
     model = IPAddress
     fields = [
         'address', 'vrf', 'status', 'role', 'dns_name', 'description', 'tenant_group', 'tenant',
     ]
     widgets = {
         'status': StaticSelect2(),
         'role': StaticSelect2(),
         'vrf': APISelect(
             api_url="/api/ipam/vrfs/"
         )
     }
Example #16
0
 class Meta:
     model = IPAddress
     fields = [
         'address', 'vrf', 'status', 'role', 'dns_name', 'description', 'interface', 'primary_for_parent',
         'nat_site', 'nat_rack', 'nat_inside', 'tenant_group', 'tenant', 'tags',
     ]
     widgets = {
         'status': StaticSelect2(),
         'role': StaticSelect2(),
         'vrf': APISelect(
             api_url="/api/ipam/vrfs/"
         )
     }
Example #17
0
class ServiceBulkEditForm(BootstrapMixin, CustomFieldBulkEditForm):
    pk = forms.ModelMultipleChoiceField(
        queryset=Service.objects.all(),
        widget=forms.MultipleHiddenInput()
    )
    protocol = forms.ChoiceField(
        choices=add_blank_choice(IP_PROTOCOL_CHOICES),
        required=False,
        widget=StaticSelect2()
    )
    port = forms.IntegerField(
        validators=[
            MinValueValidator(1),
            MaxValueValidator(65535),
        ],
        required=False
    )
    description = forms.CharField(
        max_length=100,
        required=False
    )

    class Meta:
        nullable_fields = [
            'site', 'tenant', 'role', 'description',
        ]
Example #18
0
class RespBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldBulkEditForm):
    pk = forms.ModelMultipleChoiceField(
        queryset = Resp.objects.all(),
        widget = forms.MultipleHiddenInput(
        # api_url='/api/plugins/sdns/resp'
        )
    )

    tipo = forms.ChoiceField(
        choices=add_blank_choice(RespChoices),
        widget=StaticSelect2()
    )

    dom = DynamicModelChoiceField(
        queryset= Domain.objects.all(),
        display_field='Domain',
        label='Dominio',
        required= False,
        widget= APISelect(
            api_url='/api/plugins/sdns/domain',
        )
    )

    class Meta:
        nullable_fields = [ ]
Example #19
0
class VLANBulkEditForm(BootstrapMixin, AddRemoveTagsForm,
                       CustomFieldBulkEditForm):
    pk = forms.ModelMultipleChoiceField(queryset=VLAN.objects.all(),
                                        widget=forms.MultipleHiddenInput())
    region = DynamicModelChoiceField(queryset=Region.objects.all(),
                                     required=False,
                                     to_field_name='slug')
    site = DynamicModelChoiceField(queryset=Site.objects.all(),
                                   required=False,
                                   query_params={'region': '$region'})
    group = DynamicModelChoiceField(queryset=VLANGroup.objects.all(),
                                    required=False,
                                    query_params={'site_id': '$site'})
    tenant = DynamicModelChoiceField(queryset=Tenant.objects.all(),
                                     required=False)
    status = forms.ChoiceField(choices=add_blank_choice(VLANStatusChoices),
                               required=False,
                               widget=StaticSelect2())
    role = DynamicModelChoiceField(queryset=Role.objects.all(), required=False)
    description = forms.CharField(max_length=100, required=False)

    class Meta:
        nullable_fields = [
            'site',
            'group',
            'tenant',
            'role',
            'description',
        ]
Example #20
0
 class Meta:
     model = Interface
     fields = [
         'virtual_machine',
         'name',
         'type',
         'enabled',
         'mac_address',
         'mtu',
         'description',
         'mode',
         'tags',
         'untagged_vlan',
         'tagged_vlans',
     ]
     widgets = {
         'virtual_machine': forms.HiddenInput(),
         'type': forms.HiddenInput(),
         'mode': StaticSelect2()
     }
     labels = {
         'mode': '802.1Q Mode',
     }
     help_texts = {
         'mode': INTERFACE_MODE_HELP_TEXT,
     }
Example #21
0
class VirtualMachineBulkEditForm(BootstrapMixin, AddRemoveTagsForm,
                                 CustomFieldBulkEditForm):
    pk = forms.ModelMultipleChoiceField(queryset=VirtualMachine.objects.all(),
                                        widget=forms.MultipleHiddenInput())
    status = forms.ChoiceField(
        choices=add_blank_choice(VirtualMachineStatusChoices),
        required=False,
        initial='',
        widget=StaticSelect2(),
    )
    cluster = DynamicModelChoiceField(queryset=Cluster.objects.all(),
                                      required=False)
    role = DynamicModelChoiceField(
        queryset=DeviceRole.objects.filter(vm_role=True),
        required=False,
        widget=APISelect(additional_query_params={"vm_role": "True"}))
    tenant = DynamicModelChoiceField(queryset=Tenant.objects.all(),
                                     required=False)
    platform = DynamicModelChoiceField(queryset=Platform.objects.all(),
                                       required=False)
    vcpus = forms.IntegerField(required=False, label='vCPUs')
    memory = forms.IntegerField(required=False, label='Memory (MB)')
    disk = forms.IntegerField(required=False, label='Disk (GB)')
    comments = CommentField(widget=SmallTextarea, label='Comments')

    class Meta:
        nullable_fields = [
            'role',
            'tenant',
            'platform',
            'vcpus',
            'memory',
            'disk',
            'comments',
        ]
Example #22
0
class ServiceBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldBulkEditForm):
    pk = forms.ModelMultipleChoiceField(
        queryset=Service.objects.all(),
        widget=forms.MultipleHiddenInput()
    )
    protocol = forms.ChoiceField(
        choices=add_blank_choice(ServiceProtocolChoices),
        required=False,
        widget=StaticSelect2()
    )
    ports = NumericArrayField(
        base_field=forms.IntegerField(
            min_value=SERVICE_PORT_MIN,
            max_value=SERVICE_PORT_MAX
        ),
        required=False
    )
    description = forms.CharField(
        max_length=100,
        required=False
    )

    class Meta:
        nullable_fields = [
            'description',
        ]
Example #23
0
 class Meta:
     model = Circuit
     fields = [
         'cid',
         'type',
         'provider',
         'status',
         'install_date',
         'commit_rate',
         'description',
         'tenant_group',
         'tenant',
         'comments',
         'tags',
     ]
     help_texts = {
         'cid': "Unique circuit ID",
         'commit_rate': "Committed rate",
     }
     widgets = {
         'provider': APISelect(api_url="/api/circuits/providers/"),
         'type': APISelect(api_url="/api/circuits/circuit-types/"),
         'status': StaticSelect2(),
         'install_date': DatePicker(),
     }
Example #24
0
class VMInterfaceFilterForm(forms.Form):
    model = VMInterface
    cluster_id = DynamicModelMultipleChoiceField(
        queryset=Cluster.objects.all(),
        required=False,
        label='Cluster'
    )
    virtual_machine_id = DynamicModelMultipleChoiceField(
        queryset=VirtualMachine.objects.all(),
        required=False,
        label='Virtual machine',
        query_params={
            'cluster_id': '$cluster_id'
        }
    )
    enabled = forms.NullBooleanField(
        required=False,
        widget=StaticSelect2(
            choices=BOOLEAN_WITH_BLANK_CHOICES
        )
    )
    mac_address = forms.CharField(
        required=False,
        label='MAC address'
    )
    tag = TagFilterField(model)
Example #25
0
 class Meta:
     model = VLAN
     fields = [
         'site',
         'group',
         'vid',
         'name',
         'status',
         'role',
         'description',
         'tenant_group',
         'tenant',
         'tags',
     ]
     help_texts = {
         'site': "Leave blank if this VLAN spans multiple sites",
         'group': "VLAN group (optional)",
         'vid': "Configured VLAN ID",
         'name': "Configured VLAN name",
         'status': "Operational status of this VLAN",
         'role': "The primary function of this VLAN",
     }
     widgets = {
         'status': StaticSelect2(),
     }
Example #26
0
class CircuitBulkEditForm(BootstrapMixin, AddRemoveTagsForm,
                          CustomFieldBulkEditForm):
    pk = forms.ModelMultipleChoiceField(queryset=Circuit.objects.all(),
                                        widget=forms.MultipleHiddenInput)
    type = forms.ModelChoiceField(
        queryset=CircuitType.objects.all(),
        required=False,
        widget=APISelect(api_url="/api/circuits/circuit-types/"))
    provider = forms.ModelChoiceField(
        queryset=Provider.objects.all(),
        required=False,
        widget=APISelect(api_url="/api/circuits/providers/"))
    status = forms.ChoiceField(
        choices=add_blank_choice(CIRCUIT_STATUS_CHOICES),
        required=False,
        initial='',
        widget=StaticSelect2())
    tenant = forms.ModelChoiceField(
        queryset=Tenant.objects.all(),
        required=False,
        widget=APISelect(api_url="/api/tenancy/tenants/"))
    commit_rate = forms.IntegerField(required=False,
                                     label='Commit rate (Kbps)')
    description = forms.CharField(max_length=100, required=False)
    comments = CommentField(widget=SmallTextarea, label='Comments')

    class Meta:
        nullable_fields = [
            'tenant',
            'commit_rate',
            'description',
            'comments',
        ]
Example #27
0
class VLANBulkEditForm(BootstrapMixin, AddRemoveTagsForm,
                       CustomFieldBulkEditForm):
    pk = forms.ModelMultipleChoiceField(queryset=VLAN.objects.all(),
                                        widget=forms.MultipleHiddenInput())
    site = forms.ModelChoiceField(queryset=Site.objects.all(),
                                  required=False,
                                  widget=APISelect(api_url="/api/dcim/sites/"))
    group = forms.ModelChoiceField(
        queryset=VLANGroup.objects.all(),
        required=False,
        widget=APISelect(api_url="/api/ipam/vlan-groups/"))
    tenant = forms.ModelChoiceField(
        queryset=Tenant.objects.all(),
        required=False,
        widget=APISelect(api_url="/api/tenancy/tenants/"))
    status = forms.ChoiceField(choices=add_blank_choice(VLANStatusChoices),
                               required=False,
                               widget=StaticSelect2())
    role = forms.ModelChoiceField(queryset=Role.objects.all(),
                                  required=False,
                                  widget=APISelect(api_url="/api/ipam/roles/"))
    description = forms.CharField(max_length=100, required=False)

    class Meta:
        nullable_fields = [
            'site',
            'group',
            'tenant',
            'role',
            'description',
        ]
Example #28
0
class PrefixBulkEditForm(BootstrapMixin, AddRemoveTagsForm,
                         CustomFieldBulkEditForm):
    pk = forms.ModelMultipleChoiceField(queryset=Prefix.objects.all(),
                                        widget=forms.MultipleHiddenInput())
    site = DynamicModelChoiceField(queryset=Site.objects.all(), required=False)
    vrf = DynamicModelChoiceField(queryset=VRF.objects.all(),
                                  required=False,
                                  label='VRF')
    prefix_length = forms.IntegerField(min_value=PREFIX_LENGTH_MIN,
                                       max_value=PREFIX_LENGTH_MAX,
                                       required=False)
    tenant = DynamicModelChoiceField(queryset=Tenant.objects.all(),
                                     required=False)
    status = forms.ChoiceField(choices=add_blank_choice(PrefixStatusChoices),
                               required=False,
                               widget=StaticSelect2())
    role = DynamicModelChoiceField(queryset=Role.objects.all(), required=False)
    is_pool = forms.NullBooleanField(required=False,
                                     widget=BulkEditNullBooleanSelect(),
                                     label='Is a pool')
    description = forms.CharField(max_length=100, required=False)

    class Meta:
        nullable_fields = [
            'site',
            'vrf',
            'tenant',
            'role',
            'description',
        ]
Example #29
0
class VirtualMachineFilterForm(BootstrapMixin, TenancyFilterForm,
                               CustomFieldFilterForm):
    model = VirtualMachine
    field_order = [
        'q',
        'cluster_group_id',
        'cluster_type_id',
        'cluster_id',
        'status',
        'role_id',
        'region_id',
        'site_id',
        'tenant_group_id',
        'tenant_id',
        'platform_id',
        'mac_address',
    ]
    q = forms.CharField(required=False, label=_('Search'))
    cluster_group_id = DynamicModelMultipleChoiceField(
        queryset=ClusterGroup.objects.all(),
        required=False,
        null_option='None',
        label=_('Cluster group'))
    cluster_type_id = DynamicModelMultipleChoiceField(
        queryset=ClusterType.objects.all(),
        required=False,
        null_option='None',
        label=_('Cluster type'))
    cluster_id = DynamicModelMultipleChoiceField(
        queryset=Cluster.objects.all(), required=False, label=_('Cluster'))
    region_id = DynamicModelMultipleChoiceField(queryset=Region.objects.all(),
                                                required=False,
                                                label=_('Region'))
    site_id = DynamicModelMultipleChoiceField(
        queryset=Site.objects.all(),
        required=False,
        null_option='None',
        query_params={'region_id': '$region_id'},
        label=_('Cluster'))
    role_id = DynamicModelMultipleChoiceField(
        queryset=DeviceRole.objects.all(),
        required=False,
        null_option='None',
        query_params={'vm_role': "True"},
        label=_('Role'))
    status = forms.MultipleChoiceField(choices=VirtualMachineStatusChoices,
                                       required=False,
                                       widget=StaticSelect2Multiple())
    platform_id = DynamicModelMultipleChoiceField(
        queryset=Platform.objects.all(),
        required=False,
        null_option='None',
        label=_('Platform'))
    mac_address = forms.CharField(required=False, label='MAC address')
    has_primary_ip = forms.NullBooleanField(
        required=False,
        label='Has a primary IP',
        widget=StaticSelect2(choices=BOOLEAN_WITH_BLANK_CHOICES))
    tag = TagFilterField(model)
Example #30
0
class RIRFilterForm(BootstrapMixin, forms.Form):
    is_private = forms.NullBooleanField(
        required=False,
        label='Private',
        widget=StaticSelect2(
            choices=BOOLEAN_WITH_BLANK_CHOICES
        )
    )