Skip to content

Add device_id and virtual_machine_id to ipam.forms.filtersets.ServiceFilterForm #13951

@atownson

Description

@atownson

NetBox version

v3.5.7

Feature type

Change to existing functionality

Proposed functionality

I propose to add fields device_id and virtual_machine_id to the ServiceFilterForm class. Currently there's no way to filter a service by the associated device or virtual machine in the web form. The search method also does not include these fields.

image

image

The API does support filtering by device and virtual machine.

This feature request can be accomplished by updating the filtersets.py from:

class ServiceFilterForm(ServiceTemplateFilterForm):
    model = Service
    tag = TagFilterField(model)

to:

class ServiceFilterForm(ServiceTemplateFilterForm):
    model = Service
    fieldsets = (
        (None, ('q', 'filter_id', 'tag')),
        (_('Attributes'), ('protocol', 'port')),
        (_('Device/VM'), ('device_id', 'virtual_machine_id')),
    )
    device_id = DynamicModelMultipleChoiceField(
        queryset=Device.objects.all(),
        required=False,
        label=_('Assigned Device'),
    )
    virtual_machine_id = DynamicModelMultipleChoiceField(
        queryset=VirtualMachine.objects.all(),
        required=False,
        label=_('Assigned VM'),
    )

Result:
image

image

I could handle this PR if desired and if this request is approved.

Use case

Adding these fields would improve the user experience, align the services model filterset with the IP address model filterset, and provide functionality available in the API to the web filter forms.

Database changes

None

External dependencies

None

Metadata

Metadata

Assignees

Labels

status: acceptedThis issue has been accepted for implementationtype: featureIntroduction of new functionality to the application

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions