netbox-community / netbox

The premier source of truth powering network automation. Open source under Apache 2. Try NetBox Cloud free: https://netboxlabs.com/free-netbox-cloud/
http://netboxlabs.com/oss/netbox/
Apache License 2.0
15.93k stars 2.56k forks source link

Enable Device Uniqueness by Device Role #3974

Closed darcynz closed 4 years ago

darcynz commented 4 years ago

Environment

Proposed Functionality

Enable a toggle per device role that allows a device (physical/vm) to be checked for uniqueness upon creation of a new item.

Use Case

As per the implementation of #2669 in 2.71, device names were made non unique.

This enables generic device types (patch panels, cables), however it allows the possibility of introducing a conflict in the database for a unique device (eg logical router).

Whilst this can be addressed re-actively by validation (reports) for users that use Netbox as their network source of truth this problem can be magnified by automation that is in place and increase the difficulty of cross system API calls that use the Device name as an identifier.

Database Changes

None

External Dependencies

None

jeremystretch commented 4 years ago

however it allows the possibility of introducing a conflict in the database for a unique device (eg logical router).

This is not a conflict, but a violation of your particular organization's naming/provisioning policy. If you need to restrict certain device roles to have no more than n instances, it will need to be done using a custom script or other custom mechanism. NetBox does not support conditional uniqueness enforcement for any models and we have no plans to introduce it at this time.