netbox-community / netbox

The premier source of truth powering network automation. Open source under Apache 2. Public demo: https://demo.netbox.dev
http://netboxlabs.com/oss/netbox/
Apache License 2.0
15.67k stars 2.53k forks source link

Delete IPs by Address #4223

Closed CSimpiFoN closed 4 years ago

CSimpiFoN commented 4 years ago

Environment

Proposed Functionality

It would be great if IPs could be deleted by their address, not just by their ID.

Use Case

It would be easier to implement in automation solutions, like Terraform, as for example, it has the IP of the machine, so a local provisioner could delete the IP from NetBox on destroying, without any additional help to look up the ID of the address.

Database Changes

N/A

External Dependencies

N/A

hSaria commented 4 years ago

Personal opinion: the ID of the object grants an unequivocal reference to it, irrespective of the data it holds and even after being modified. This ensures consistency between all models, no matter the fields they have.

Along the same vein, one can make an argument that we should be able to delete a device by its asset tag. You see how this can start to get out of hand in terms of consistency and manageability.

In addition, you can create multiples addresses with the same IP in NetBox, so deleting by IP address would fall apart when it comes to those.

I'm no Terraform expert, though I would expect that a provider for NetBox would definitely reference an object's identifier for a particular resource type, much like Amazon's aws_instance resource type.

DanSheps commented 4 years ago

As @hSaria pointed out, due to the model chosen (primarily, allowing duplicate IPs) we cannot support deletion by IP.