Skip to content

Add a filter for device.primary_ip4 and primary_ip6 to the REST API / graphQL #11150

@michaelarnauts

Description

@michaelarnauts

NetBox version

v3.3.9

Feature type

Change to existing functionality

Proposed functionality

I would like to be able to fetch a device based on it's primary ipv4 (and probably also ipv6). I understand IP addresses aren't unique (you can them in multiple VRF's), but it should still be posible to get the device based on the ID of the IP Address.

Related to #10058

Mentioned here https://groups.google.com/g/netbox-discuss/c/Di5VMTtK5lg

Use case

I'm pushing devices to netbox trough a script with the API, and it happens that a device already exists with the same primary IP address. I want to handle these cases (probably by removing the old device).

When adding the device, I currently only get the error Device with this Primary IPv4 already exists, but there is no way to find this actual device.

I assign the IP address to an interface of the new device before I can configure the primary IP, but somehow while doing this, the IP address is still linked to an old device, causing that device to have a primary IP4 that isn't linked to any of its interfaces.

Once this happens, it's not possible anymore to find the actual device to remove it.

Database changes

No response

External dependencies

No response

Metadata

Metadata

Labels

status: acceptedThis issue has been accepted for implementationtype: featureIntroduction of new functionality to the application

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions