[PR #4706] [MERGED] 4708: more flexible checks on RearPort usage #12904

Closed
opened 2025-12-29 22:24:17 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/4706
Author: @steffann
Created: 6/2/2020
Status: Merged
Merged: 7/1/2020
Merged by: @jeremystretch

Base: developHead: 4604_check_position_stack


📝 Commits (10+)

  • a0f4d48 make single front/rear port work when between panels
  • 112dfb8 Integrate patch panel building into one list
  • 3278cc8 Recreate the model instance instead of re-saving a deleted model
  • 56898f7 Restore original test_connection_via_single_rear_port test and make separate test for one-on-one panels
  • 1d33d7d Call full_clean() when saving Cable instances
  • 6fc7c6a Update path validation tests for single-position rear port scenarios
  • 2fe4656 Permit connection of a multi-position RearPort to a FrontPort
  • 2479b8a Validate against is_path_endpoint instead of specific classes, and only when positions > 1
  • 81a322e Add position_stack to returned values from trace()
  • 34ae57d Show warning when position stack is not empty after trace

📊 Changes

6 files changed (+313 additions, -55 deletions)

View changed files

📝 netbox/dcim/models/__init__.py (+8 -5)
📝 netbox/dcim/models/device_components.py (+33 -26)
📝 netbox/dcim/signals.py (+6 -4)
📝 netbox/dcim/tests/test_models.py (+254 -19)
📝 netbox/dcim/views.py (+2 -1)
📝 netbox/templates/dcim/cable_trace.html (+10 -0)

📄 Description

Fixes: #4708

Alternative solution to #4708 that allows users to use RearPort in more complex ways without causing an IntegrityError with connected endpoints.

This implementation changes trace() to return the position_stack to the caller, which allows the caller to determine whether the returned path is end-to-end (nothing left on the stack) or whether it went through a FrontPort->RearPort without going through the corresponding RearPort->FrontPort (stack is not empty).

Adapted the update_connected_endpoints signal handler to consider an endpoint unconnected when the stack is not empty. This prevents the IntegrityError from occurring as connected endpoints are now only established for one-to-one paths.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/4706 **Author:** [@steffann](https://github.com/steffann) **Created:** 6/2/2020 **Status:** ✅ Merged **Merged:** 7/1/2020 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `develop` ← **Head:** `4604_check_position_stack` --- ### 📝 Commits (10+) - [`a0f4d48`](https://github.com/netbox-community/netbox/commit/a0f4d481dce4ef7bb69f63e271e46cd6504f462c) make single front/rear port work when between panels - [`112dfb8`](https://github.com/netbox-community/netbox/commit/112dfb865bd748af3dc5d6a9a4e8742d1f9dfb76) Integrate patch panel building into one list - [`3278cc8`](https://github.com/netbox-community/netbox/commit/3278cc8cc0e26a26fa7b62f160327fdb62a73634) Recreate the model instance instead of re-saving a deleted model - [`56898f7`](https://github.com/netbox-community/netbox/commit/56898f7e3797b20f6c9a2c92972b377abc2abe6b) Restore original test_connection_via_single_rear_port test and make separate test for one-on-one panels - [`1d33d7d`](https://github.com/netbox-community/netbox/commit/1d33d7d2059b4e9216fd4e56aaa2789836469166) Call full_clean() when saving Cable instances - [`6fc7c6a`](https://github.com/netbox-community/netbox/commit/6fc7c6a7d0915756ca7fe5cbedc5a39aff65053e) Update path validation tests for single-position rear port scenarios - [`2fe4656`](https://github.com/netbox-community/netbox/commit/2fe4656db49d4c08d222351d4a91cd38082254e1) Permit connection of a multi-position RearPort to a FrontPort - [`2479b8a`](https://github.com/netbox-community/netbox/commit/2479b8a57f645571747fb17282c7dd3c48d9a23e) Validate against is_path_endpoint instead of specific classes, and only when positions > 1 - [`81a322e`](https://github.com/netbox-community/netbox/commit/81a322eaaf796025458b8f84e4655921974a91ab) Add position_stack to returned values from trace() - [`34ae57d`](https://github.com/netbox-community/netbox/commit/34ae57dfa361ad7b1e63a28de3b18ad444dce35c) Show warning when position stack is not empty after trace ### 📊 Changes **6 files changed** (+313 additions, -55 deletions) <details> <summary>View changed files</summary> 📝 `netbox/dcim/models/__init__.py` (+8 -5) 📝 `netbox/dcim/models/device_components.py` (+33 -26) 📝 `netbox/dcim/signals.py` (+6 -4) 📝 `netbox/dcim/tests/test_models.py` (+254 -19) 📝 `netbox/dcim/views.py` (+2 -1) 📝 `netbox/templates/dcim/cable_trace.html` (+10 -0) </details> ### 📄 Description ### Fixes: #4708 Alternative solution to #4708 that allows users to use RearPort in more complex ways without causing an IntegrityError with connected endpoints. This implementation changes `trace()` to return the `position_stack` to the caller, which allows the caller to determine whether the returned path is end-to-end (nothing left on the stack) or whether it went through a FrontPort->RearPort without going through the corresponding RearPort->FrontPort (stack is not empty). Adapted the `update_connected_endpoints` signal handler to consider an endpoint unconnected when the stack is not empty. This prevents the IntegrityError from occurring as connected endpoints are now only established for one-to-one paths. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 22:24:17 +01:00
adam closed this issue 2025-12-29 22:24:17 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#12904