mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-09 00:58:16 -06:00
14692 convert disk size to MB
This commit is contained in:
parent
50169365a9
commit
5e19c890eb
@ -137,7 +137,7 @@
|
|||||||
</th>
|
</th>
|
||||||
<td>
|
<td>
|
||||||
{% if object.disk %}
|
{% if object.disk %}
|
||||||
{{ object.disk }} {% trans "GB" context "Abbreviation for gigabyte" %}
|
{{ object.disk|humanize_megabytes }}
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ ''|placeholder }}
|
{{ ''|placeholder }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
23
netbox/virtualization/migrations/0039_convert_disk_size.py
Normal file
23
netbox/virtualization/migrations/0039_convert_disk_size.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# Generated by Django 5.0.6 on 2024-06-06 17:46
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
from django.db.models import F
|
||||||
|
|
||||||
|
|
||||||
|
def convert_disk_size(apps, schema_editor):
|
||||||
|
VirtualMachine = apps.get_model('virtualization', 'VirtualMachine')
|
||||||
|
VirtualMachine.objects.update(disk=F('disk') * 1024)
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('virtualization', '0038_virtualdisk'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(
|
||||||
|
code=convert_disk_size,
|
||||||
|
reverse_code=migrations.RunPython.noop
|
||||||
|
),
|
||||||
|
]
|
@ -125,7 +125,7 @@ class VirtualMachine(ContactsMixin, ImageAttachmentsMixin, RenderConfigMixin, Co
|
|||||||
disk = models.PositiveIntegerField(
|
disk = models.PositiveIntegerField(
|
||||||
blank=True,
|
blank=True,
|
||||||
null=True,
|
null=True,
|
||||||
verbose_name=_('disk (GB)')
|
verbose_name=_('disk (MB)')
|
||||||
)
|
)
|
||||||
|
|
||||||
# Counter fields
|
# Counter fields
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import django_tables2 as tables
|
import django_tables2 as tables
|
||||||
|
from django.contrib.humanize.templatetags.humanize import intcomma
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from dcim.tables.devices import BaseInterfaceTable
|
from dcim.tables.devices import BaseInterfaceTable
|
||||||
@ -118,6 +119,9 @@ class VirtualMachineTable(TenancyColumnsMixin, ContactsColumnMixin, NetBoxTable)
|
|||||||
'pk', 'name', 'status', 'site', 'cluster', 'role', 'tenant', 'vcpus', 'memory', 'disk', 'primary_ip',
|
'pk', 'name', 'status', 'site', 'cluster', 'role', 'tenant', 'vcpus', 'memory', 'disk', 'primary_ip',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def render_disk(self, value):
|
||||||
|
return intcomma(value)
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# VM components
|
# VM components
|
||||||
|
Loading…
Reference in New Issue
Block a user