Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: custom netbox queries / add nautobot 2.X support #921

Open
gioccher opened this issue Feb 2, 2024 · 0 comments · May be fixed by #934
Open

[Feature]: custom netbox queries / add nautobot 2.X support #921

gioccher opened this issue Feb 2, 2024 · 0 comments · May be fixed by #934
Labels
enhancement New feature or request

Comments

@gioccher
Copy link

gioccher commented Feb 2, 2024

Suzieq version

0.22.0

Install Type

container

Feature type

Extend sq-poller

Use case

Import devices from netbox based on arbitrary filters, not just tags.
It also has the welcome side effect of adding support for Nautobot 2.X (the query syntax of netbox and nautobot 1.X is equivalent and so the current netbox source can be used for nautobot deployments, but it doesn't work for nautobot 2.X)

Proposed functionality/solution

The netbox source allows specifying one or more tags to pick the devices to include in the inventory.
The approach I'm proposing is to allow the SuzieQ user to specify the filters that will be sent to netbox.
Could be a list of tags, a list of sites, and/or a list of any other attributes...

This makes the Netbox source more flexible, and also makes it work for all the Nautobot versions

Example: this is a sample netbox source configuration

sources:
- name: nautobot
  token: env:NAUTOBOT_TOKEN
  url: env:NAUTOBOT_URL
  tag:
  - next_gen
  type: netbox
  period: 3600

and this is the equivalent config that uses the proposed filters mechanism

sources:
- name: nautobot
  token: env:NAUTOBOT_TOKEN
  url: env:NAUTOBOT_URL
  filters:
  - tag=next_gen
  type: netbox
  period: 3600

both produce an API request like this GET https://demo.nautobot.com/api/dcim/devices/?tag=next_gen

Another example that really shows the flexibility of this approach:

sources:
- name: nautobot
  token: env:NAUTOBOT_TOKEN
  url: env:NAUTOBOT_URL
  filters:
  - role=core
  - status=active
  - tags=next_gen
  - tags=whatever
  - depth=1
  type: netbox
  period: 3600

which produces an API call like GET https://demo.nautobot.com/api/dcim/devices/?role=core&status=active&tags=next_gen&tags=whatever&depth=1

It's up to the user to lookup the netbox/nautobot documentation and pick the parameters that make most sense for the use-case. https://demo.nautobot.com/api/docs/#/dcim/dcim_devices_list https://demo.netbox.dev/static/docs/rest-api/filtering/

External dependencies

No response

Additional Context

@gioccher gioccher added the enhancement New feature or request label Feb 2, 2024
@housepbass housepbass linked a pull request Apr 8, 2024 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant