Changed decimal size for memory_sum and disk_sum

This commit is contained in:
Julio-Oliveira-Encora 2024-04-30 15:17:26 -03:00
parent 1ba2dd04fa
commit 07305f9037
2 changed files with 3 additions and 2 deletions

View File

@ -37,6 +37,7 @@ def convert_byte_size(value, unit="mega"):
"tera": 1024 ** 4, "tera": 1024 ** 4,
} }
if value: if value:
# If the value is less than 6 digits, it understands the value is expressed according to the unit.
if len(str(value)) < 6: if len(str(value)) < 6:
return value return value
value_converted = float(value) / factors[unit] value_converted = float(value) / factors[unit]

View File

@ -180,8 +180,8 @@ class ClusterView(generic.ObjectView):
disk_sum = sum(vm_disk) disk_sum = sum(vm_disk)
extra_content = instance.virtual_machines.aggregate(vcpus_sum=Sum('vcpus')) extra_content = instance.virtual_machines.aggregate(vcpus_sum=Sum('vcpus'))
extra_content['memory_sum'] = f"{memory_sum:.0f}" extra_content['memory_sum'] = f"{memory_sum:.2f}"
extra_content['disk_sum'] = f"{disk_sum:.0f}" extra_content['disk_sum'] = f"{disk_sum:.2f}"
return extra_content return extra_content