[2132] | 1 | MAX_MEMORY_TOTAL = 512 |
---|
| 2 | MAX_MEMORY_SINGLE = 512 |
---|
[2134] | 3 | MAX_DISK_TOTAL = 50 |
---|
| 4 | MAX_DISK_SINGLE = 50 |
---|
| 5 | MAX_VMS_TOTAL = 10 |
---|
| 6 | MAX_VMS_ACTIVE = 4 |
---|
| 7 | |
---|
[2132] | 8 | class Owner(object): |
---|
| 9 | def __repr__(self): |
---|
[2143] | 10 | a = self.ram_quota_total |
---|
| 11 | b = self.ram_quota_single |
---|
| 12 | c = self.disk_quota_total |
---|
| 13 | d = self.disk_quota_single |
---|
| 14 | e = self.vms_quota_total |
---|
| 15 | f = self.vms_quota_active |
---|
| 16 | if not a: |
---|
| 17 | a = MAX_MEMORY_TOTAL |
---|
| 18 | if not b: |
---|
| 19 | b = MAX_MEMORY_SINGLE |
---|
| 20 | if not c: |
---|
| 21 | c = MAX_DISK_TOTAL |
---|
| 22 | if not d: |
---|
| 23 | d = MAX_DISK_SINGLE |
---|
| 24 | if not e: |
---|
| 25 | e = MAX_VMS_TOTAL |
---|
| 26 | if not f: |
---|
| 27 | f = MAX_VMS_ACTIVE |
---|
[2134] | 28 | return """<Owner %s: ram_quota_total=%s MB ram_quota_single=%s MB |
---|
[2155] | 29 | disk_quota_total=%s GB disk_quota_single=%s GB |
---|
[2143] | 30 | vms_quota_total=%s vms_quota_active=%s >""" % (self.owner_id, a,b,c,d,e,f) |
---|
[2134] | 31 | def getMemoryQuotas(owner): |
---|
[2132] | 32 | owner_info = Owner.query().filter_by(owner_id=owner).first() |
---|
| 33 | if owner_info != None: |
---|
| 34 | quota_total = owner_info.ram_quota_total |
---|
| 35 | if quota_total == None: |
---|
| 36 | quota_total = MAX_MEMORY_TOTAL |
---|
| 37 | quota_single = owner_info.ram_quota_single |
---|
| 38 | if quota_single == None: |
---|
| 39 | quota_single = MAX_MEMORY_SINGLE |
---|
| 40 | else: |
---|
| 41 | quota_total = MAX_MEMORY_TOTAL |
---|
| 42 | quota_single = MAX_MEMORY_SINGLE |
---|
| 43 | return (quota_total, quota_single) |
---|
[2134] | 44 | getMemoryQuotas = staticmethod(getMemoryQuotas) |
---|
| 45 | def getDiskQuotas(owner): |
---|
| 46 | owner_info = Owner.query().filter_by(owner_id=owner).first() |
---|
| 47 | if owner_info != None: |
---|
| 48 | quota_total = owner_info.disk_quota_total |
---|
| 49 | if quota_total == None: |
---|
| 50 | quota_total = MAX_DISK_TOTAL |
---|
| 51 | quota_single = owner_info.disk_quota_single |
---|
| 52 | if quota_single == None: |
---|
| 53 | quota_single = MAX_DISK_SINGLE |
---|
| 54 | else: |
---|
| 55 | quota_total = MAX_DISK_TOTAL |
---|
| 56 | quota_single = MAX_DISK_SINGLE |
---|
| 57 | return (quota_total, quota_single) |
---|
| 58 | getDiskQuotas = staticmethod(getDiskQuotas) |
---|
| 59 | def getVMQuotas(owner): |
---|
| 60 | owner_info = Owner.query().filter_by(owner_id=owner).first() |
---|
| 61 | if owner_info != None: |
---|
| 62 | quota_total = owner_info.vms_quota_total |
---|
| 63 | if quota_total == None: |
---|
| 64 | quota_total = MAX_VMS_TOTAL |
---|
| 65 | quota_active = owner_info.vms_quota_active |
---|
| 66 | if quota_active == None: |
---|
| 67 | quota_active = MAX_VMS_ACTIVE |
---|
| 68 | else: |
---|
| 69 | quota_total = MAX_VMS_TOTAL |
---|
[2142] | 70 | quota_active = MAX_VMS_ACTIVE |
---|
[2134] | 71 | return (quota_total, quota_active) |
---|
| 72 | getVMQuotas = staticmethod(getVMQuotas) |
---|