netenglabs / suzieq

Using network observability to operate and design healthier networks
https://www.stardustsystems.net/
Apache License 2.0
780 stars 104 forks source link

draft: draft device_query_filters approach #862

Closed ryanmerolle closed 1 month ago

ryanmerolle commented 1 year ago

Set develop as target branch of this PR (delete this line before issuing the PR)

Test inclusion requirements

Test will be included after I get some feedback on the initial approach. IE should I make breaking changes and remove tag/tags?

Related Issue

Fixes #641

Description

Introduces the device_query_filters option when using a netbox inventory source. Its what we do in the NetBox Ansible modules.

Type of change

Please delete options that are not relevant.

New Behavior

device_query_filters allows you to set more advanced api filter

...

Contrast to Current Behavior

Current method only allows for filtering by tags.

...

Discussion: Benefits and Drawbacks

The main benefit is that its more consistent with other tooling like the ansible collection, and you can filter devices beyond just by tags.

The main drawback is the confusion given tags can be passed like:

- name: netbox-multi-tag
  type: netbox
  token: your-api-token-here
  url: https://127.0.0.1:8000
  device_query_filters:
    - manufacturer_id: 1
    - tag: suzieq

or like

- name: netbox-multi-tag
  type: netbox
  token: your-api-token-here
  url: https://127.0.0.1:8000
  tags:
    - suzieq
  device_query_filters:
    - manufacturer_id: 1

I would argue this warrants a breaking change to remove tag/tags all together.

Changes to the Documentation

Documentation will be more detailed after I get some feedback on the initial approach. IE should I make breaking changes and remove tag/tags? I already started in my first draft commit

Proposed Release Note Entry

Introduces the device_query_filters option when using a netbox inventory source(similar to Ansible Netbox's nb_inventory) to allow for more advanced device api filters.

Comments

More of a draft PR where I need feedback from the team.

Double Check