Record A & B terminations on changelog record for cable #11564

Closed
opened 2025-12-29 21:46:50 +01:00 by adam · 0 comments
Owner

Originally created by @jeremystretch on GitHub (Sep 3, 2025).

Originally assigned to: @jeremystretch on GitHub.

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:

  1. Call super().save() initially if the cable is being created. (This ensures that it exists in the database prior to creating any new CableTerminations.)
  2. Create/delete any associated CableTermination records in the database as needed.
  3. 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

Originally created by @jeremystretch on GitHub (Sep 3, 2025). Originally assigned to: @jeremystretch on GitHub. ### 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: 1. Call `super().save()` initially if the cable is being created. (This ensures that it exists in the database prior to creating any new CableTerminations.) 2. Create/delete any associated CableTermination records in the database as needed. 3. 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
adam added the status: acceptedtype: featurecomplexity: medium labels 2025-12-29 21:46:50 +01:00
adam closed this issue 2025-12-29 21:46:50 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11564