Fix ruff check errors

This commit is contained in:
mika.busch 2025-02-10 09:06:48 +01:00
parent a77978ebf7
commit 572ce91387
2 changed files with 4 additions and 0 deletions

View File

@ -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):
"""

View File

@ -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)