Changeset 2132 for trunk


Ignore:
Timestamp:
Feb 16, 2009, 11:52:01 PM (16 years ago)
Author:
iannucci
Message:

RAM quotas at remctl; RAM quota exception script, table, and usage in -web and -remote-create; /etc/nocreate support

Location:
trunk/packages
Files:
2 added
7 edited

Legend:

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

    r2097 r2132  
     1invirt-base (0.0.21) unstable; urgency=low
     2
     3  * added invirt-setquota script (self-documenting)
     4
     5 -- Peter A. Iannucci <iannucci@mit.edu>  Mon, 16 Feb 2009 23:48:25 -0500
     6
    17invirt-base (0.0.20) unstable; urgency=low
    28
  • trunk/packages/invirt-database/debian/changelog

    r1962 r2132  
     1invirt-database (0.1.3) unstable; urgency=low
     2
     3  * Added owner table with ram quotas.
     4  * Refactored Owner class into separate sourcefile
     5
     6 -- Peter A. Iannucci <iannucci@mit.edu>  Mon, 16 Feb 2009 23:49:39 -0500
     7
    18invirt-database (0.1.2) unstable; urgency=low
    29
  • trunk/packages/invirt-database/python/database/models.py

    r1714 r2132  
    1717           'mirrors_table',
    1818           'autoinstalls_table',
     19           'owners_table',
    1920           'Machine',
    2021           'MachineAccess',
     
    2526           'Mirror',
    2627           'Autoinstall',
     28           'Owner',
    2729           'or_',
    2830           ]
     
    8385       Column('arch', String, nullable=False))
    8486
     87owners_table = Table('owners', meta,
     88       Column('owner_id', String, primary_key=True, nullable=False),
     89       Column('ram_quota_total', Integer, nullable=True),
     90       Column('ram_quota_single', Integer, nullable=True))
     91
    8592machine_access_table = Table('machine_access', meta,
    8693       Column('machine_id', Integer, ForeignKey('machines.machine_id', ondelete='CASCADE'), nullable=False, index=True),
     
    120127        return "<Autoinstall %s: %s (%s)>" % (self.autoinstall_id, self.description, self.type.type_id)
    121128
     129from owner import Owner
     130
    122131session.mapper(Machine, machine_table,
    123132              properties={'nics': relation(NIC, backref="machine"),
     
    133142               properties={'mirror': relation(Mirror, backref="cdroms")})
    134143session.mapper(Autoinstall, autoinstalls_table)
     144session.mapper(Owner, owners_table)
    135145
    136146def clear_cache():
  • trunk/packages/invirt-remote/debian/changelog

    r2113 r2132  
    22
    33  * modified host/usr/sbin/invirt-availability and invirt-vmcontrol to stat
    4     /etc/invirt/nocreate; if it exists, they advertise zero free memory and 
     4    /etc/invirt/nocreate; if it exists, they advertise zero free memory and
    55    refuse to create VMs
    6 
    7  -- Peter A. Iannucci <iannucci@mit.edu>  Sat, 14 Feb 2009 18:10:54 -0500
     6  * added memory quota validation to invirt-remote-create
     7  * added owner table to database with ram_quota_total and ram_quota_single
     8
     9 -- Peter A. Iannucci <iannucci@mit.edu>  Mon, 16 Feb 2009 23:49:14 -0500
    810
    911invirt-remote (0.3.3) unstable; urgency=low
  • trunk/packages/invirt-remote/server/usr/sbin/invirt-remote-create

    r2106 r2132  
    1313import sys
    1414import yaml
     15import invirt.database
     16
     17def maxMemory(owner, xmlist):
     18    """
     19    Return the memory available for a new machine.
     20    """
     21    machines = invirt.database.Machine.query().filter_by(owner=owner)
     22    (quota_total, quota_single) = invirt.database.Owner.getQuotas(owner)
     23
     24    active_machines = [m for m in machines if m.name in xmlist]
     25    mem_usage = sum([x.memory for x in active_machines])
     26    return min(quota_single, quota_total-mem_usage)
    1527
    1628def choose_host():
     
    5062        return 1
    5163
     64    if operation == "create":
     65        invirt.database.connect()
     66        machine = invirt.database.Machine.query().filter_by(name=machine_name).first()
     67
     68        owner = machine.owner
     69        vm_memory = machine.memory
     70
     71        max_memory = maxMemory(owner, vms.keys())
     72        if vm_memory > max_memory:
     73            print >>sys.stderr, "owner %s requested %d MB of memory for vm %s; %d MB allowed" % (owner, vm_memory, machine_name, max_memory)
     74            return 1
     75
    5276    host = choose_host()
    5377    print 'Creating on host %s...' % host
  • trunk/packages/invirt-web/code/validation.py

    r2064 r2132  
    66import string
    77import dns.resolver
    8 from invirt.database import Machine, NIC, Type, Disk, CDROM, Autoinstall
     8from invirt.database import Machine, NIC, Type, Disk, CDROM, Autoinstall, Owner
    99from invirt.config import structs as config
    1010from invirt.common import InvalidInput, CodeError
    1111
    12 MAX_MEMORY_TOTAL = 512
    13 MAX_MEMORY_SINGLE = 512
    1412MIN_MEMORY_SINGLE = 16
    1513MAX_DISK_TOTAL = 50
     
    9290    returned.
    9391    """
    94     if machine is not None and machine.memory > MAX_MEMORY_SINGLE:
    95         # If they've been blessed, let them have it
    96         return machine.memory
     92    (quota_total, quota_single) = Owner.getQuotas(machine.owner if machine else owner)
     93
    9794    if not on:
    98         return MAX_MEMORY_SINGLE
     95        return quota_single
    9996    machines = getMachinesByOwner(owner, machine)
    10097    active_machines = [m for m in machines if m.name in g.xmlist_raw]
    10198    mem_usage = sum([x.memory for x in active_machines if x != machine])
    102     return min(MAX_MEMORY_SINGLE, MAX_MEMORY_TOTAL-mem_usage)
     99    return min(quota_single, quota_total-mem_usage)
    103100
    104101def maxDisk(owner, machine=None):
  • trunk/packages/invirt-web/debian/changelog

    r2063 r2132  
     1invirt-web (0.0.19) unstable; urgency=low
     2
     3  * modified quota checking to refer to invirt.database.Owner for quotas and defaults
     4
     5 -- Peter A. Iannucci <iannucci@mit.edu>  Mon, 16 Feb 2009 23:49:21 -0500
     6
    17invirt-web (0.0.18) unstable; urgency=low
    28
Note: See TracChangeset for help on using the changeset viewer.