Skip to content
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

Closes #11670: Add ability to optionally import DeviceType and ModuleType weight #12512

Conversation

dhenschen
Copy link
Contributor

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:

dhenschen and others added 3 commits May 7, 2023 00:21
This is 1 of 2 commits to address issue netbox-community#11670

To maintain consistency, the import design of the DeviceType weight follows the
same pattern used for importing weight and weight units in DCIM Racks.
This is commit 2 of 2 to address and close netbox-community#11670.

To maintain consistency, the import design of the ModuleType weight follows the
same pattern used for importing weight and weight units in DCIM Racks.
@jeremystretch
Copy link
Member

Thanks for such a thorough PR @dhenschen! I've merged your new tests into the existing test_import_objects() tests just to reduce redundancy.

@jeremystretch jeremystretch merged commit c55c14e into netbox-community:develop May 9, 2023
jsenecal pushed a commit to jsenecal/netbox that referenced this pull request May 18, 2023
…eType and ModuleType weight (netbox-community#12512)

* 11670: Add optional weight to DeviceType import

This is 1 of 2 commits to address issue netbox-community#11670

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

* Closes netbox-community#11670: Add weight to ModuleType import

This is commit 2 of 2 to address and close netbox-community#11670.

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

* Merge tests; misc cleanup

---------

Co-authored-by: jeremystretch <[email protected]>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Import Device/Module Weight
2 participants