Device primary_ip not being removed when removing address from interface
See original GitHub issueEnvironment
- Python version: 3.5.3
- NetBox version: 2.6.2
Steps to Reproduce
- Add an interface (let’s call it ‘I1’) to a device (‘D1’), and then add an IP address (‘A1’) to that interface ‘I1’
- Set the tuple (Interface-I1, IP-A1) as the primary_ip for the device ‘D1’
- Assign that IP address to a new interface (‘I2’) owned by a different device (‘D2’)
- Try to set that new tuple (Interface-I2, IP-A1) as the primary IP for the device ‘D2’
Expected Behavior
As far as I can reassign the IP address to a new interface (which is completely logical), I should be able to set it as primary_ip on the new device.
Observed Behavior
Response from the UI (device edit): Device with this Primary IPv4 already exists. Response from the API (PATCH /api/dcim/devices/<device-D2_id>/):
HTTP 500:
duplicate key value violates unique constraint "dcim_device_primary_ip4_id_key"
DETAIL: Key (primary_ip4_id)=(<IP-A1_id>) already exists.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Removing a primary IP address from a network interface
Ensure that you remove all the manually configured alias addresses for the interface. Step. To remove a primary IP address, enter the following...
Read more >REmoving Ip address from FE interface - Cisco Community
The right way to do is to remove the secondary u want to change, using no form of the command, with a secondary...
Read more >Why does removing an unused IP address from an interface ...
This changes the behaviour such that when a primary IP is removed, it will not flush the remaining addresses and instead will promote...
Read more >Cannot remove the IP address because it is the primary IP ...
Plesk IP address cannot be removed: Error: Cannot remove the IP address 203.0.113.2 because it is the primary IP address of a network...
Read more >I want to change the primary IP on my nic but the console is ...
How can I swap primary for secondary nic on the interface? ... So deleting the only private IP address associated with your primary...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
To be clear, it is intended behavior to not let an IP be moved from device A to device B while being assigned as the primary IP for device A. The parent device/VM needs to be modified to remove the assignment as primary IP before the IP can be reassigned. However, there is currently no validation in place to prevent this (via the API), so I’m calling it a bug.
Are you telling me that this behaviour only happens when using the API? Is the UI the one triggering the release? 😦