[PR #6111] [CLOSED] Fix 5952 #13098

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

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/6111
Author: @hellerve
Created: 4/8/2021
Status: Closed

Base: developHead: fix-5952


📝 Commits (4)

📊 Changes

5 files changed (+112 additions, -26 deletions)

View changed files

📝 netbox/dcim/constants.py (+11 -0)
📝 netbox/dcim/forms.py (+64 -18)
📝 netbox/dcim/models/cables.py (+9 -4)
📝 netbox/dcim/tests/test_views.py (+4 -4)
📝 netbox/utilities/forms/fields.py (+24 -0)

📄 Description

Fixes: #5952

This PR unifies the import and export CSV formats for cables. As of now it is a mix of both. The new headers are:

side_a_parent_type
side_a_parent_id
side_b_parent_type
side_b_parent_id

They replace the headers side_a_device and side_b_device. An ID instead of a name was chosen for two reasons:

  • Circuits do not have names, just IDs.
  • Device names are not necessarily unique across sites.

The value for side_a_name and side_b_name also underwent a semantic change: if the component type does not have a name (such as for circuit terminations), the value of side_<side>_name will be assumed to be a PK instead. This is also exported like this.

I tried testing this with a good amount of cables (I dumped about ~1500 cables and reimported them), but I cannot guarantee that this code was tested with all possible combinations of types and values.

I’d be happy to rework this a bit if the approach used is not quite as intended.

Cheers


🔄 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/6111 **Author:** [@hellerve](https://github.com/hellerve) **Created:** 4/8/2021 **Status:** ❌ Closed **Base:** `develop` ← **Head:** `fix-5952` --- ### 📝 Commits (4) - [`859bda0`](https://github.com/netbox-community/netbox/commit/859bda079e6fff28018ceace14e5319d3bb1846f) initial work on #5952 - [`0e8fb13`](https://github.com/netbox-community/netbox/commit/0e8fb136c36d66998dc67e24667d316dcac72c3a) fix csv test data for cables for new format - [`3c13f81`](https://github.com/netbox-community/netbox/commit/3c13f81c83a1d7a6f8132f09a9b21a9f73d9603c) make model choice fields work inside csv cable import - [`698e5d9`](https://github.com/netbox-community/netbox/commit/698e5d99eeb07c6815c111b74044bf7fa8576248) pep8-ify comments ### 📊 Changes **5 files changed** (+112 additions, -26 deletions) <details> <summary>View changed files</summary> 📝 `netbox/dcim/constants.py` (+11 -0) 📝 `netbox/dcim/forms.py` (+64 -18) 📝 `netbox/dcim/models/cables.py` (+9 -4) 📝 `netbox/dcim/tests/test_views.py` (+4 -4) 📝 `netbox/utilities/forms/fields.py` (+24 -0) </details> ### 📄 Description ### Fixes: #5952 This PR unifies the import and export CSV formats for cables. As of now it is a mix of both. The new headers are: ``` side_a_parent_type side_a_parent_id side_b_parent_type side_b_parent_id ``` They replace the headers `side_a_device` and `side_b_device`. An ID instead of a name was chosen for two reasons: - Circuits do not have names, just IDs. - Device names are not necessarily unique across sites. The value for `side_a_name` and `side_b_name` also underwent a semantic change: if the component type does not have a name (such as for circuit terminations), the value of `side_<side>_name` will be assumed to be a PK instead. This is also exported like this. I tried testing this with a good amount of cables (I dumped about ~1500 cables and reimported them), but I cannot guarantee that this code was tested with all possible combinations of types and values. I’d be happy to rework this a bit if the approach used is not quite as intended. Cheers --- <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:25:24 +01:00
adam closed this issue 2025-12-29 22:25:24 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#13098