Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editing an unterminated cable throws exception #11460

Closed
dutchman80 opened this issue Jan 11, 2023 · 8 comments · Fixed by #15813
Closed

Editing an unterminated cable throws exception #11460

dutchman80 opened this issue Jan 11, 2023 · 8 comments · Fixed by #15813
Assignees
Labels
severity: medium Results in substantial degraded or broken functionality for specfic workflows status: accepted This issue has been accepted for implementation topic: cabling type: bug A confirmed report of unexpected behavior in the application

Comments

@dutchman80
Copy link

dutchman80 commented Jan 11, 2023

NetBox version

v3.4.0

Python version

3.9

Steps to Reproduce

  1. Create Device-A with Interface
  2. Create Device-B with Interface
  3. Connect Device-A to Device-B via their interfaces. Cable-1 is automatically created
  4. Delete Device-A
  5. Navigate to view for Cable-1 and hit the "Edit" button

Expected Behavior

The "Edit" view for the cable is displayed

Observed Behavior

<class 'AttributeError'>

'str' object has no attribute 'label'

@dutchman80 dutchman80 added the type: bug A confirmed report of unexpected behavior in the application label Jan 11, 2023
@jeremystretch jeremystretch added topic: cabling status: accepted This issue has been accepted for implementation labels Jan 11, 2023
@jeremystretch jeremystretch self-assigned this Jan 11, 2023
@jeremystretch
Copy link
Member

The error occurs during form rendering because we're unable to determine the type of the A side connection when no A side terminations exist. I'm not sure there's any particularly clever solution to this, however it may be rendered moot depending on what changes (if any) we decide to make with respect to #10769. I'm going to mark this as blocked for now pending the outcome of that issue.

@jeremystretch jeremystretch added status: blocked Another issue or external requirement is preventing implementation and removed status: accepted This issue has been accepted for implementation labels Jan 11, 2023
@DanSheps
Copy link
Member

So, I keep hitting this, and I am wondering if it wouldn't be worth it to turn every "interface" into a polymorphic object (yes, I am bringing up polymorphism again. :D)

The advantage, is we could likely do-away with multiple forms for connecting interfaces, front/rear ports, etc and just point to a "Connection Point" base class, which would hold the PK for whatever it morphs into (FrontPort). This would allow us to simplifiy the cable create form by consolidating the form creation logic into a single DynamicModelChoiceField.

We then wouldn't need to "determine" what type of connection we are making, we just need to allow you to connect to perhaps a base connection type (power only to power). Just a thought.

The only problem is it looks like django-polymorphic is abandoned right now.

@jeremystretch
Copy link
Member

Just noting that this remains an active bug and has not been resolved by #13337.

@DanSheps
Copy link
Member

I can take a look at this tomorrow or during the week if no one gets to it.

I think it has to do with the way the dynamic forms are created but not 100% sure. It is something I have been meaning to dive into.

@AravindhStanley
Copy link

AravindhStanley commented Oct 26, 2023

Can we atleast make the terminations on both sides as mandatory input fields? I have few users that update one side of the cable and not the other. Maybe it can atleast help with such scenarios?

@jeremystretch jeremystretch removed their assignment Dec 15, 2023
@jeremystretch jeremystretch added status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation and removed status: blocked Another issue or external requirement is preventing implementation labels Dec 15, 2023
@DanSheps DanSheps added status: accepted This issue has been accepted for implementation and removed status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation labels Feb 15, 2024
@DanSheps DanSheps self-assigned this Feb 15, 2024
@DanSheps
Copy link
Member

DanSheps commented Feb 15, 2024

I might play around with the cable termination form (and by extension HTMX) to see if I can get this working to an acceptable level.

I believe that might be the only way forward for this one, as it is hard to determine the type of cable when it doesn't exist at all.
😄

@jschewebbn
Copy link
Contributor

I will say that I like the idea of some of polymorphism or inheritance that allows one to reference anything that can be a cable termination without needing to know the specific type of termination. It would be nice if one could just ask an object "what are the things you have that can be a cable termination" instead of needing to specify which specific type of cable termination, at least as long as it's a network termination.

@Th3Bard
Copy link

Th3Bard commented Mar 6, 2024

Running in to this issue. Swapping out line cards while using the same fibers...

I currently have to:

  1. create a temp module bay
  2. create new module
  3. update all cable terminations to the new module
  4. delete old module
  5. slot new module in the correct module bay
  6. update interface names (as the interfaces adopted the temp module bay in their naming convention)
  7. delete temp module bay

This is very unfortunate right now as I work for an ISP that is upgrading GPON line cards to XGS capable cards (hundreds of them). Each line card has 8 fibers that get pulled from old card and terminated into the new card.

jeremystretch added a commit that referenced this issue May 1, 2024
…15813)

* Fix cable edit form with single unterminated cable

* Minor tweaks

* Instead of skipping HTMX, override the template & move form template to an "htmx" template

* Use HTMXSelect widget for A/B type selection

* Infer A/B termination types from POST data

* Fix saving cable which results in resetting of the termination type fields

* Condense view logic

---------

Co-authored-by: Jeremy Stretch <[email protected]>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
severity: medium Results in substantial degraded or broken functionality for specfic workflows status: accepted This issue has been accepted for implementation topic: cabling type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants