projects
/
invirt/packages/invirt-web.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
RAM quotas at remctl; RAM quota exception script, table, and usage in -web and -remot...
[invirt/packages/invirt-web.git]
/
code
/
validation.py
diff --git
a/code/validation.py
b/code/validation.py
index
5f2a3ff
..
05e4c27
100644
(file)
--- a/
code/validation.py
+++ b/
code/validation.py
@@
-5,12
+5,10
@@
import getafsgroups
import re
import string
import dns.resolver
import re
import string
import dns.resolver
-from invirt.database import Machine, NIC, Type, Disk, CDROM, Autoinstall
+from invirt.database import Machine, NIC, Type, Disk, CDROM, Autoinstall, Owner
from invirt.config import structs as config
from invirt.common import InvalidInput, CodeError
from invirt.config import structs as config
from invirt.common import InvalidInput, CodeError
-MAX_MEMORY_TOTAL = 512
-MAX_MEMORY_SINGLE = 512
MIN_MEMORY_SINGLE = 16
MAX_DISK_TOTAL = 50
MAX_DISK_SINGLE = 50
MIN_MEMORY_SINGLE = 16
MAX_DISK_TOTAL = 50
MAX_DISK_SINGLE = 50
@@
-91,15
+89,14
@@
def maxMemory(owner, g, machine=None, on=True):
memory for the machine to change to, if it is left off, is
returned.
"""
memory for the machine to change to, if it is left off, is
returned.
"""
- if machine is not None and machine.memory > MAX_MEMORY_SINGLE:
- # If they've been blessed, let them have it
- return machine.memory
+ (quota_total, quota_single) = Owner.getQuotas(machine.owner if machine else owner)
+
if not on:
if not on:
- return MAX_MEMORY_SINGLE
+ return quota_single
machines = getMachinesByOwner(owner, machine)
active_machines = [m for m in machines if m.name in g.xmlist_raw]
mem_usage = sum([x.memory for x in active_machines if x != machine])
machines = getMachinesByOwner(owner, machine)
active_machines = [m for m in machines if m.name in g.xmlist_raw]
mem_usage = sum([x.memory for x in active_machines if x != machine])
- return min(MAX_MEMORY_SINGLE, MAX_MEMORY_TOTAL-mem_usage)
+ return min(quota_single, quota_total-mem_usage)
def maxDisk(owner, machine=None):
"""Return the maximum disk that a machine can reach.
def maxDisk(owner, machine=None):
"""Return the maximum disk that a machine can reach.