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/invirt-remote
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.