mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-27 19:08:38 -06:00
Fix ruff check errors
This commit is contained in:
parent
a77978ebf7
commit
572ce91387
@ -85,6 +85,7 @@ def humanize_speed(speed):
|
||||
else:
|
||||
return '{} Kbps'.format(speed)
|
||||
|
||||
|
||||
def _humanize_megabytes(mb, divisor=1000):
|
||||
"""
|
||||
Express a number of megabytes in the most suitable unit (e.g. gigabytes, terabytes, etc.).
|
||||
@ -104,6 +105,7 @@ def _humanize_megabytes(mb, divisor=1000):
|
||||
return f"{mb / GB_SIZE:.2f} GB"
|
||||
return f"{mb} MB"
|
||||
|
||||
|
||||
@register.filter()
|
||||
def humanize_disk_megabytes(mb):
|
||||
"""
|
||||
@ -112,6 +114,7 @@ def humanize_disk_megabytes(mb):
|
||||
"""
|
||||
return _humanize_megabytes(mb, DISK_BASE_UNIT)
|
||||
|
||||
|
||||
@register.filter()
|
||||
def humanize_ram_megabytes(mb):
|
||||
"""
|
||||
|
@ -2,6 +2,7 @@ from django.db import migrations
|
||||
from django.db.models import F, Sum
|
||||
from netbox.settings import DISK_BASE_UNIT
|
||||
|
||||
|
||||
def convert_disk_size(apps, schema_editor):
|
||||
VirtualMachine = apps.get_model('virtualization', 'VirtualMachine')
|
||||
VirtualMachine.objects.filter(disk__isnull=False).update(disk=F('disk') * DISK_BASE_UNIT)
|
||||
|
Loading…
Reference in New Issue
Block a user