Changeset 2132 for trunk/packages/invirt-remote
- Timestamp:
- Feb 16, 2009, 11:52:01 PM (16 years ago)
- Location:
- trunk/packages/invirt-remote
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/invirt-remote/debian/changelog
r2113 r2132 2 2 3 3 * 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 5 5 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 8 10 9 11 invirt-remote (0.3.3) unstable; urgency=low -
trunk/packages/invirt-remote/server/usr/sbin/invirt-remote-create
r2106 r2132 13 13 import sys 14 14 import yaml 15 import invirt.database 16 17 def 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) 15 27 16 28 def choose_host(): … … 50 62 return 1 51 63 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 52 76 host = choose_host() 53 77 print 'Creating on host %s...' % host
Note: See TracChangeset
for help on using the changeset viewer.