[PR #19923] [MERGED] Closes #19840 - Enable Site Filtering for Devices in Cable Bulk Import #15760

Closed
opened 2025-12-30 00:23:53 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/19923
Author: @pheus
Created: 7/21/2025
Status: Merged
Merged: 7/23/2025
Merged by: @jnovinger

Base: mainHead: 19840-add-site-filter-for-cable-import-form


📝 Commits (3)

  • 8f7f258 feat(dcim): Add site fields to Cable bulk import form
  • b963cf3 feat(dcim): Enhance test data setup with multiple sites
  • 4da5816 docs(dcim): Update comments explaining indent for CSV import

📊 Changes

2 files changed (+58 additions, -13 deletions)

View changed files

📝 netbox/dcim/forms/bulk_import.py (+35 -2)
📝 netbox/dcim/tests/test_views.py (+23 -11)

📄 Description

Fixes: #19840 - Add Site information to CSV Import of cables

This PR addresses issue #19840 by introducing the ability to specify side_a_site and side_b_site when importing cables via CSV. This change enables importing cables between devices with duplicate names located in different sites.

Changes

  • Adds optional side_a_site and side_b_site fields to the Cable bulk import form.
  • Enhances device lookup logic during import to filter by the specified site when resolving device names.
  • Refactors and expands test cases:
    • Introduces test data with multiple sites and devices sharing the same name.
    • Verifies correct cable creation using site-scoped device resolution.
  • Updates test CSV files to demonstrate usage of the new fields.

Example CSV

side_a_site,side_a_device,side_a_type,side_a_name,side_b_site,side_b_device,side_b_type,side_b_name
DC1,Switch1,dcim.interface,Ethernet1/2,DC2,Switch1,dcim.interface,Ethernet1/2

This CSV will correctly match device1 in DC1 to device1 in DC2 and create a cable between their Ethernet1/2 interfaces.


🔄 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/19923 **Author:** [@pheus](https://github.com/pheus) **Created:** 7/21/2025 **Status:** ✅ Merged **Merged:** 7/23/2025 **Merged by:** [@jnovinger](https://github.com/jnovinger) **Base:** `main` ← **Head:** `19840-add-site-filter-for-cable-import-form` --- ### 📝 Commits (3) - [`8f7f258`](https://github.com/netbox-community/netbox/commit/8f7f258612f6a7e0fa8649fe58b156361cea0df0) feat(dcim): Add site fields to Cable bulk import form - [`b963cf3`](https://github.com/netbox-community/netbox/commit/b963cf3dcfe93ebcdb11bf6fe8beff745454a987) feat(dcim): Enhance test data setup with multiple sites - [`4da5816`](https://github.com/netbox-community/netbox/commit/4da58163852796c2f20d8e59e35c33d652c9de3f) docs(dcim): Update comments explaining indent for CSV import ### 📊 Changes **2 files changed** (+58 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `netbox/dcim/forms/bulk_import.py` (+35 -2) 📝 `netbox/dcim/tests/test_views.py` (+23 -11) </details> ### 📄 Description <!-- Thank you for your interest in contributing to NetBox! Please note that our contribution policy requires that a feature request or bug report be approved and assigned prior to opening a pull request. This helps avoid waste time and effort on a proposed change that we might not be able to accept. IF YOUR PULL REQUEST DOES NOT REFERENCE AN ISSUE WHICH HAS BEEN ASSIGNED TO YOU, IT WILL BE CLOSED AUTOMATICALLY. Please specify your assigned issue number on the line below. --> ### Fixes: #19840 - Add Site information to CSV Import of cables This PR addresses issue [#19840](https://github.com/netbox-community/netbox/issues/19840) by introducing the ability to specify `side_a_site` and `side_b_site` when importing cables via CSV. This change enables importing cables between devices with duplicate names located in different sites. #### Changes - Adds optional `side_a_site` and `side_b_site` fields to the Cable bulk import form. - Enhances device lookup logic during import to filter by the specified site when resolving device names. - Refactors and expands test cases: - Introduces test data with multiple sites and devices sharing the same name. - Verifies correct cable creation using site-scoped device resolution. - Updates test CSV files to demonstrate usage of the new fields. #### Example CSV ```csv side_a_site,side_a_device,side_a_type,side_a_name,side_b_site,side_b_device,side_b_type,side_b_name DC1,Switch1,dcim.interface,Ethernet1/2,DC2,Switch1,dcim.interface,Ethernet1/2 ``` This CSV will correctly match `device1` in *DC1* to `device1` in *DC2* and create a cable between their `Ethernet1/2` interfaces. --- <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-30 00:23:53 +01:00
adam closed this issue 2025-12-30 00:23:53 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15760