Changeset 2132 for trunk/packages/invirt-web/code
- Timestamp:
- Feb 16, 2009, 11:52:01 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/invirt-web/code/validation.py
r2064 r2132 6 6 import string 7 7 import dns.resolver 8 from invirt.database import Machine, NIC, Type, Disk, CDROM, Autoinstall 8 from invirt.database import Machine, NIC, Type, Disk, CDROM, Autoinstall, Owner 9 9 from invirt.config import structs as config 10 10 from invirt.common import InvalidInput, CodeError 11 11 12 MAX_MEMORY_TOTAL = 51213 MAX_MEMORY_SINGLE = 51214 12 MIN_MEMORY_SINGLE = 16 15 13 MAX_DISK_TOTAL = 50 … … 92 90 returned. 93 91 """ 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 97 94 if not on: 98 return MAX_MEMORY_SINGLE95 return quota_single 99 96 machines = getMachinesByOwner(owner, machine) 100 97 active_machines = [m for m in machines if m.name in g.xmlist_raw] 101 98 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) 103 100 104 101 def maxDisk(owner, machine=None):
Note: See TracChangeset
for help on using the changeset viewer.