59080bc0c96b5135d14ffbe5ee61de8a879d6ecf
[invirt/packages/invirt-database.git] / python / database / owner.py
1 MAX_MEMORY_TOTAL = 512
2 MAX_MEMORY_SINGLE = 512
3 class Owner(object):
4     def __repr__(self):
5         return "<Owner %s: ram_quota_total=%s MB ram_quota_single=%s MB>" % (self.owner_id, self.ram_quota_total, self.ram_quota_single)
6     def getQuotas(owner):
7         owner_info = Owner.query().filter_by(owner_id=owner).first()
8         if owner_info != None:
9             quota_total = owner_info.ram_quota_total
10             if quota_total == None:
11                 quota_total = MAX_MEMORY_TOTAL
12             quota_single = owner_info.ram_quota_single
13             if quota_single == None:
14                 quota_single = MAX_MEMORY_SINGLE
15         else:
16             quota_total = MAX_MEMORY_TOTAL
17             quota_single = MAX_MEMORY_SINGLE
18         return (quota_total, quota_single)
19     getQuotas = staticmethod(getQuotas)