X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-database.git/blobdiff_plain/fe334bb175017b9c5988159652718e29dafe83cd..abf474c8d08537a4ce66068b0bfbd5639391efcb:/python/database/owner.py diff --git a/python/database/owner.py b/python/database/owner.py index 59080bc..196bd85 100755 --- a/python/database/owner.py +++ b/python/database/owner.py @@ -1,9 +1,34 @@ MAX_MEMORY_TOTAL = 512 MAX_MEMORY_SINGLE = 512 +MAX_DISK_TOTAL = 50 +MAX_DISK_SINGLE = 50 +MAX_VMS_TOTAL = 10 +MAX_VMS_ACTIVE = 4 + class Owner(object): def __repr__(self): - return "" % (self.owner_id, self.ram_quota_total, self.ram_quota_single) - def getQuotas(owner): + a = self.ram_quota_total + b = self.ram_quota_single + c = self.disk_quota_total + d = self.disk_quota_single + e = self.vms_quota_total + f = self.vms_quota_active + if not a: + a = MAX_MEMORY_TOTAL + if not b: + b = MAX_MEMORY_SINGLE + if not c: + c = MAX_DISK_TOTAL + if not d: + d = MAX_DISK_SINGLE + if not e: + e = MAX_VMS_TOTAL + if not f: + f = MAX_VMS_ACTIVE + return """""" % (self.owner_id, a,b,c,d,e,f) + def getMemoryQuotas(owner): owner_info = Owner.query().filter_by(owner_id=owner).first() if owner_info != None: quota_total = owner_info.ram_quota_total @@ -16,4 +41,32 @@ class Owner(object): quota_total = MAX_MEMORY_TOTAL quota_single = MAX_MEMORY_SINGLE return (quota_total, quota_single) - getQuotas = staticmethod(getQuotas) + getMemoryQuotas = staticmethod(getMemoryQuotas) + def getDiskQuotas(owner): + owner_info = Owner.query().filter_by(owner_id=owner).first() + if owner_info != None: + quota_total = owner_info.disk_quota_total + if quota_total == None: + quota_total = MAX_DISK_TOTAL + quota_single = owner_info.disk_quota_single + if quota_single == None: + quota_single = MAX_DISK_SINGLE + else: + quota_total = MAX_DISK_TOTAL + quota_single = MAX_DISK_SINGLE + return (quota_total, quota_single) + getDiskQuotas = staticmethod(getDiskQuotas) + def getVMQuotas(owner): + owner_info = Owner.query().filter_by(owner_id=owner).first() + if owner_info != None: + quota_total = owner_info.vms_quota_total + if quota_total == None: + quota_total = MAX_VMS_TOTAL + quota_active = owner_info.vms_quota_active + if quota_active == None: + quota_active = MAX_VMS_ACTIVE + else: + quota_total = MAX_VMS_TOTAL + quota_active = MAX_VMS_ACTIVE + return (quota_total, quota_active) + getVMQuotas = staticmethod(getVMQuotas)