Divide VM memory by 1.024 to accomodate 'metric' interpretation by Netbox
After the Netbox 4.0 upgrade, the web GUI started reporting VM memory in 'metric' units like GB, instead of 'binary' units like GiB, which it did prior to 4.0.
I opened an issue for this in the Netbox project, and was told that this is the way that its going to be.
However, Netbox-sync still sets the memory field in MiB (for a VM with 12 GiB RAM, netbox-sync sets the MB field to 12288, while Netbox 'expects' 12000).
Could you please reflect the changes that Netbox made? So the import divides the memory value by 1.024 somewhere in the process?
I think this is pretty a low-priority problem, but it would be nice if it could be fixed eventually 🌈
Hi,
I checked and it worked fine with 4.0.1 but looks different in 4.0.6.
also could't easily find the issue in the change log of the versions in between.
The problem here is: the value only "changed" in the UI. If you also use the API then the value there remains the same.
Technically this would change the API output as well if we adjust the value.
Technically this would change the API output as well if we adjust the value.
I understand what you're saying, however the Netbox maintainers are saying that the 'binary' display we used to have was incorrect. (Implying that the API should always have reported 'decimal' values). I wish that wasn't the case, because I think 'binary' representation is more relevant, but my opinion doesn't matter in this case.
So I think that in the eyes of Netbox, any application using this value from the API should always have interpreted it as MB, not MiB.
I can ask you the same thing I asked Jeremy; could you make it configurable? But I would understand it if you're hesitant to put time in a 'feature' you don't agree with 😅
It's easy to make it configurable. Had this in mind to not break any existing API integration based on this project.
Will add a config option like vm_momery_in_mib. Or do you have a more fitting name?
Upgraded from 4.0.3 to 4.0.8 and got this unexpected behavior. Question to maintainers: Where did you find real cases, where RAM expected to be entered as MB/GB/TB instead of MiB/GiB/TiB? MS HV, VMware vSphere, LXC, QEMU, OpenStack, many cloud providers (~10 that I used) - all of them use 1024 base for memory.
Why change divisor now, instead of fixing obvious visual error (show correct MiB, GiB, TiB for memory)?
Upgraded from 4.0.3 to 4.0.8 and got this unexpected behavior.
Question to maintainers: Where did you find real cases, where RAM expected to be entered as MB/GB/TB instead of MiB/GiB/TiB? MS HV, VMware vSphere, LXC, QEMU, OpenStack, many cloud providers (~10 that I used) - all of them use 1024 base for memory.
Why change divisor now, instead of fixing obvious visual error (show correct MiB, GiB, TiB for memory)?
Hi @stavr666,
You would need to direct your questions towarda the NetBox project. Preferably in the related issue https://github.com/netbox-community/netbox/issues/16770
Here we can only mitigate the change.
@bb-Ricardo
vm_memory_in_mib might imply that it always shows the memory in MiB, not binary multiples in general (like KiB,GiB etc).
Looking at this wikipedia article I would go for vm_memory_in_binary_multiples? It's a bit long, but its clear at least 😅 .
Hi @yaiqsa and @stavr666,
I just pushed a new commit to the development branch with newly added config option:
; In NetBox version 4.1.0 and newer the VM disk and RAM values are displayed in power of
; 10 instead of power of 2. If this values is set to true 4GB of RAM will be set to a
; value of 4000 megabyte. If set to false 4GB of RAM will be reported as 4096MB. The same
; behavior also applies for VM disk sizes.
;vm_disk_and_ram_in_decimal = True
Would you be able to try it out and see if this fixes the issue?
@bb-Ricardo It seems to be correct!
Thank you for the fix! I saw that there is some more activity in the Netbox issue regarding this decision by the way, we'll see how it's going to end.
Thank you very much for testing it.