Skip to content

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

@jeremystretch

Description

@jeremystretch

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

Metadata

Metadata

Assignees

Labels

complexity: mediumRequires a substantial but not unusual amount of effort to implementstatus: acceptedThis issue has been accepted for implementationtype: featureIntroduction of new functionality to the application

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions