Closes #11670: Add ability to optionally import DeviceType and ModuleType weight #12512
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
andweight_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.
Device Type Import Example (YAML)
This is a YAML example of importing a Device Type in NetBox.
Module Type Import Example (YAML)
This is a YAML example of importing a Module Type in NetBox.
YAML Export
Attached below are example exports with the new
weight
andweight_unit
fields included: