projects
/
invirt/packages/invirt-database.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Allow all users to write to the postgres temp directory
[invirt/packages/invirt-database.git]
/
python
/
database
/
owner.py
diff --git
a/python/database/owner.py
b/python/database/owner.py
index
adb176c
..
ac8ecfd
100755
(executable)
--- a/
python/database/owner.py
+++ b/
python/database/owner.py
@@
-1,6
+1,7
@@
-from record import NullableRecord
+from invirt.database import record
+from invirt.database.models import session
-class Owner(NullableRecord):
+class Owner(record.Record):
_f = {
'ram_quota_total': (512, 'MiB'),
'ram_quota_single': (512, 'MiB'),
_f = {
'ram_quota_total': (512, 'MiB'),
'ram_quota_single': (512, 'MiB'),
@@
-15,26
+16,26
@@
class Owner(NullableRecord):
_format = dict([(_k,_unitFormatter(_v[1])) for _k,_v in _f.items()])
_identity_field = 'owner_id'
_format = dict([(_k,_unitFormatter(_v[1])) for _k,_v in _f.items()])
_identity_field = 'owner_id'
- def getMemoryQuotas(owner):
- owner_info = Owner.query().filter_by(owner_id=owner).first()
+ @classmethod
+ def getMemoryQuotas(cls, owner):
+ owner_info = cls.query().get(owner)
if owner_info == None:
if owner_info == None:
- owner_info = Owner(owner_id=owner)
+ owner_info = cls(owner_id=owner)
+ session.expunge(owner_info)
return (owner_info.get('ram_quota_total'), owner_info.get('ram_quota_single'))
return (owner_info.get('ram_quota_total'), owner_info.get('ram_quota_single'))
- getMemoryQuotas = staticmethod(getMemoryQuotas)
- def getDiskQuotas(owner):
- owner_info = Owner.query().filter_by(owner_id=owner).first()
+ @classmethod
+ def getDiskQuotas(cls, owner):
+ owner_info = cls.query().get(owner)
if owner_info == None:
if owner_info == None:
- owner_info = Owner(owner_id=owner)
+ owner_info = cls(owner_id=owner)
+ session.expunge(owner_info)
return (owner_info.get('disk_quota_total'), owner_info.get('disk_quota_single'))
return (owner_info.get('disk_quota_total'), owner_info.get('disk_quota_single'))
- getDiskQuotas = staticmethod(getDiskQuotas)
- def getVMQuotas(owner):
- owner_info = Owner.query().filter_by(owner_id=owner).first()
+ @classmethod
+ def getVMQuotas(cls, owner):
+ owner_info = cls.query().get(owner)
if owner_info == None:
if owner_info == None:
- owner_info = Owner(owner_id=owner)
+ owner_info = cls(owner_id=owner)
+ session.expunge(owner_info)
return (owner_info.get('vms_quota_total'), owner_info.get('vms_quota_active'))
return (owner_info.get('vms_quota_total'), owner_info.get('vms_quota_active'))
- getVMQuotas = staticmethod(getVMQuotas)
-
- def _ignore(self):
- return super(Owner, self)._ignore() + ['getMemoryQuotas', 'getDiskQuotas', 'getVMQuotas']