Skip to content

Commit

Permalink
Merge pull request #197 from jabbate19/ide-drive
Browse files Browse the repository at this point in the history
Fix 500 on IDE Drives
  • Loading branch information
jabbate19 committed Jun 19, 2023
2 parents 9b26311 + d16858e commit 34d2869
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion proxstar/user.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from math import ceil

from proxmoxer.core import ResourceException
from rq.registry import StartedJobRegistry

Expand Down Expand Up @@ -88,7 +90,7 @@ def usage(self):
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
Expand Down
12 changes: 9 additions & 3 deletions proxstar/vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
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:
def __init__(self, vmid):
Expand Down Expand Up @@ -261,7 +267,8 @@ def disks(self):
disk_size = val.split(',')
for split in disk_size:
if 'size' in split:
disk_size = split.split('=')[1].rstrip('G')
size = check_in_gb(split.split('=')[1])
disk_size = size.rstrip('G')
disks.append([key, disk_size])
disks = sorted(disks, key=lambda x: x[0])
return disks
Expand All @@ -280,11 +287,10 @@ def cdroms(self):
@lazy_property
def isos(self):
isos = []
for iso in filter(lambda interface: 'ide' in interface, self.config.keys()):
for iso in filter(lambda interface: interface in self.cdroms, self.config.keys()):
iso_info = self.config[iso]
if iso_info:
if 'cloudinit' in iso_info:
isos.append((iso, 'Clountinit Drive'))
continue
if iso_info.split(',')[0] == 'none':
isos.append((iso, 'None'))
Expand Down

0 comments on commit 34d2869

Please sign in to comment.