RAM quotas at remctl; RAM quota exception script, table, and usage in -web and -remot...
[invirt/packages/invirt-database.git] / python / database / owner.py
diff --git a/python/database/owner.py b/python/database/owner.py
new file mode 100755 (executable)
index 0000000..59080bc
--- /dev/null
@@ -0,0 +1,19 @@
+MAX_MEMORY_TOTAL = 512
+MAX_MEMORY_SINGLE = 512
+class Owner(object):
+    def __repr__(self):
+        return "<Owner %s: ram_quota_total=%s MB ram_quota_single=%s MB>" % (self.owner_id, self.ram_quota_total, self.ram_quota_single)
+    def getQuotas(owner):
+        owner_info = Owner.query().filter_by(owner_id=owner).first()
+        if owner_info != None:
+            quota_total = owner_info.ram_quota_total
+            if quota_total == None:
+                quota_total = MAX_MEMORY_TOTAL
+            quota_single = owner_info.ram_quota_single
+            if quota_single == None:
+                quota_single = MAX_MEMORY_SINGLE
+        else:
+            quota_total = MAX_MEMORY_TOTAL
+            quota_single = MAX_MEMORY_SINGLE
+        return (quota_total, quota_single)
+    getQuotas = staticmethod(getQuotas)