From: Peter Iannucci Date: Tue, 17 Feb 2009 06:54:26 +0000 (-0500) Subject: Added all the other quotas for great win. X-Git-Tag: 0.1.3~1 X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-database.git/commitdiff_plain/9cf145e794628fbc4bf11b663fa301404cb0759a Added all the other quotas for great win. svn path=/trunk/packages/invirt-database/; revision=2134 --- diff --git a/debian/changelog b/debian/changelog index 24d4a52..cdcccec 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,9 @@ invirt-database (0.1.3) unstable; urgency=low - * Added owner table with ram quotas. + * Added owner table to database with ram, disk, and VM quotas * Refactored Owner class into separate sourcefile - -- Peter A. Iannucci Mon, 16 Feb 2009 23:49:39 -0500 + -- Peter A. Iannucci Tue, 17 Feb 2009 01:31:53 -0500 invirt-database (0.1.2) unstable; urgency=low diff --git a/python/database/models.py b/python/database/models.py index 2944a1f..798934a 100644 --- a/python/database/models.py +++ b/python/database/models.py @@ -87,7 +87,11 @@ autoinstalls_table = Table('autoinstalls', meta, owners_table = Table('owners', meta, Column('owner_id', String, primary_key=True, nullable=False), Column('ram_quota_total', Integer, nullable=True), - Column('ram_quota_single', Integer, nullable=True)) + Column('ram_quota_single', Integer, nullable=True), + Column('disk_quota_total', Integer, nullable=True), + Column('disk_quota_single', Integer, nullable=True), + Column('vms_quota_total', Integer, nullable=True), + Column('vms_quota_active', Integer, nullable=True)) machine_access_table = Table('machine_access', meta, Column('machine_id', Integer, ForeignKey('machines.machine_id', ondelete='CASCADE'), nullable=False, index=True), diff --git a/python/database/owner.py b/python/database/owner.py index 59080bc..b40dea5 100755 --- a/python/database/owner.py +++ b/python/database/owner.py @@ -1,9 +1,16 @@ 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): + return """""" % (self.owner_id, self.ram_quota_total, self.ram_quota_single, self.disk_quota_total, self.disk_quota_single, self.vms_quota_total, self.vms_quota_active) + 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 +23,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_single = MAX_VMS_ACTIVE + return (quota_total, quota_active) + getVMQuotas = staticmethod(getVMQuotas)