Ignore:
Timestamp:
Feb 16, 2009, 11:52:01 PM (16 years ago)
Author:
iannucci
Message:

RAM quotas at remctl; RAM quota exception script, table, and usage in -web and -remote-create; /etc/nocreate support

File:
1 edited

Legend:

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

    r2064 r2132  
    66import string
    77import dns.resolver
    8 from invirt.database import Machine, NIC, Type, Disk, CDROM, Autoinstall
     8from invirt.database import Machine, NIC, Type, Disk, CDROM, Autoinstall, Owner
    99from invirt.config import structs as config
    1010from invirt.common import InvalidInput, CodeError
    1111
    12 MAX_MEMORY_TOTAL = 512
    13 MAX_MEMORY_SINGLE = 512
    1412MIN_MEMORY_SINGLE = 16
    1513MAX_DISK_TOTAL = 50
     
    9290    returned.
    9391    """
    94     if machine is not None and machine.memory > MAX_MEMORY_SINGLE:
    95         # If they've been blessed, let them have it
    96         return machine.memory
     92    (quota_total, quota_single) = Owner.getQuotas(machine.owner if machine else owner)
     93
    9794    if not on:
    98         return MAX_MEMORY_SINGLE
     95        return quota_single
    9996    machines = getMachinesByOwner(owner, machine)
    10097    active_machines = [m for m in machines if m.name in g.xmlist_raw]
    10198    mem_usage = sum([x.memory for x in active_machines if x != machine])
    102     return min(MAX_MEMORY_SINGLE, MAX_MEMORY_TOTAL-mem_usage)
     99    return min(quota_single, quota_total-mem_usage)
    103100
    104101def maxDisk(owner, machine=None):
Note: See TracChangeset for help on using the changeset viewer.