Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 500 on IDE Drives #197

Merged
merged 4 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading