Merge pull request #197 from jabbate19/ide-drive

Fix 500 on IDE Drives
This commit is contained in:
Joe Abbate 2023-06-18 22:17:29 -04:00 committed by GitHub
commit 34d2869c53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View file

@ -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

View file

@ -11,6 +11,12 @@ 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:
def __init__(self, vmid):
@ -261,7 +267,8 @@ class VM:
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
@ -280,11 +287,10 @@ class VM:
@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'))