Allow VirtualMachine and Device filter by IP address from Primary IP #10996

Closed
opened 2025-12-29 21:38:58 +01:00 by adam · 1 comment
Owner

Originally created by @miaow2 on GitHub (Apr 8, 2025).

Originally assigned to: @miaow2 on GitHub.

NetBox version

v4.2.6

Feature type

New functionality

Proposed functionality

Add primary_ip4 and primary_ip6 filters to ipam.filtersets.PrimaryIPFilterSet

Use case

In our use cases we need to get virtual machine or device by their primary IP. Now we do this in two requests:

  1. find IP address id by api/ipam/ip-addresses/?address=1.1.1.1/32
  2. find device or VM by filtering api/dcim/devices/?primary_ip4_id=<ip_id>

I propose to add filtering by IP address directly, so users can do it only in one request: api/dcim/devices/?primary_ip4=1.1.1.1/32. This will decrease the number of requests and time to complete.

If the issue is accepted, I would be glad to submit a PR.

Database changes

None

External dependencies

None

Originally created by @miaow2 on GitHub (Apr 8, 2025). Originally assigned to: @miaow2 on GitHub. ### NetBox version v4.2.6 ### Feature type New functionality ### Proposed functionality Add `primary_ip4` and `primary_ip6` filters to `ipam.filtersets.PrimaryIPFilterSet` ### Use case In our use cases we need to get virtual machine or device by their primary IP. Now we do this in two requests: 1. find IP address id by `api/ipam/ip-addresses/?address=1.1.1.1/32` 2. find device or VM by filtering `api/dcim/devices/?primary_ip4_id=<ip_id>` I propose to add filtering by IP address directly, so users can do it only in one request: `api/dcim/devices/?primary_ip4=1.1.1.1/32`. This will decrease the number of requests and time to complete. If the issue is accepted, I would be glad to submit a PR. ### Database changes None ### External dependencies None
adam added the status: acceptedtype: featurecomplexity: low labels 2025-12-29 21:38:58 +01:00
adam closed this issue 2025-12-29 21:38:58 +01:00
Author
Owner

@bctiemann commented on GitHub (Apr 8, 2025):

This sounds like a good add. Thanks @miaow2 !

@bctiemann commented on GitHub (Apr 8, 2025): This sounds like a good add. Thanks @miaow2 !
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10996