Use MB/GB/TB suffix for VM memory input #5989

Closed
opened 2025-12-29 19:35:24 +01:00 by adam · 8 comments
Owner

Originally created by @hagbarddenstore on GitHub (Jan 23, 2022).

NetBox version

v3.1.6

Feature type

Change to existing functionality

Proposed functionality

Allow inputting memory with a MB/GB/TB suffix instead of defaulting to MB.

Use case

The use case is to make it easier for users to input the correct amount of memory for the virtual machine.

It is far more common today to input GBs of memory rather than MBs of memory and having to memorize or calculate the correct amount of MBs the wanted GB represent is tedious.

Database changes

None

External dependencies

One method of solving it is by changing the form input field to this https://pypi.org/project/django-sizefield/.

Originally created by @hagbarddenstore on GitHub (Jan 23, 2022). ### NetBox version v3.1.6 ### Feature type Change to existing functionality ### Proposed functionality Allow inputting memory with a MB/GB/TB suffix instead of defaulting to MB. ### Use case The use case is to make it easier for users to input the correct amount of memory for the virtual machine. It is far more common today to input GBs of memory rather than MBs of memory and having to memorize or calculate the correct amount of MBs the wanted GB represent is tedious. ### Database changes None ### External dependencies One method of solving it is by changing the form input field to this https://pypi.org/project/django-sizefield/.
adam added the type: featurestatus: needs ownerpending closure labels 2025-12-29 19:35:24 +01:00
adam closed this issue 2025-12-29 19:35:25 +01:00
Author
Owner

@jeremystretch commented on GitHub (Jan 26, 2022):

To clarify, the intent here is to enable the user to enter a value such as "8gb"in the form field and have NetBox automatically convert that to a value of 8192, correct?

@jeremystretch commented on GitHub (Jan 26, 2022): To clarify, the intent here is to enable the user to enter a value such as "8gb"in the form field and have NetBox automatically convert that to a value of `8192`, correct?
Author
Owner

@hagbarddenstore commented on GitHub (Jan 26, 2022):

@jeremystretch Yes exactly, so just a frontend change.

@hagbarddenstore commented on GitHub (Jan 26, 2022): @jeremystretch Yes exactly, so just a frontend change.
Author
Owner

@jeremystretch commented on GitHub (Jan 28, 2022):

Another option would be to keep the integer field and add a separate unit selection dropdown (similar to what we do with circuit speeds). Django's MultiValueField might be useful for this approach, though I haven't experimented with it myself.

@jeremystretch commented on GitHub (Jan 28, 2022): Another option would be to keep the integer field and add a separate unit selection dropdown (similar to what we do with circuit speeds). Django's [`MultiValueField`](https://docs.djangoproject.com/en/4.0/ref/forms/fields/#multivaluefield) might be useful for this approach, though I haven't experimented with it myself.
Author
Owner

@hagbarddenstore commented on GitHub (Jan 28, 2022):

That works as well.

On 28 Jan 2022, at 15:25, Jeremy Stretch @.***> wrote:


Another option would be to keep the integer field and add a separate unit selection dropdown (similar to what we do with circuit speeds). Django's MultiValueField might be useful for this approach, though I haven't experimented with it myself.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you authored the thread.

@hagbarddenstore commented on GitHub (Jan 28, 2022): That works as well. > On 28 Jan 2022, at 15:25, Jeremy Stretch ***@***.***> wrote: > >  > Another option would be to keep the integer field and add a separate unit selection dropdown (similar to what we do with circuit speeds). Django's MultiValueField might be useful for this approach, though I haven't experimented with it myself. > > — > Reply to this email directly, view it on GitHub, or unsubscribe. > Triage notifications on the go with GitHub Mobile for iOS or Android. > You are receiving this because you authored the thread.
Author
Owner

@minitriga commented on GitHub (Mar 10, 2022):

Managed to get something working without altering the model, the user can select what unit they want to enter the value in and it will convert it on the backend to MB. when you go to edit the form again it will then present you with the value so if you entered 9GB it will show 9216 MB as shown in the picture below.

image

This implements MultiValueField just got to work on formatting the html properly.

@minitriga commented on GitHub (Mar 10, 2022): Managed to get something working without altering the model, the user can select what unit they want to enter the value in and it will convert it on the backend to MB. when you go to edit the form again it will then present you with the value so if you entered 9GB it will show 9216 MB as shown in the picture below. ![image](https://user-images.githubusercontent.com/26367336/157722551-142b3b5c-7095-40c8-8760-2696319b8048.png) This implements MultiValueField just got to work on formatting the html properly.
Author
Owner

@juliusrickert commented on GitHub (Mar 18, 2022):

@minitriga useful addition :)

I'd like to suggest inlining the <select> with the <input>.

@juliusrickert commented on GitHub (Mar 18, 2022): @minitriga useful addition :) I'd like to suggest inlining the `<select>` with the `<input>`.
Author
Owner

@github-actions[bot] commented on GitHub (Apr 6, 2023):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

@github-actions[bot] commented on GitHub (Apr 6, 2023): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. **Do not** attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
Author
Owner

@github-actions[bot] commented on GitHub (May 7, 2023):

This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.

@github-actions[bot] commented on GitHub (May 7, 2023): This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5989