Debug MB to GB Function

This commit is contained in:
Joe Abbate 2023-06-18 19:41:42 -04:00
parent bb88e64aad
commit 35165a38c5
2 changed files with 7 additions and 6 deletions

View file

@ -1,3 +1,5 @@
from math import ceil
from proxmoxer.core import ResourceException from proxmoxer.core import ResourceException
from rq.registry import StartedJobRegistry from rq.registry import StartedJobRegistry
@ -88,7 +90,7 @@ class User:
usage['cpu'] += int(vm.cpu) usage['cpu'] += int(vm.cpu)
usage['mem'] += int(vm.mem) / 1024 usage['mem'] += int(vm.mem) / 1024
for disk in vm.disks: for disk in vm.disks:
usage['disk'] += int(disk[1]) usage['disk'] += int(ceil(disk[1]))
return usage return usage
@lazy_property @lazy_property

View file

@ -10,6 +10,10 @@ from proxstar.proxmox import connect_proxmox, get_free_vmid, get_node_least_mem,
from proxstar.starrs import get_ip_for_mac from proxstar.starrs import get_ip_for_mac
from proxstar.util import lazy_property, default_repr from proxstar.util import lazy_property, default_repr
def check_in_gb(size):
if size[-1] == 'M':
size = f'{int(size.rstrip("M")) / 1000}G'
return size
@default_repr @default_repr
class VM: class VM:
@ -251,11 +255,6 @@ class VM:
disk_size = split.split('=')[1].rstrip('G') disk_size = split.split('=')[1].rstrip('G')
return disk_size return disk_size
def check_in_gb(size):
if size[-1] == 'M':
size = f'{int(size.rstrip("M")) / 1000}G'
return size
@lazy_property @lazy_property
def disks(self): def disks(self):
disks = [] disks = []