RAM quotas at remctl; RAM quota exception script, table, and usage in -web and -remot...
authorPeter Iannucci <iannucci@mit.edu>
Tue, 17 Feb 2009 04:52:01 +0000 (23:52 -0500)
committerPeter Iannucci <iannucci@mit.edu>
Tue, 17 Feb 2009 04:52:01 +0000 (23:52 -0500)
svn path=/trunk/packages/invirt-web/; revision=2132

code/validation.py
debian/changelog

index 5f2a3ff..05e4c27 100644 (file)
@@ -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.
index f007ec3..d746e43 100644 (file)
@@ -1,3 +1,9 @@
+invirt-web (0.0.19) unstable; urgency=low
+
+  * modified quota checking to refer to invirt.database.Owner for quotas and defaults
+
+ -- Peter A. Iannucci <iannucci@mit.edu>  Mon, 16 Feb 2009 23:49:21 -0500
+
 invirt-web (0.0.18) unstable; urgency=low
 
   * depend on apache2, libapache2-mod-auth-sslcert, python-dnspython
 invirt-web (0.0.18) unstable; urgency=low
 
   * depend on apache2, libapache2-mod-auth-sslcert, python-dnspython