Skip to content

Instantly share code, notes, and snippets.

@jathanism
Last active June 16, 2022 15:26
Show Gist options
  • Save jathanism/7c585954da4cb1a54997be31991cdaac to your computer and use it in GitHub Desktop.
Save jathanism/7c585954da4cb1a54997be31991cdaac to your computer and use it in GitHub Desktop.

FilterSet Feature Inventory

The purpose of this document is to inventory all existing FilterSetclasses within the Nautobot core to identify gaps in declared filters compared to available model fields.

Core/Utilities

Utilities are being included with core since nautobot.utilities.filters.BaseModelSet is the bread and butter here and we may very well end up folding all of the primitives from Utilities into Core to streamline the namespace.

BaseFilterSet

  • The model field to filter field mapping at BaseFilterSet.FILTER_DEFAULTS needs to also include the correct UI widget types in the extra for the filter mapping
  • Filter mappings for ALL custom field types should be extended
    • For example TaggableManager should always be mapped to TagFilter to obviate the need to define tag/tags on every new filterset that requires tags.
  • The base form used should be included by default on the Meta.form option. This base form should be what is used as the base form for our UI including its own model field to form field mappings. (See field_classes on that page).
  • Patterns where foo_id (pk) and foo (slug) filters are defined should be accounted for automatically, either by automatically doing this for fields with a slug value, or introducing a hybrid pk/slug filter field that can take both without needing to explicitly define them on every new filterset.

Extending automatically generated filters

Related/related_id filters
  • We should consider a pattern to map certain pk/slug related fields that are common such as site/site_id, region/region_id etc. Consider CircuitFilterSet as an example.
    • It does not have a site field and instead derives site from terminations__site__slug
    • Region similiarly is derived from terminations__site__region
  • So a "foo_lookup_field" pattern in the filterset meta would be useful here to help reduce boiler plate e.g.:
class CircuitFilterSet:
    class Meta:
        site_lookup_field = "terminations__site__slug"
        region_lookup_field = "terminations__site__region"
  • Then if these meta options are defined, the filterset automatically gets site and region filters without having to explicitly define them.
Related membership filters
  • In cases where there is a reverse related manager field (such as Device.interfaces) a BooleanFilter with lookup_expr="isnull" and exclude=True named with has_{field_name} should be automatically generated.

MultiVarCharFilter

This filter needs to be adapted since there are cases where CharField filters (such as DeviceFilterSet.name) do not make any sense as what gets rendered as a DynamicMultipleChoiceField in many forms. The dynamically generated MultiValueCharField that gets generated doesn't necessarily map to non-choice-backed fields (e.g. Device.name)

  • As generated, it inherits from MultipleChoiceFilter , but this should only be the case it is eligible to have choices provided at filter definition time.
  • A raw char field (like Device.name) does not inherently have any choices to from which to choose, so a MultiVarCharFilter it is incorrect to make it a choice filter unless choices are also provided.
  • A pattern similar to what we had to do with ContentTypeFilter (inherits from CharFilter) and ContentTypeChoiceFilter (inherits from ChoiceFilter) with a common mixin (ContentTypeFilterMixin) shared between them should be considered here.
  • This is an important consideration for generating UI fields automatically from filtersets

NameSlugSearchFilterSet

This should be renamed to NameSlugSearchFilterSetMixin because it is a mixin.

NullableCharFilter

This filter needs to go away in v2. It is not even used.

Further, it is bad data design to have CharField with null=True because this introduces two ways such a field can be considered "empty" (both an empty string or None). From the Django docs on null:

Avoid using null on string-based fields such as CharField and TextField. If a string-based field has null=True, that means it has two possible values for “no data”: NULL, and the empty string. In most cases, it’s redundant to have two possible values for “no data;” the Django convention is to use the empty string, not NULL. One exception is when a CharField has both unique=True and blank=True set. In this situation, null=True is required to avoid unique constraint violations when saving multiple objects with blank values.

TreeNodeMultipleChoiceFilter

  • This filter will likely go away as it is tightly coupled to calling .get_descendants() on member objects. If it is not removed, it will need to be replaced with something similar (related to work such as "IPAM objects as trees")

Circuits

CircuitFilterSet

Missing fields

  • comments
  • description
  • provider_network
  • termination_a
  • termination_z
  • terminations (reverse related field)
    • Should also include has_terminations membership filter

Incorrect fields

  • tag -> tags

CircuitTerminationFilterSet

Missing fields

  • circuit (slug/name/cid filter)
  • provider_network (name/slug filter)
  • pp_info
  • description

CircuitTypeFilterSet

Missing fields

  • description

ProviderFilterSet

Missing fields

  • portal_url
  • noc_contact
  • admin_contact
  • comments
  • provider_networks (reverse related field)
    • Should also include has_provider_networks membership filter
  • circuits (reverse related field)
    • Should also include has_circuits membership filter

Incorrect fields

  • tag -> tags

ProviderNetworkFilterSet

Missing fields

  • circuit_terminations (reverse related field)
    • Should also include has_circuit_terminations membership filter
  • comments
  • description

Incorrect fields

  • tag -> tags

DCIM

CableFilterSet

Missing fields

  • termination_a_type
  • termination_a_id
  • termination_a
  • termination_b_type
  • termination_b_id
  • termination_b

Incorrect fields

  • So many of these filter fields are pointing to the filter_device method. This is broken. We can solve this more generically.

CablePathFilterSet

This filterset does not even exist and it should.

CableTerminationFilterSet

Incorrect fields

  • cable
  • cabled -> has_cable

ConnectionFilterSet

This should be renamed to ConnectionFilterSetMixin because it is a mixin.

ConsolePortFilterSet

Needs Meta.fields = "__all__" once DeviceComponentFilterSet is updated w/ missing fields

ConsolePortTemplateFilterSet

Missing fields

  • device_type
  • label
  • description

ConsoleServerPortFilterSet

Needs Meta.fields = "__all__" once DeviceComponentFilterSet is updated w/ missing fields

ConsoleServerPortTemplateFilterSet

Missing fields

  • device_type
  • label
  • description

DeviceFilterSet

Missing fields

  • rack
  • device_type
  • cluster
  • virtual_chassis
  • comments
  • primary_ip4
  • primary_ip6
  • consoleports (reverse related)
    • And has_consoleports
  • consoleserverports (reverse related)
    • And has_consoleserverports
  • devicebays (reverse related)
    • And has_devicebays
  • frontports (reverse related)
    • And has_frontports
  • inventoryitems (reverse related)
    • And has_inventoryitems
  • parent_bay (reverse related)
    • And has_parent_bay
  • poweroutlets (reverse related)
    • And has_poweroutlets
  • powerports (reverse related)
    • And has_powerports
  • rearports (reverse related)
    • And has_rearports
  • services (reverse related)
    • And has_services
  • vc_master_for (reverse related)
    • And has_vc_master_for

Incorrect fields

  • role -> device_role
  • interfaces should be (reverse related)
    • And then assert it has ben included has_interfaces

DeviceBayFilterSet

Missing fields

  • installed_device
  • label
  • description

DeviceBayTemplateFilterSet

Missing fields

  • device_type
  • label
  • description

DeviceComponentFilterSet

Should be renamed to DeviceComponentFilterSetMixin because it is a mixin.

Missing fields

  • label
  • description

Incorrect fields

  • tag -> tags

DeviceRoleFilterSet

Missing fields

  • description
  • devices (reverse related)
    • And has_devices
  • virtual_machines (reverse related)
    • And has_virtual_machines

DeviceTypeFilterSet

Missing fields

  • comments

  • instances (reverse)

    • And has_instances
  • consoleporttemplates

    • Should be named consoleport_templates
    • And has_consoleport_templates
  • consoleserverporttemplates

    • Should be named consoleserverport_templates
    • And has_consoleserverport_templates
  • powerporttemplates

    • Should be named powerport_templates
    • And has_powerport_templates
  • poweroutlettemplates

    • Should be named poweroutlet_templates
    • And has_poweroutlet_templates
  • interfacetemplates

    • Should be named interface_templates
    • And has_interface_templates
  • frontporttemplates

    • Should be named frontport_templates
    • And has_frontport_templates
  • rearporttemplates

    • Should be named rearport_templates
    • And has_rearport_templates
  • devicebaytemplates

    • Should be named devicebay_templates
    • And has_devicebay_templates

Incorrect fields

  • tag -> tags
  • Each of the related names listed above in missing fields instead has its on method that should be eliminated as the naming is incorrect an

FrontPortFilterSet

Missing fields

  • label
  • description
  • rear_port
  • rear_port_position

FrontPortTemplateFilterSet

Missing fields

  • device_type
  • label
  • description
  • rear_port
  • rear_port_position

InterfaceFilterSet

Needs Meta.fields = "__all__" once DeviceComponentFilterSet is updated w/ missing fields

Missing fields

  • lag
  • untagged_vlan
  • tagged_vlans
  • ip_addresses
  • member_interfaces (reverse related)
    • Also has_member_interfaces membership filter

Incorrect fields

  • kind and filter_kind method apparently overlaps with type. Can we abstract?
  • vlan_id and vlan are both calling methods. Why?
  • tag -> tags

InterfaceTemplateFilterSet

Missing fields

  • device_type
  • label
  • description

InventoryItemFilterSet

Missing fields

  • parent
  • serial

ManufacturerFilterSet

It's actually perfect! Only change would be to set Meta.fields = "__all__".

PathEndpointFilterSet

Should be renamed to PathEndpointFilterSetMixin because it is a mixin.

PlatformFilterSet

Missing fields

  • napalm_args
  • description
  • devices (reverse related)
    • And has_devices
  • virtual_machines (reverse related)
    • And has_virtual_machines

PowerFeedFilterSet

Missing fields

  • power_panel
  • rack
  • available_power
  • comments

PowerPanelFilterSet

Missing fields

  • rack_group
  • powerfeeds (reverse related)
    • And has_powerfeeds

Incorrect fields

  • tag -> tags

PowerPortFilterSet

Needs Meta.fields = "__all__" once DeviceComponentFilterSet is updated w/ missing fields

PowerPortTemplateFilterSet

Missing fields

  • device_type
  • label
  • description
  • power_port
  • poweroutlet_templates (reverse related)
    • And has_poweroutlet_templates membership filter

PowerOutletFilterSet

Needs Meta.fields = "__all__" once DeviceComponentFilterSet is updated w/ missing fields

PowerOutletTemplateFilterSet

Missing fields

  • device_type
  • label
  • description

RackFilterSet

Missing fields

  • comments
  • devices (reverse related)
    • And has_devices
  • powerfeed (reverse related)
    • Should be called powerfeeds (plural)
    • And has_powerfeeds
  • reservations (reverse related)
    • And has_reservations

Incorrect fields

RackGroupFilterSet

Missing fields

  • children (reverse related)
    • And has_children
  • powerpanel (reverse related)
    • Should be called powerpanels (plural)
    • And has_powerpanels
  • racks (reverse related)
    • And has_racks

RackReservationFilterSet

Missing fields

  • rack
  • description

Incorrect fields

  • tag -> tags

RackRoleFilterSet

Missing fields

  • description
  • racks (reverse related)
    • And has_racks

RearPortFilterSet

Missing fields

  • label
  • description
  • frontports (reverse related)
    • And has_frontports membership filter

RearPortTemplateFilterSet

Missing fields

  • device_type
  • label
  • description
  • frontport_templates (reverse related)
    • And has_frontport_templates membership filter

RegionFilterSet

It's actually perfect! Only change would be to set Meta.fields = "__all__".

Missing fields

  • children (reverse related)
    • And has_children
  • sites (reverse related)
    • And has_sites

SiteFilterSet

Missing fields

  • comments
  • time_zone
  • physical_address
  • shipping_address
  • circuit_terminations (reverse related)
    • And has_circuit_terminations
  • devices (reverse related)
    • And has_devices
  • powerpanel (reverse related)
    • Should be named powerpanels
    • And has_powerpanels
  • rack_groups (reverse related)
    • And has_rack_groups
  • racks (reverse related)
    • And has_racks
  • prefixes (reverse related)
    • And has_prefixes
  • vlan_groups (reverse related)
    • And has_vlan_groups
  • vlans (reverse related)
    • And has_vlans
  • clusters (reverse related)
    • And has_clusters

Incorrect fields

  • tag -> tags

VirtualChassisFilterSet

It's actually perfect! Only change would be to set Meta.fields = "__all__".

Extras

ComputedFieldFilterSet

Missing fields

  • label
  • description
  • advanced_ui (boolean)
    • And has_advanced_ui

ConfigContextFilterSet

Missing fields

  • owner
  • weight
  • description
  • schema

Incorrect fields

  • region -> `regions
  • site -> sites
  • role -> roles
  • platform -> platforms
  • cluster_group -> cluster_groups
  • tenant_group -> tenant_groups
  • tenant -> tenants
  • device_type -> device_types
  • tag -> tags

ConfigContextSchemaFilterSet

Missing fields

  • slug
  • data_schema
  • owner_content_type
  • owner_object_id
  • owner
  • device_set (reverse related)
    • Should be called devices
    • And add has_devices
  • configcontext_set -> config_contexts
    • Should be called config_contexts
    • And add has_config_contexts
  • virtualmachine_set (reverse related)
    • Should be called virtual_machines
    • And add has_virtual_machines

Incorrect fields

  • device_set -> devices
  • configcontext_set -> config_contexts
  • virtualmachine_set -> virtual_machines

CustomFieldChoiceFilterSet

It's actually perfect! Only change would be to set Meta.fields = "__all__".

CustomFieldFilterSet

Missing fields

  • type
  • description
  • default
  • label
  • validation_minimum
  • validation_maximum
  • validation_regex
  • advanced_ui
  • choices (reverse related)
    • And has_choices

CustomLinkFilterSet

It's actually perfect! Only change would be to set Meta.fields = "__all__".

CreatedUpdatedFilterSet

Should be renamed to CreatedUpdatedFilterSetMixin because it is a mixin.

DynamicGroupFilterSet

It's actually perfect! Only change would be to set Meta.fields = "__all__".

ExportTemplateFilterSet

Missing fields

  • owner
  • description
  • template_code
  • mime_type
  • file_extension

GitRepositoryFilterSet

Missing fields

  • current_head
  • provided_contents
  • username
  • jobs (reverse related)
    • And has_jobs

Incorrect fields

  • tag -> tags

GraphQLQueryFilterSet

Missing fields

  • query
  • variables

ImageAttachmentFilterSet

Missing fields

  • parent
  • image_height
  • image_width
  • created

JobFilterSet

Missing fields

  • git_repository
  • description
  • results (reverse related)
    • And has_results
  • scheduled_jobs (reverse related)
    • And has_scheduled_jobs

Incorrect fields

  • tag -> tags

JobLogEntryFilterSet

Meta.exclude = [] should be exchanged for Meta.fields = "__all__"

JobResultFilterSet

Missing fields

  • data
  • schedule
  • job_id
  • logs (reverse related)
    • And has_logs

ObjectChangeFilterSet

Missing fields

  • related_object_type
  • related_object_id
  • realted_object
  • object_repr
  • object_data
  • object_data_v2

RelationshipFilterSet

Missing fields

  • slug
  • description
  • source_label
  • source_hidden
  • source_filter
  • destination_label
  • destination_hidden
  • destination_filter
  • advanced_ui
  • associations (reverse related)
    • And has_associations

RelationshipAssociationFilterSet

Missing fields

  • source
  • destination

Too many to list:

In [187]: RelationshipAssociation._meta.fields_map
Out[187]:
{'source_circuits_providernetwork': <GenericRel: circuits.providernetwork>,
 'destination_circuits_providernetwork': <GenericRel: circuits.providernetwork>,
 'source_circuits_provider': <GenericRel: circuits.provider>,
 'destination_circuits_provider': <GenericRel: circuits.provider>,
 'source_circuits_circuittype': <GenericRel: circuits.circuittype>,
 'destination_circuits_circuittype': <GenericRel: circuits.circuittype>,
 'source_circuits_circuit': <GenericRel: circuits.circuit>,
 'destination_circuits_circuit': <GenericRel: circuits.circuit>,
 'source_circuits_circuittermination': <GenericRel: circuits.circuittermination>,
 'destination_circuits_circuittermination': <GenericRel: circuits.circuittermination>,
 'source_dcim_consoleport': <GenericRel: dcim.consoleport>,
 'destination_dcim_consoleport': <GenericRel: dcim.consoleport>,
 'source_dcim_consoleserverport': <GenericRel: dcim.consoleserverport>,
 'destination_dcim_consoleserverport': <GenericRel: dcim.consoleserverport>,
 'source_dcim_powerport': <GenericRel: dcim.powerport>,
 'destination_dcim_powerport': <GenericRel: dcim.powerport>,
 'source_dcim_poweroutlet': <GenericRel: dcim.poweroutlet>,
 'destination_dcim_poweroutlet': <GenericRel: dcim.poweroutlet>,
 'source_dcim_interface': <GenericRel: dcim.interface>,
 'destination_dcim_interface': <GenericRel: dcim.interface>,
 'source_dcim_frontport': <GenericRel: dcim.frontport>,
 'destination_dcim_frontport': <GenericRel: dcim.frontport>,
 'source_dcim_rearport': <GenericRel: dcim.rearport>,
 'destination_dcim_rearport': <GenericRel: dcim.rearport>,
 'source_dcim_devicebay': <GenericRel: dcim.devicebay>,
 'destination_dcim_devicebay': <GenericRel: dcim.devicebay>,
 'source_dcim_inventoryitem': <GenericRel: dcim.inventoryitem>,
 'destination_dcim_inventoryitem': <GenericRel: dcim.inventoryitem>,
 'source_dcim_manufacturer': <GenericRel: dcim.manufacturer>,
 'destination_dcim_manufacturer': <GenericRel: dcim.manufacturer>,
 'source_dcim_devicetype': <GenericRel: dcim.devicetype>,
 'destination_dcim_devicetype': <GenericRel: dcim.devicetype>,
 'source_dcim_devicerole': <GenericRel: dcim.devicerole>,
 'destination_dcim_devicerole': <GenericRel: dcim.devicerole>,
 'source_dcim_platform': <GenericRel: dcim.platform>,
 'destination_dcim_platform': <GenericRel: dcim.platform>,
 'source_dcim_device': <GenericRel: dcim.device>,
 'destination_dcim_device': <GenericRel: dcim.device>,
 'source_dcim_virtualchassis': <GenericRel: dcim.virtualchassis>,
 'destination_dcim_virtualchassis': <GenericRel: dcim.virtualchassis>,
 'source_dcim_cable': <GenericRel: dcim.cable>,
 'destination_dcim_cable': <GenericRel: dcim.cable>,
 'source_dcim_consoleporttemplate': <GenericRel: dcim.consoleporttemplate>,
 'destination_dcim_consoleporttemplate': <GenericRel: dcim.consoleporttemplate>,
 'source_dcim_consoleserverporttemplate': <GenericRel: dcim.consoleserverporttemplate>,
 'destination_dcim_consoleserverporttemplate': <GenericRel: dcim.consoleserverporttemplate>,
 'source_dcim_powerporttemplate': <GenericRel: dcim.powerporttemplate>,
 'destination_dcim_powerporttemplate': <GenericRel: dcim.powerporttemplate>,
 'source_dcim_poweroutlettemplate': <GenericRel: dcim.poweroutlettemplate>,
 'destination_dcim_poweroutlettemplate': <GenericRel: dcim.poweroutlettemplate>,
 'source_dcim_interfacetemplate': <GenericRel: dcim.interfacetemplate>,
 'destination_dcim_interfacetemplate': <GenericRel: dcim.interfacetemplate>,
 'source_dcim_frontporttemplate': <GenericRel: dcim.frontporttemplate>,
 'destination_dcim_frontporttemplate': <GenericRel: dcim.frontporttemplate>,
 'source_dcim_rearporttemplate': <GenericRel: dcim.rearporttemplate>,
 'destination_dcim_rearporttemplate': <GenericRel: dcim.rearporttemplate>,
 'source_dcim_devicebaytemplate': <GenericRel: dcim.devicebaytemplate>,
 'destination_dcim_devicebaytemplate': <GenericRel: dcim.devicebaytemplate>,
 'source_dcim_powerpanel': <GenericRel: dcim.powerpanel>,
 'destination_dcim_powerpanel': <GenericRel: dcim.powerpanel>,
 'source_dcim_powerfeed': <GenericRel: dcim.powerfeed>,
 'destination_dcim_powerfeed': <GenericRel: dcim.powerfeed>,
 'source_dcim_rackgroup': <GenericRel: dcim.rackgroup>,
 'destination_dcim_rackgroup': <GenericRel: dcim.rackgroup>,
 'source_dcim_rackrole': <GenericRel: dcim.rackrole>,
 'destination_dcim_rackrole': <GenericRel: dcim.rackrole>,
 'source_dcim_rack': <GenericRel: dcim.rack>,
 'destination_dcim_rack': <GenericRel: dcim.rack>,
 'source_dcim_rackreservation': <GenericRel: dcim.rackreservation>,
 'destination_dcim_rackreservation': <GenericRel: dcim.rackreservation>,
 'source_dcim_region': <GenericRel: dcim.region>,
 'destination_dcim_region': <GenericRel: dcim.region>,
 'source_dcim_site': <GenericRel: dcim.site>,
 'destination_dcim_site': <GenericRel: dcim.site>,
 'source_ipam_vrf': <GenericRel: ipam.vrf>,
 'destination_ipam_vrf': <GenericRel: ipam.vrf>,
 'source_ipam_routetarget': <GenericRel: ipam.routetarget>,
 'destination_ipam_routetarget': <GenericRel: ipam.routetarget>,
 'source_ipam_rir': <GenericRel: ipam.rir>,
 'destination_ipam_rir': <GenericRel: ipam.rir>,
 'source_ipam_aggregate': <GenericRel: ipam.aggregate>,
 'destination_ipam_aggregate': <GenericRel: ipam.aggregate>,
 'source_ipam_role': <GenericRel: ipam.role>,
 'destination_ipam_role': <GenericRel: ipam.role>,
 'source_ipam_prefix': <GenericRel: ipam.prefix>,
 'destination_ipam_prefix': <GenericRel: ipam.prefix>,
 'source_ipam_ipaddress': <GenericRel: ipam.ipaddress>,
 'destination_ipam_ipaddress': <GenericRel: ipam.ipaddress>,
 'source_ipam_vlangroup': <GenericRel: ipam.vlangroup>,
 'destination_ipam_vlangroup': <GenericRel: ipam.vlangroup>,
 'source_ipam_vlan': <GenericRel: ipam.vlan>,
 'destination_ipam_vlan': <GenericRel: ipam.vlan>,
 'source_ipam_service': <GenericRel: ipam.service>,
 'destination_ipam_service': <GenericRel: ipam.service>,
 'source_extras_status': <GenericRel: extras.status>,
 'destination_extras_status': <GenericRel: extras.status>,
 'source_extras_tag': <GenericRel: extras.tag>,
 'destination_extras_tag': <GenericRel: extras.tag>,
 'source_extras_gitrepository': <GenericRel: extras.gitrepository>,
 'destination_extras_gitrepository': <GenericRel: extras.gitrepository>,
 'source_extras_dynamicgroup': <GenericRel: extras.dynamicgroup>,
 'destination_extras_dynamicgroup': <GenericRel: extras.dynamicgroup>,
 'source_extras_job': <GenericRel: extras.job>,
 'destination_extras_job': <GenericRel: extras.job>,
 'source_extras_configcontextschema': <GenericRel: extras.configcontextschema>,
 'destination_extras_configcontextschema': <GenericRel: extras.configcontextschema>,
 'source_extras_exporttemplate': <GenericRel: extras.exporttemplate>,
 'destination_extras_exporttemplate': <GenericRel: extras.exporttemplate>,
 'source_extras_secret': <GenericRel: extras.secret>,
 'destination_extras_secret': <GenericRel: extras.secret>,
 'source_extras_secretsgroup': <GenericRel: extras.secretsgroup>,
 'destination_extras_secretsgroup': <GenericRel: extras.secretsgroup>,
 'source_tenancy_tenantgroup': <GenericRel: tenancy.tenantgroup>,
 'destination_tenancy_tenantgroup': <GenericRel: tenancy.tenantgroup>,
 'source_tenancy_tenant': <GenericRel: tenancy.tenant>,
 'destination_tenancy_tenant': <GenericRel: tenancy.tenant>,
 'source_virtualization_clustertype': <GenericRel: virtualization.clustertype>,
 'destination_virtualization_clustertype': <GenericRel: virtualization.clustertype>,
 'source_virtualization_clustergroup': <GenericRel: virtualization.clustergroup>,
 'destination_virtualization_clustergroup': <GenericRel: virtualization.clustergroup>,
 'source_virtualization_cluster': <GenericRel: virtualization.cluster>,
 'destination_virtualization_cluster': <GenericRel: virtualization.cluster>,
 'source_virtualization_virtualmachine': <GenericRel: virtualization.virtualmachine>,
 'destination_virtualization_virtualmachine': <GenericRel: virtualization.virtualmachine>,
 'source_virtualization_vminterface': <GenericRel: virtualization.vminterface>,
 'destination_virtualization_vminterface': <GenericRel: virtualization.vminterface>}

ScheduledJobFilterSet

Missing fields

  • description
  • task
  • job_class
  • interval
  • args
  • kwargs
  • queue
  • one_off
  • start_time
  • enabled
  • total_run_count
  • user
  • approved_by_user
  • approval_required
  • approved_at
  • jobresult_set (reverse related)
    • Should be named job_results (from JobResult.schedule.related_name being set)
    • Also add has_job_results

Incorrect fields

  • last_run -> last_run_at

SecretsGroupAssociationFilterSet

It's actually perfect! Only change would be to set Meta.fields = "__all__".

SecretFilterSet

Missing fields

  • parameters
  • groups (reverse related)
    • And has_groups
  • secretsgroupassociation_set (reverse related)
    • Should be secrets_groups
    • And has_secrets_groups

SecretsGroupFilterSet

Missing fields

  • secrets (m2m)
  • device_set (reverse related)
    • Should be called devices
    • And has_devices
  • gitrepository_set (reverse related)
    • Should be called git_repositories
    • And has_git_repositories
  • secretsgroupassociation (reverse related)
    • Should be called secrets
    • And has_secrets

StatusFilterSet

Missing fields

  • description
  • circuits_circuit_related (reverse related)
    • And has_circuits_circuit_related
  • dcim_cable_related (reverse related)
    • And has_dcim_cable_related
  • dcim_device_related (reverse related)
    • And has_dcim_device_related
  • dcim_powerfeed_related (reverse related)
    • And has_dcim_powerfeed_related
  • dcim_rack_related (reverse related)
    • And has_dcim_rack_related
  • dcim_site_related (reverse related)
    • And has_dcim_site_related
  • ipam_ipaddress_related (reverse related)
    • And has_ipam_ipaddress_related
  • ipam_prefix_related (reverse related)
    • And has_ipam_prefix_related
  • ipam_vlan_related (reverse related)
    • And has_ipam_vlan_related
  • virtualization_virtualmachine_related (reverse related)
    • And has_virtualization_virtualmachine_related

TagFilterSet

Missing fields

  • description

See also (related_name needs to be added to whatever this is vs. foo_set):

In [201]: Tag._meta.fields_map
Out[201]:
{'providernetwork': <ManyToManyRel: circuits.providernetwork>,
 'provider': <ManyToManyRel: circuits.provider>,
 'circuit': <ManyToManyRel: circuits.circuit>,
 'circuittermination': <ManyToManyRel: circuits.circuittermination>,
 'consoleport': <ManyToManyRel: dcim.consoleport>,
 'consoleserverport': <ManyToManyRel: dcim.consoleserverport>,
 'powerport': <ManyToManyRel: dcim.powerport>,
 'poweroutlet': <ManyToManyRel: dcim.poweroutlet>,
 'interface': <ManyToManyRel: dcim.interface>,
 'frontport': <ManyToManyRel: dcim.frontport>,
 'rearport': <ManyToManyRel: dcim.rearport>,
 'devicebay': <ManyToManyRel: dcim.devicebay>,
 'inventoryitem': <ManyToManyRel: dcim.inventoryitem>,
 'devicetype': <ManyToManyRel: dcim.devicetype>,
 'device': <ManyToManyRel: dcim.device>,
 'virtualchassis': <ManyToManyRel: dcim.virtualchassis>,
 'cable': <ManyToManyRel: dcim.cable>,
 'powerpanel': <ManyToManyRel: dcim.powerpanel>,
 'powerfeed': <ManyToManyRel: dcim.powerfeed>,
 'rack': <ManyToManyRel: dcim.rack>,
 'rackreservation': <ManyToManyRel: dcim.rackreservation>,
 'site': <ManyToManyRel: dcim.site>,
 'vrf': <ManyToManyRel: ipam.vrf>,
 'routetarget': <ManyToManyRel: ipam.routetarget>,
 'aggregate': <ManyToManyRel: ipam.aggregate>,
 'prefix': <ManyToManyRel: ipam.prefix>,
 'ipaddress': <ManyToManyRel: ipam.ipaddress>,
 'vlan': <ManyToManyRel: ipam.vlan>,
 'service': <ManyToManyRel: ipam.service>,
 'Tag_content_types+': <ManyToOneRel: extras.tag_content_types>,
 'extras_taggeditem_items': <ManyToOneRel: extras.taggeditem>,
 'gitrepository': <ManyToManyRel: extras.gitrepository>,
 'job': <ManyToManyRel: extras.job>,
 'ConfigContext_tags+': <ManyToOneRel: extras.configcontext_tags>,
 '_extras_configcontext_tags_+': <ManyToManyRel: extras.configcontext>,
 'secret': <ManyToManyRel: extras.secret>,
 'tenant': <ManyToManyRel: tenancy.tenant>,
 'cluster': <ManyToManyRel: virtualization.cluster>,
 'virtualmachine': <ManyToManyRel: virtualization.virtualmachine>,
 'vminterface': <ManyToManyRel: virtualization.vminterface>}

WebhookFilterSet

Missing fields

  • http_method
  • http_content_type
  • additional_headers
  • body_template
  • secret
  • ssl_verification
  • ca_file_path

IPAM

AggregateFilterSet

Missing fields

  • network
  • broadcast
  • prefix_length
  • description

Incorrect fields

  • tag -> tags

IPAddressFilterSet

Missing fields

  • host
  • broadcast
  • prefix_length
  • assigned_object
  • nat_inside
  • nat_outside_list
    • Should also include has_nat_outside_list?
  • primary_ip4_for (on Device.name)
  • primary_ip6_for (on Device.name)
  • services (reverse related)
    • Should also include has_services

Incorrect fields

  • mask_length ( and __gte/__lte) should just be replaced with prefix_length and support multiple lookup expressions without resorting to method fiilters
    • Automatically generating lt,gt, etc for these is ideal which when NOT a method filter happens automatically (See: nautobot.utilities.constants.FILTER_NUMERIC_BASED_LOOKUP_MAP)
  • present_in_vrf_id should be has_vrf on the vrf__rd field
  • assigned_to_interface -> is_assigned_to_interface
  • interface related name should instead be called interfaces as it is a FK related manager
  • vminterface related name should instead be called vimnterfaces as it is a FK related manager
  • tag -> tags

PrefixFilterSet

Missing fields

  • network
  • broadcast
  • prefix_length
  • description

Incorrect fields

  • tag -> tags
  • present_in_vrf_id should be has_vrf on the vrf__rd field
  • vlan_vid should just be caleld vlan and search on the vid using to_field_name
  • mask_length ( and __gte/__lte) should just be replaced with prefix_length and support multiple lookup expressions without resorting to method fiilters
    • Automatically generating lt,gt, etc for these is ideal which when NOT a method filter happens automatically (See: nautobot.utilities.constants.FILTER_NUMERIC_BASED_LOOKUP_MAP)

RIRFilterSet

It's actually perfect! Only change would be to set Meta.fields = "__all__".

RoleFilterSet

Missing fields

  • description

  • weight

  • prefixes (reverse related)

    • Also add has_prefixes membership filter
  • vlans (reverse related)

    • Also add has_vlans membership filter

ServiceFilterSet

Missing fields

  • ipaddresses (m2m)

Incorrect fields

  • port -> ports
  • tag -> tags

RouteTargetFilterSet

Missing fields

  • description

Incorrect fields

  • exporting_vrf -> exporting_vrfs
  • importing_vrf -> importing_vrfs
  • tag -> tags

VLANFilterSet

Missing fields

  • description
  • interfaces_as_untagged
  • interfaces_as_tagged
  • vminterfaces_as_untagged
  • vminterfaces_as_tagged
  • prefixes (reverse related)
    • Also add has_prefixes membership filter

Incorrect fields

  • tag -> tags

VLANGroupFilterSet

Almost all fields accounted for!

Missing fields

  • vlans (reverse related)
    • Also add has_vlans membership filter

VRFFilterSet

Missing fields

  • description
  • prefixes (reverse related field)
    • Should also include has_prefixes membership filter
  • ip_addresses (reverse related field)
    • Should also include has_ip_addresses membership filter

Incorrect fields

  • tag -> tags
  • import_target -> import_targets
  • export_target -> export_targets

Tenancy

TenantGroupFilterSet

Missing fields

  • children (reverse related field)
    • Should also include has_children membership filter
  • tenants (reverse related field)
    • Should also include has_tenants membership filter

TenantFilterSet

Missing fields

  • description

  • comments

  • aggregates

    • And has_aggregates
  • circuits

    • And has_circuits
  • clusters

    • And has_clusters
  • devices

    • And has_devices
  • ip_addresses

    • And has_ip_addresses
  • prefixes

    • And has_prefixes
  • rackreservations

    • Should be called rack_reservations (this is a related_name problem)
    • And has_rack_reservations
  • racks

    • And has_racks
  • route_targets

    • And has_route_targets
  • sites

    • And has_sites
  • virtual_machines

    • And has_virtual_machines
  • vlans

    • And has_vlans
  • vrfs

    • And has_vrfs

Incorrect fields

  • tag -> tags

TenancyFilterSet

Should be renamed to TenancyFilterSetMixin because it is a mixin.

Users

UserFilterSet

Missing fields

  • config_data
  • changes (reverse related)
    • And has_changes
  • logentry_set (reverse related)
    • And has_logentry_set
  • object_permissions (reverse related)
    • And has_object_permissions
  • rackreservation_set (reverse related)
    • Should be called rack_reservations
    • And has_rack_reservations
  • social_auth (reverse related)
    • And has_social_auth
  • tokens (reverse related)
    • And has_tokens

ObjectPermissionFilterSet

Missing fields

  • description
  • constraints
  • actions

Incorrect fields

  • group -> groups
  • user -> users

TokenFilterSet

Missing fields

  • description

Virtualization

ClusterFilterSet

Missing fields

  • comments
  • devices (reverse related)
    • And has_devices
  • virtual_machines (reverse related)
    • And has_virtual_machines

Incorrect fields

  • tag -> tags

ClusterTypeFilterSet

Missing fields

  • clusters (reverse related)
    • And has_clusters

ClusterGroupFilterSet

Missing fields

  • clusters (reverse related)
    • And has_clusters

VirtualMachineFilterSet

Missing fields

  • comments
  • primary_ip4
  • primary_ip6
  • services (reverse related)
    • And has_services
  • interfaces (reverse related)
    • And has_interfaces

VMInterfaceFilterSet

Missing fields

  • description
  • untagged_vlan
  • tagged_vlans
  • ip_addresses
  • mode

Incorrect fields

  • tag -> tags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment