Changeset 2134 for trunk/packages/invirt-web/code/validation.py
- Timestamp:
- Feb 17, 2009, 1:54:26 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/invirt-web/code/validation.py
r2132 r2134 11 11 12 12 MIN_MEMORY_SINGLE = 16 13 MAX_DISK_TOTAL = 5014 MAX_DISK_SINGLE = 5015 13 MIN_DISK_SINGLE = 0.1 16 MAX_VMS_TOTAL = 1017 MAX_VMS_ACTIVE = 418 14 19 15 class Validate: … … 90 86 returned. 91 87 """ 92 (quota_total, quota_single) = Owner.get Quotas(machine.owner if machine else owner)88 (quota_total, quota_single) = Owner.getMemoryQuotas(machine.owner if machine else owner) 93 89 94 90 if not on: … … 105 101 return the maximum that a given machine can be changed to. 106 102 """ 103 (quota_total, quota_single) = Owner.getDiskQuotas(machine.owner if machine else owner) 104 107 105 if machine is not None: 108 106 machine_id = machine.machine_id … … 112 110 join('machine').\ 113 111 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.) 115 113 116 114 def cantAddVm(owner, g): 117 115 machines = getMachinesByOwner(owner) 118 116 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: 120 119 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: 122 121 return ('You already have the maximum number of VMs turned on. ' 123 122 'To create more, turn one off.')
Note: See TracChangeset
for help on using the changeset viewer.