-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
NetBox version
v4.4.0
Feature type
New functionality
Proposed functionality
Currently, when creating or modifying a cable, NetBox does not record any data about its associated terminations in the changelog record for the cable itself. (Each termination gets its own changelog record.) We should be able to store the numeric IDs of each termination on the A and B sides of a cable in the changelog to complement the individual CableTermination records.
We can extend the save()
method on the Cable model to perform the following tasks:
- Call
super().save()
initially if the cable is being created. (This ensures that it exists in the database prior to creating any new CableTerminations.) - Create/delete any associated CableTermination records in the database as needed.
- Call
super().save()
to capture the updated cable terminations.
This will result in two changelog records when creating a new cable, but I don't expect that to be problematic (and may in fact be necessary to accurately reflect what happens in the database).
The resulting serialized post-change data would look like this:
{
label: "",
status: "connected",
a_terminations: [
223
],
b_terminations: [
224
],
...
}
Use case
Including a_terminations
and b_terminations
on the change record for a cable allows a user to determine immediately whether the terminations for a cable were changed, without needing to reference the associated change records for each termination. This would also enable us to address some issues with cabling in the netbox-branching
plugin (see netboxlabs/netbox-branching#150 for example).
Database changes
None anticipated
External dependencies
N/A