-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Add a filter for device.primary_ip4 and primary_ip6 to the REST API / graphQL #11150
Comments
I've had to do this in my bulk import python code, when a device gets renamed from the source: fix_nb_device = [nb_device for nb_device in nb_devices if str(nb_device) == nb_address.assigned_object.device.name]
fix_nb_device[0].update({ 'primary_ip4': None })
nb_address.assigned_object_type = None
nb_address.assigned_object_id = None
nb_address.save() This presumes nb_devices contains all netbox device objects, and nb_address is the "Primary IPv4 already exists" netbox address object. However, I also do a cleanup of devices in netbox that do not exist any more in the source... (if done in the start, rather than at the end, then the above logic is not required) |
@jeremystretch i'm willing to take a look add adding this filter, doesn't seem that hard. |
@michaelarnauts - All yours :) |
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
The text was updated successfully, but these errors were encountered: