Ignore:
Timestamp:
Feb 27, 2009, 2:18:03 PM (16 years ago)
Author:
quentin
Message:

Fix get*Quotas

Location:
trunk/packages/invirt-database/python/database
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/invirt-database/python/database/models.py

    r2211 r2213  
    77
    88from invirt.database import record
    9 from invirt.database.owner import Owner
    109
    1110__all__ = ['meta',
     
    127126    _identity_field = 'autoinstall_id'
    128127
     128from invirt.database.owner import Owner
     129
    129130session.mapper(Machine, machine_table,
    130131              properties={'nics': relation(NIC, backref="machine"),
  • trunk/packages/invirt-database/python/database/owner.py

    r2200 r2213  
    11from invirt.database import record
     2from invirt.database.models import session
    23
    34class Owner(record.Record):
     
    1819    @classmethod
    1920    def getMemoryQuotas(cls, owner):
    20         owner_info = cls.query().filter_by(owner_id=owner).first()
     21        owner_info = cls.query().get(owner)
    2122        if owner_info == None:
    2223            owner_info = cls(owner_id=owner)
     24            session.expunge(owner_info)
    2325        return (owner_info.get('ram_quota_total'), owner_info.get('ram_quota_single'))
    2426
    2527    @classmethod
    2628    def getDiskQuotas(cls, owner):
    27         owner_info = cls.query().filter_by(owner_id=owner).first()
     29        owner_info = cls.query().get(owner)
    2830        if owner_info == None:
    2931            owner_info = cls(owner_id=owner)
     32            session.expunge(owner_info)
    3033        return (owner_info.get('disk_quota_total'), owner_info.get('disk_quota_single'))
    3134
    3235    @classmethod
    3336    def getVMQuotas(cls, owner):
    34         owner_info = cls.query().filter_by(owner_id=owner).first()
     37        owner_info = cls.query().get(owner)
    3538        if owner_info == None:
    3639            owner_info = cls(owner_id=owner)
     40            session.expunge(owner_info)
    3741        return (owner_info.get('vms_quota_total'), owner_info.get('vms_quota_active'))
Note: See TracChangeset for help on using the changeset viewer.