mirror of
https://github.com/ComputerScienceHouse/proxstar.git
synced 2025-03-09 15:40:09 +00:00
check usage before starting vm, hide start button if not enough resources, always show cpu/mem buttons
This commit is contained in:
parent
75ef5a98d1
commit
79fff2e762
2 changed files with 32 additions and 22 deletions
8
app.py
8
app.py
|
@ -75,7 +75,8 @@ def vm_details(vmid):
|
|||
vm['expire'] = get_vm_expire(vmid, app.config['VM_EXPIRE_MONTHS']).strftime('%m/%d/%Y')
|
||||
usage = get_user_usage(proxmox, 'proxstar')
|
||||
limits = get_user_usage_limits(user)
|
||||
return render_template('vm_details.html', username='com6056', vm=vm, usage=usage, limits=limits)
|
||||
usage_check = check_user_usage(proxmox, user, vm['config']['cores'], vm['config']['memory'], 0)
|
||||
return render_template('vm_details.html', username='com6056', vm=vm, usage=usage, limits=limits, usage_check=usage_check)
|
||||
else:
|
||||
return '', 403
|
||||
|
||||
|
@ -86,6 +87,11 @@ def vm_power(vmid, action):
|
|||
app.config['PROXMOX_USER'],
|
||||
app.config['PROXMOX_PASS'])
|
||||
if int(vmid) in get_user_allowed_vms(proxmox, user):
|
||||
if action == 'start':
|
||||
config = get_vm_config(proxmox, vmid)
|
||||
usage_check = check_user_usage(proxmox, user, config['cores'], config['memory'], 0)
|
||||
if usage_check:
|
||||
return usage_check
|
||||
change_vm_power(proxmox, vmid, action)
|
||||
return '', 200
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue