[PR #18011] [MERGED] 17686 config option for disk divider #15249

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

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/18011
Author: @Haeki
Created: 11/14/2024
Status: Merged
Merged: 3/7/2025
Merged by: @arthanson

Base: mainHead: 17686-config_option_for_disk_divider


📝 Commits (10+)

  • 09b7715 Closes #17686: Abillity to select disk divider
  • 391e4e6 Merge branch 'netbox-community:develop' into 17686-config_option_for_disk_divider
  • c35db10 Merge branch 'netbox-community:main' into 17686-config_option_for_disk_divider
  • 27b7687 Rename _UNIT_DIVISOR to _BASE_UNIT
  • e21e317 Check that Disk/Ram base units are 1000 or 1024
  • a77978e Merge branch 'netbox-community:main' into 17686-config_option_for_disk_divider
  • 572ce91 Fix ruff check errors
  • 6caf957 Merge branch 'netbox-community:main' into 17686-config_option_for_disk_divider
  • 1df7ba7 Merge branch 'netbox-community:main' into 17686-config_option_for_disk_divider
  • 2c1237e commented out to keep default

📊 Changes

9 files changed (+59 additions, -16 deletions)

View changed files

📝 docs/configuration/miscellaneous.md (+12 -0)
📝 netbox/netbox/configuration_example.py (+5 -0)
📝 netbox/netbox/settings.py (+6 -0)
📝 netbox/templates/virtualization/cluster.html (+2 -2)
📝 netbox/templates/virtualization/virtualdisk.html (+1 -1)
📝 netbox/templates/virtualization/virtualmachine.html (+2 -2)
📝 netbox/utilities/templatetags/helpers.py (+25 -6)
📝 netbox/virtualization/migrations/0040_convert_disk_size.py (+3 -2)
📝 netbox/virtualization/tables/virtualmachines.py (+3 -3)

📄 Description

Fixes: #17686 Ability to select disk divider

I added two new config options to specify the divider used to calculate the disk and ram sizes in different units.
The default value is 1000 but can be changed to 1024 to get GiB instead of GB.
Those config values are used in the humanize_megabytes method. I split this method into two separate methods, one for RAM and one for disk values. Additionally I added the disk config value to the disk migration so that users with GiB values get them converted to MiB.
I tested the changes in my local environment and noticed no problems.

I'm open for feedback and I also didn't include any tests yet.


🔄 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/18011 **Author:** [@Haeki](https://github.com/Haeki) **Created:** 11/14/2024 **Status:** ✅ Merged **Merged:** 3/7/2025 **Merged by:** [@arthanson](https://github.com/arthanson) **Base:** `main` ← **Head:** `17686-config_option_for_disk_divider` --- ### 📝 Commits (10+) - [`09b7715`](https://github.com/netbox-community/netbox/commit/09b771507f0d41c4be38fe852da1d944b4bffbac) Closes #17686: Abillity to select disk divider - [`391e4e6`](https://github.com/netbox-community/netbox/commit/391e4e696667c9a99090d34dbf1c21cde307b7fa) Merge branch 'netbox-community:develop' into 17686-config_option_for_disk_divider - [`c35db10`](https://github.com/netbox-community/netbox/commit/c35db10f220fd1c4df9bd71a55c73a0726138fff) Merge branch 'netbox-community:main' into 17686-config_option_for_disk_divider - [`27b7687`](https://github.com/netbox-community/netbox/commit/27b76870c455985abfee852343ef0fdbe1930436) Rename _UNIT_DIVISOR to _BASE_UNIT - [`e21e317`](https://github.com/netbox-community/netbox/commit/e21e31762799684938b855dc0c4e917c03beec13) Check that Disk/Ram base units are 1000 or 1024 - [`a77978e`](https://github.com/netbox-community/netbox/commit/a77978ebf7f8e5a7df575381f3c89ac14806a763) Merge branch 'netbox-community:main' into 17686-config_option_for_disk_divider - [`572ce91`](https://github.com/netbox-community/netbox/commit/572ce91387ec7f409877c306543fd9b913910036) Fix ruff check errors - [`6caf957`](https://github.com/netbox-community/netbox/commit/6caf957158efd37d7ae8ebcaa6f49ea219ac182a) Merge branch 'netbox-community:main' into 17686-config_option_for_disk_divider - [`1df7ba7`](https://github.com/netbox-community/netbox/commit/1df7ba72f6331bab4301b1a4f791e8288a92eaff) Merge branch 'netbox-community:main' into 17686-config_option_for_disk_divider - [`2c1237e`](https://github.com/netbox-community/netbox/commit/2c1237e98bf11b06cc4b1926b0e5b20156bb8e71) commented out to keep default ### 📊 Changes **9 files changed** (+59 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `docs/configuration/miscellaneous.md` (+12 -0) 📝 `netbox/netbox/configuration_example.py` (+5 -0) 📝 `netbox/netbox/settings.py` (+6 -0) 📝 `netbox/templates/virtualization/cluster.html` (+2 -2) 📝 `netbox/templates/virtualization/virtualdisk.html` (+1 -1) 📝 `netbox/templates/virtualization/virtualmachine.html` (+2 -2) 📝 `netbox/utilities/templatetags/helpers.py` (+25 -6) 📝 `netbox/virtualization/migrations/0040_convert_disk_size.py` (+3 -2) 📝 `netbox/virtualization/tables/virtualmachines.py` (+3 -3) </details> ### 📄 Description ### Fixes: #17686 Ability to select disk divider I added two new config options to specify the divider used to calculate the disk and ram sizes in different units. The default value is 1000 but can be changed to 1024 to get GiB instead of GB. Those config values are used in the `humanize_megabytes` method. I split this method into two separate methods, one for RAM and one for disk values. Additionally I added the disk config value to the disk migration so that users with GiB values get them converted to MiB. I tested the changes in my local environment and noticed no problems. I'm open for feedback and I also didn't include any tests yet. --- <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:20:51 +01:00
adam closed this issue 2025-12-30 00:20:52 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15249