diff --git a/proxstar/user.py b/proxstar/user.py index 96ff819..230dae7 100644 --- a/proxstar/user.py +++ b/proxstar/user.py @@ -1,3 +1,5 @@ +from math import ceil + from proxmoxer.core import ResourceException from rq.registry import StartedJobRegistry @@ -88,7 +90,7 @@ class User: usage['cpu'] += int(vm.cpu) usage['mem'] += int(vm.mem) / 1024 for disk in vm.disks: - usage['disk'] += int(disk[1]) + usage['disk'] += int(ceil(disk[1])) return usage @lazy_property diff --git a/proxstar/vm.py b/proxstar/vm.py index 99e668e..6468c11 100644 --- a/proxstar/vm.py +++ b/proxstar/vm.py @@ -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.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 class VM: @@ -251,11 +255,6 @@ class VM: disk_size = split.split('=')[1].rstrip('G') return disk_size - def check_in_gb(size): - if size[-1] == 'M': - size = f'{int(size.rstrip("M")) / 1000}G' - return size - @lazy_property def disks(self): disks = []