Ignore:
Timestamp:
Feb 17, 2009, 1:54:26 AM (16 years ago)
Author:
iannucci
Message:

Added all the other quotas for great win.

Location:
trunk/packages/invirt-database
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/invirt-database/debian/changelog

    r2132 r2134  
    11invirt-database (0.1.3) unstable; urgency=low
    22
    3   * Added owner table with ram quotas.
     3  * Added owner table to database with ram, disk, and VM quotas
    44  * Refactored Owner class into separate sourcefile
    55
    6  -- Peter A. Iannucci <iannucci@mit.edu>  Mon, 16 Feb 2009 23:49:39 -0500
     6 -- Peter A. Iannucci <iannucci@mit.edu>  Tue, 17 Feb 2009 01:31:53 -0500
    77
    88invirt-database (0.1.2) unstable; urgency=low
  • trunk/packages/invirt-database/python/database/models.py

    r2132 r2134  
    8888       Column('owner_id', String, primary_key=True, nullable=False),
    8989       Column('ram_quota_total', Integer, nullable=True),
    90        Column('ram_quota_single', Integer, nullable=True))
     90       Column('ram_quota_single', Integer, nullable=True),
     91       Column('disk_quota_total', Integer, nullable=True),
     92       Column('disk_quota_single', Integer, nullable=True),
     93       Column('vms_quota_total', Integer, nullable=True),
     94       Column('vms_quota_active', Integer, nullable=True))
    9195
    9296machine_access_table = Table('machine_access', meta,
  • trunk/packages/invirt-database/python/database/owner.py

    r2132 r2134  
    11MAX_MEMORY_TOTAL = 512
    22MAX_MEMORY_SINGLE = 512
     3MAX_DISK_TOTAL = 50
     4MAX_DISK_SINGLE = 50
     5MAX_VMS_TOTAL = 10
     6MAX_VMS_ACTIVE = 4
     7
    38class Owner(object):
    49    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):
     10        return """<Owner %s: ram_quota_total=%s MB ram_quota_single=%s MB
     11disk_quota_total=%s MB disk_quota_single=%s MB
     12vms_quota_total=%s vms_quota_active=%s >""" % (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)
     13    def getMemoryQuotas(owner):
    714        owner_info = Owner.query().filter_by(owner_id=owner).first()
    815        if owner_info != None:
     
    1724            quota_single = MAX_MEMORY_SINGLE
    1825        return (quota_total, quota_single)
    19     getQuotas = staticmethod(getQuotas)
     26    getMemoryQuotas = staticmethod(getMemoryQuotas)
     27    def getDiskQuotas(owner):
     28        owner_info = Owner.query().filter_by(owner_id=owner).first()
     29        if owner_info != None:
     30            quota_total = owner_info.disk_quota_total
     31            if quota_total == None:
     32                quota_total = MAX_DISK_TOTAL
     33            quota_single = owner_info.disk_quota_single
     34            if quota_single == None:
     35                quota_single = MAX_DISK_SINGLE
     36        else:
     37            quota_total = MAX_DISK_TOTAL
     38            quota_single = MAX_DISK_SINGLE
     39        return (quota_total, quota_single)
     40    getDiskQuotas = staticmethod(getDiskQuotas)
     41    def getVMQuotas(owner):
     42        owner_info = Owner.query().filter_by(owner_id=owner).first()
     43        if owner_info != None:
     44            quota_total = owner_info.vms_quota_total
     45            if quota_total == None:
     46                quota_total = MAX_VMS_TOTAL
     47            quota_active = owner_info.vms_quota_active
     48            if quota_active == None:
     49                quota_active = MAX_VMS_ACTIVE
     50        else:
     51            quota_total = MAX_VMS_TOTAL
     52            quota_single = MAX_VMS_ACTIVE
     53        return (quota_total, quota_active)
     54    getVMQuotas = staticmethod(getVMQuotas)
Note: See TracChangeset for help on using the changeset viewer.