Changeset 535 for trunk/packages/sipb-xen-www/code/validation.py
- Timestamp:
- May 15, 2008, 9:55:17 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/sipb-xen-www/code/validation.py
r440 r535 5 5 import re 6 6 import string 7 from sipb_xen_database import Machine, NIC, Type 7 from sipb_xen_database import Machine, NIC, Type, Disk 8 8 from webcommon import InvalidInput, g 9 9 … … 45 45 return MAX_MEMORY_SINGLE 46 46 machines = getMachinesByOwner(user, machine) 47 active_machines = [x for x in machines if g. uptimes.get(x)]47 active_machines = [x for x in machines if g.xmlist.get(x)] 48 48 mem_usage = sum([x.memory for x in active_machines if x != machine]) 49 49 return min(MAX_MEMORY_SINGLE, MAX_MEMORY_TOTAL-mem_usage) … … 55 55 return the maximum that a given machine can be changed to. 56 56 """ 57 machines = getMachinesByOwner(user, machine) 58 disk_usage = sum([sum([y.size for y in x.disks]) 59 for x in machines if x != machine]) 57 if machine is not None: 58 machine_id = machine.machine_id 59 else: 60 machine_id = None 61 disk_usage = Disk.query().filter_by(Disk.c.machine_id != machine_id, 62 owner=user).sum(Disk.c.size) 60 63 return min(MAX_DISK_SINGLE, MAX_DISK_TOTAL-disk_usage/1024.) 61 64 62 65 def cantAddVm(user): 63 66 machines = getMachinesByOwner(user) 64 active_machines = [x for x in machines if g. uptimes.get(x)]67 active_machines = [x for x in machines if g.xmlist.get(x)] 65 68 if len(machines) >= MAX_VMS_TOTAL: 66 69 return 'You have too many VMs to create a new one.'
Note: See TracChangeset
for help on using the changeset viewer.