Skip to content

Closes #19840 - Enable Site Filtering for Devices in Cable Bulk Import #19923

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

Conversation

pheus
Copy link
Contributor

@pheus pheus commented Jul 21, 2025

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.

pheus added 2 commits July 21, 2025 21:46
Introduces `side_a_site` and `side_b_site` fields for the Cable bulk
import form. Limits device choices on both sides to the selected site
for improved input validation and consistency.
Refactors tests to create multiple sites and assign devices accordingly.
Updates CSV data to include `side_a_site` and `side_b_site` fields for
scenarios involving multiple sites. This improves test coverage and
alignment with real-world use cases.
@pheus pheus force-pushed the 19840-add-site-filter-for-cable-import-form branch from 170533d to b963cf3 Compare July 21, 2025 19:47
@jeremystretch jeremystretch requested review from a team and jnovinger and removed request for a team July 23, 2025 12:33
Copy link
Member

@jnovinger jnovinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pheus , overall, this looks great and acts as expected. I did have one question about changes to the test, if you could take a look.

Thanks!

@pheus
Copy link
Contributor Author

pheus commented Jul 23, 2025

@jnovinger Thank you very much. I responded on your comments. Let me know, how you like to proceed 🙂

Improved the inline comments to clarify the rationale behind allowing
devices with duplicate names on different sites during CSV bulk import.
@pheus pheus requested a review from jnovinger July 23, 2025 20:25
@jnovinger jnovinger merged commit 14c4aec into netbox-community:main Jul 23, 2025
3 checks passed
@pheus pheus deleted the 19840-add-site-filter-for-cable-import-form branch July 23, 2025 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Site information to CSV Import of cables
2 participants