Ignore:
Timestamp:
Feb 17, 2009, 1:54:26 AM (15 years ago)
Author:
iannucci
Message:

Added all the other quotas for great win.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/invirt-web/code/validation.py

    r2132 r2134  
    1111
    1212MIN_MEMORY_SINGLE = 16
    13 MAX_DISK_TOTAL = 50
    14 MAX_DISK_SINGLE = 50
    1513MIN_DISK_SINGLE = 0.1
    16 MAX_VMS_TOTAL = 10
    17 MAX_VMS_ACTIVE = 4
    1814
    1915class Validate:
     
    9086    returned.
    9187    """
    92     (quota_total, quota_single) = Owner.getQuotas(machine.owner if machine else owner)
     88    (quota_total, quota_single) = Owner.getMemoryQuotas(machine.owner if machine else owner)
    9389
    9490    if not on:
     
    105101    return the maximum that a given machine can be changed to.
    106102    """
     103    (quota_total, quota_single) = Owner.getDiskQuotas(machine.owner if machine else owner)
     104
    107105    if machine is not None:
    108106        machine_id = machine.machine_id
     
    112110                     join('machine').\
    113111                     filter_by(owner=owner).sum(Disk.c.size) or 0
    114     return min(MAX_DISK_SINGLE, MAX_DISK_TOTAL-disk_usage/1024.)
     112    return min(quota_single, quota_total-disk_usage/1024.)
    115113
    116114def cantAddVm(owner, g):
    117115    machines = getMachinesByOwner(owner)
    118116    active_machines = [m for m in machines if m.name in g.xmlist_raw]
    119     if machines.count() >= MAX_VMS_TOTAL:
     117    (quota_total, quota_active) = Owner.getVMQuotas(machine.owner if machine else owner)
     118    if machines.count() >= quota_total:
    120119        return 'You have too many VMs to create a new one.'
    121     if len(active_machines) >= MAX_VMS_ACTIVE:
     120    if len(active_machines) >= quota_active:
    122121        return ('You already have the maximum number of VMs turned on.  '
    123122                'To create more, turn one off.')
Note: See TracChangeset for help on using the changeset viewer.