Skip to content

inventory plugin: support netbox endpoints running in a non-root context path (subpath) #1407

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

Merged
merged 1 commit into from
May 11, 2025

Conversation

lanefu
Copy link
Contributor

@lanefu lanefu commented Apr 13, 2025

Related Issue

#1408

New Behavior

Updated Plugin to parse the full path of the netbox server and compose API endpoints accordingly.
...

allow inventory to support netbox endpoints on host.example.com/netboxpath/

This is a patch I originally made for v3.13 which had updated parsing of the openapi endpoint and assumes that netbox is always running in the root context rather than a path. This performs the additional url parsing to derive the correct inventory API endpoints if netbox is running on a path rather than a root context.

I've tested this rebased patch on latest netbox running on in the root context path, as well as my legacy deployment running on host.com/netbox/
...

Discussion: Benefits and Drawbacks

  • allows users to run in additional supported configurations ex: somehost.example.com/netbox/ rather than only netbox.example.com

...

Changes to the Documentation

...

Proposed Release Note Entry

update inventory plugin to support netbox API running on non-root context paths.
...

Double Check

  • I have read the comments and followed the CONTRIBUTING.md.
  • I have explained my PR according to the information in the comments or in a linked issue.
  • My PR targets the devel branch.

@lanefu lanefu force-pushed the latest-with-inventory-fix branch 2 times, most recently from bb892df to c669722 Compare April 13, 2025 02:54
@lanefu lanefu changed the title add base_url to api endpoint to allow non-root context nextbox endpoints inventory plugin: support netbox endpoints running in a non-root context path Apr 13, 2025
@lanefu lanefu force-pushed the latest-with-inventory-fix branch from 44eae29 to 574f6cc Compare April 13, 2025 12:54
@lanefu
Copy link
Contributor Author

lanefu commented Apr 13, 2025

Also related to #1195

@lanefu
Copy link
Contributor Author

lanefu commented Apr 13, 2025

For some additional background in response to #1195

When I originally implemented this fix a year ago, I had already been using netbox inventory and ipam modules for quite a while (using a subpath) The inventory plugin broke when some changes were made in response to querying OpenAPI.

However, from what I recall, it only broke the inventory plugin... The other modules relying on the netbox_util module already had better api path parsing and it just worked. My solution was inspired from what was in netbox_util

response = open_url(base_url + "/docs/?format=openapi")

@lanefu lanefu changed the title inventory plugin: support netbox endpoints running in a non-root context path inventory plugin: support netbox endpoints running in a non-root context path (subpath) Apr 13, 2025
@sc68cal
Copy link
Contributor

sc68cal commented Apr 15, 2025

The integration test failure against 4.2 is unrelated to this change (it's an issue with how NetBox reports its versions in that branch, it's a regression), and the doc build failure is unrelated to this change as well. I think this is good to go.

@leitwerk-ag
Copy link

Oh, I'd love to see this one merged 😍

@sc68cal
Copy link
Contributor

sc68cal commented May 10, 2025

@rodvand I'm planning on merging this regardless of the CI failure, which is unrelated to this change. Thoughts?

@sc68cal sc68cal merged commit 11e4dd2 into netbox-community:devel May 11, 2025
57 of 59 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants