Skip to content

Device primary_ip not being removed when removing address from interface #3458

@juan-vg

Description

@juan-vg

Environment

  • Python version: 3.5.3
  • NetBox version: 2.6.2

Steps to Reproduce

  1. Add an interface (let's call it 'I1') to a device ('D1'), and then add an IP address ('A1') to that interface 'I1'
  2. Set the tuple (Interface-I1, IP-A1) as the primary_ip for the device 'D1'
  3. Assign that IP address to a new interface ('I2') owned by a different device ('D2')
  4. 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 &quot;dcim_device_primary_ip4_id_key&quot;
DETAIL:  Key (primary_ip4_id)=(<IP-A1_id>) already exists.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: acceptedThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the application

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions