Skip to content

Commit 35165a3

Browse files
committed
Debug MB to GB Function
1 parent bb88e64 commit 35165a3

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

proxstar/user.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from math import ceil
2+
13
from proxmoxer.core import ResourceException
24
from rq.registry import StartedJobRegistry
35

@@ -88,7 +90,7 @@ def usage(self):
8890
usage['cpu'] += int(vm.cpu)
8991
usage['mem'] += int(vm.mem) / 1024
9092
for disk in vm.disks:
91-
usage['disk'] += int(disk[1])
93+
usage['disk'] += int(ceil(disk[1]))
9294
return usage
9395

9496
@lazy_property

proxstar/vm.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
from proxstar.starrs import get_ip_for_mac
1111
from proxstar.util import lazy_property, default_repr
1212

13+
def check_in_gb(size):
14+
if size[-1] == 'M':
15+
size = f'{int(size.rstrip("M")) / 1000}G'
16+
return size
1317

1418
@default_repr
1519
class VM:
@@ -251,11 +255,6 @@ def get_disk_size(self, name='virtio0'):
251255
disk_size = split.split('=')[1].rstrip('G')
252256
return disk_size
253257

254-
def check_in_gb(size):
255-
if size[-1] == 'M':
256-
size = f'{int(size.rstrip("M")) / 1000}G'
257-
return size
258-
259258
@lazy_property
260259
def disks(self):
261260
disks = []

0 commit comments

Comments
 (0)