Disk Size conversion from GB to MB during update to 4.1.2 #10301

Closed
opened 2025-12-29 21:29:36 +01:00 by adam · 5 comments
Owner

Originally created by @AndreasSMoe on GitHub (Sep 27, 2024).

Deployment Type

Self-hosted

NetBox Version

v4.1.2

Python Version

3.12

Steps to Reproduce

10000 MB is shown as 10GB, import with script is bytes/1MB, which gives 10.24GB in netbox (1024MB)
Tested to do (bytes/1GB)*1000 was shown correctly. But failes if disk is > 1TB

Is there a configuration setting to choose between divider of 1000 and 1024?

Expected Behavior

1024 MB shown as 1GB so that conversion from bytes to MB will be shown correctly

Observed Behavior

The value is shown as 50GB when 50000 MB is entered. Expected that 51200 MB would show as 50GB

Originally created by @AndreasSMoe on GitHub (Sep 27, 2024). ### Deployment Type Self-hosted ### NetBox Version v4.1.2 ### Python Version 3.12 ### Steps to Reproduce 10000 MB is shown as 10GB, import with script is bytes/1MB, which gives 10.24GB in netbox (1024MB) Tested to do (bytes/1GB)*1000 was shown correctly. But failes if disk is > 1TB Is there a configuration setting to choose between divider of 1000 and 1024? ### Expected Behavior 1024 MB shown as 1GB so that conversion from bytes to MB will be shown correctly ### Observed Behavior The value is shown as 50GB when 50000 MB is entered. Expected that 51200 MB would show as 50GB
adam added the type: bugstatus: revisions needed labels 2025-12-29 21:29:36 +01:00
adam closed this issue 2025-12-29 21:29:37 +01:00
Author
Owner

@AndreasSMoe commented on GitHub (Sep 27, 2024):

Simular issue as
https://github.com/netbox-community/netbox/pull/17605 but for VMs

@AndreasSMoe commented on GitHub (Sep 27, 2024): Simular issue as https://github.com/netbox-community/netbox/pull/17605 but for VMs
Author
Owner

@arthanson commented on GitHub (Sep 30, 2024):

@AndreasSMoe can you please update your reproduction steps, you never state where this is occurring or what steps to see it appear.

@arthanson commented on GitHub (Sep 30, 2024): @AndreasSMoe can you please update your reproduction steps, you never state where this is occurring or what steps to see it appear.
Author
Owner

@AndreasSMoe commented on GitHub (Oct 1, 2024):

Field used to be GB, is now MB
Field collected from VMM is in Bytes, 1024 Bytes is 1KB, 1024KB is 1MB, 1024MB is 1GB, 1024GB is 1TB
Netbox uses 1000 Bytes as 1KB, 1000MB as 1GB
Example
Importing a value of 50000 MB on virtual disk is shown as 50GB
While converting from bytes to MB
52428800 Bytes is 51200MB

In Netbox, 51200 MB is converted to 51,2GB which is not correct

if I convert the bytes
52428800/1MB = 51200 MB which is correct, but shown wrong
(52428800/1GB)*1000 = 50000MB which is wrong, but shown correctly

Problems occur if the disk is larger than 1TB

(1 073 741 824/1GB)*1000 = 1024GB which is wrong, will be shown as 1.02 TB

Correct would be to not use humanizenumbers as conversion will be wrong
A posible solution would be to add ability in configuration to choose between 1000 and 1024

image
vs edit
image

To get value 60GB, the MB value should be 61440MB

But if I change value the converted value shown under virual disk is
image

We use netbox as source for our billing, and as a workaround they now divide the MB number by 1000
The correct way would be for billing to devide by 1024

@AndreasSMoe commented on GitHub (Oct 1, 2024): Field used to be GB, is now MB Field collected from VMM is in Bytes, 1024 Bytes is 1KB, 1024KB is 1MB, 1024MB is 1GB, 1024GB is 1TB Netbox uses 1000 Bytes as 1KB, 1000MB as 1GB Example Importing a value of 50000 MB on virtual disk is shown as 50GB While converting from bytes to MB 52428800 Bytes is 51200MB In Netbox, 51200 MB is converted to 51,2GB which is not correct if I convert the bytes 52428800/1MB = 51200 MB which is correct, but shown wrong (52428800/1GB)*1000 = 50000MB which is wrong, but shown correctly Problems occur if the disk is larger than 1TB (1 073 741 824/1GB)*1000 = 1024GB which is wrong, will be shown as 1.02 TB Correct would be to not use humanizenumbers as conversion will be wrong A posible solution would be to add ability in configuration to choose between 1000 and 1024 ![image](https://github.com/user-attachments/assets/2894d2a6-10cd-4479-8330-7fa92cb9c38a) vs edit ![image](https://github.com/user-attachments/assets/63486073-09d3-4fcc-9ed7-85bf475a2d92) To get value 60GB, the MB value should be 61440MB But if I change value the converted value shown under virual disk is ![image](https://github.com/user-attachments/assets/8af272f1-b37c-42fa-b33e-dcf156631243) We use netbox as source for our billing, and as a workaround they now divide the MB number by 1000 The correct way would be for billing to devide by 1024
Author
Owner

@arthanson commented on GitHub (Oct 3, 2024):

@AndreasSMoe This is not strictly a bug as it was designed that way, we went back and forth on dividing by 1000 or 1024. Your suggestion is good though for having it be a configurable parameter, can you please close this and bug and open up a Feature Request for this.

@arthanson commented on GitHub (Oct 3, 2024): @AndreasSMoe This is not strictly a bug as it was designed that way, we went back and forth on dividing by 1000 or 1024. Your suggestion is good though for having it be a configurable parameter, can you please close this and bug and open up a Feature Request for this.
Author
Owner

@AndreasSMoe commented on GitHub (Oct 7, 2024):

Reported as a feature request

@AndreasSMoe commented on GitHub (Oct 7, 2024): Reported as a feature request
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10301