[PR #12512] [MERGED] Closes #11670: Add ability to optionally import DeviceType and ModuleType weight #14005

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

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/12512
Author: @dhenschen
Created: 5/7/2023
Status: Merged
Merged: 5/9/2023
Merged by: @jeremystretch

Base: developHead: 11670-import-device-module-weight


📝 Commits (3)

  • 09b6b1c 11670: Add optional weight to DeviceType import
  • c776482 Closes #11670: Add weight to ModuleType import
  • 2321287 Merge tests; misc cleanup

📊 Changes

3 files changed (+45 additions, -5 deletions)

View changed files

📝 netbox/dcim/forms/bulk_import.py (+20 -2)
📝 netbox/dcim/models/devices.py (+4 -0)
📝 netbox/dcim/tests/test_views.py (+21 -3)

📄 Description

Fixes: #11670

Summary

This Pull Request adds the ability to import weight data via CSV, YAML, or JSON for Module Types and Device Types. Additionally, this PR adds the weight and weight_unit fields to the YAML export of Device Types and Module Types.

Background

Prior to this PR, the ModuleType and DeviceType modules already contained weight and weight unit fields. However, there was no ability to import this data. This PR adds the necessary functionality.

Changes

To maintain consistency, the import design of the DeviceType weight follows the same pattern used for importing weight and weight units in DCIM Racks.

The PR description includes examples of YAML imports for Racks, Device Types, and Module Types, as well as YAML exports for Device Types and Module Types. These examples illustrate demonstrate how these new import and export changes look.

Benefits

This feature improves the usability of NetBox by allowing users to import weight data for Module Types and Device Types, as requested in #11670. It also makes it easier to manage and maintain this data, as it can be imported/exported along with other relevant information.

Examples

Rack Import Example (YAML)

This is a YAML example of importing a Rack in NetBox. The below YAML worked in NetBox prior to this Pull Request.

site: DM-Albany
name: blahabc
status: active
width: 19
u_height: 42
weight: 10
weight_unit: kg

Device Type Import Example (YAML)

This is a YAML example of importing a Device Type in NetBox.

manufacturer: Juniper
model: Switch
slug: switch
u_height: 1
weight: 10
weight_unit: kg

Module Type Import Example (YAML)

This is a YAML example of importing a Module Type in NetBox.

manufacturer: Juniper
model: TEST-1001
weight: 10
weight_unit: lb

YAML Export

Attached below are example exports with the new weight and weight_unit fields included:


🔄 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/12512 **Author:** [@dhenschen](https://github.com/dhenschen) **Created:** 5/7/2023 **Status:** ✅ Merged **Merged:** 5/9/2023 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `develop` ← **Head:** `11670-import-device-module-weight` --- ### 📝 Commits (3) - [`09b6b1c`](https://github.com/netbox-community/netbox/commit/09b6b1c39a80e65250cf332b07709f36cbad5e0d) 11670: Add optional weight to DeviceType import - [`c776482`](https://github.com/netbox-community/netbox/commit/c776482228652f20d55563a7cd9286408b0a657b) Closes #11670: Add weight to ModuleType import - [`2321287`](https://github.com/netbox-community/netbox/commit/23212875dfa17864f10e58dfb8eceb3686875033) Merge tests; misc cleanup ### 📊 Changes **3 files changed** (+45 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `netbox/dcim/forms/bulk_import.py` (+20 -2) 📝 `netbox/dcim/models/devices.py` (+4 -0) 📝 `netbox/dcim/tests/test_views.py` (+21 -3) </details> ### 📄 Description ### Fixes: #11670 ### Summary This Pull Request adds the ability to import weight data via CSV, YAML, or JSON for Module Types and Device Types. Additionally, this PR adds the `weight` and `weight_unit` fields to the YAML export of Device Types and Module Types. ### Background Prior to this PR, the ModuleType and DeviceType modules already contained weight and weight unit fields. However, there was no ability to import this data. This PR adds the necessary functionality. ### Changes To maintain consistency, the import design of the DeviceType weight follows the same pattern used for importing weight and weight units in DCIM Racks. The PR description includes examples of YAML imports for Racks, Device Types, and Module Types, as well as YAML exports for Device Types and Module Types. These examples illustrate demonstrate how these new import and export changes look. ### Benefits This feature improves the usability of NetBox by allowing users to import weight data for Module Types and Device Types, as requested in #11670. It also makes it easier to manage and maintain this data, as it can be imported/exported along with other relevant information. ## Examples ### Rack Import Example (YAML) This is a YAML example of importing a Rack in NetBox. The below YAML worked in NetBox prior to this Pull Request. ```yaml site: DM-Albany name: blahabc status: active width: 19 u_height: 42 weight: 10 weight_unit: kg ``` ### Device Type Import Example (YAML) This is a YAML example of importing a Device Type in NetBox. ```yaml manufacturer: Juniper model: Switch slug: switch u_height: 1 weight: 10 weight_unit: kg ``` ### Module Type Import Example (YAML) This is a YAML example of importing a Module Type in NetBox. ```yaml manufacturer: Juniper model: TEST-1001 weight: 10 weight_unit: lb ``` ### YAML Export Attached below are example exports with the new `weight` and `weight_unit` fields included: - [netbox_device_types_yaml.txt](https://github.com/netbox-community/netbox/files/11413947/netbox_device_types_yaml.txt) - [netbox_module_types_yaml.txt](https://github.com/netbox-community/netbox/files/11413946/netbox_module_types_yaml.txt) --- <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 23:22:00 +01:00
adam closed this issue 2025-12-29 23:22:00 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#14005