Changeset 2134
- Timestamp:
- Feb 17, 2009, 1:54:26 AM (16 years ago)
- Location:
- trunk/packages
- Files:
-
- 8 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/invirt-base/debian/changelog
r2132 r2134 3 3 * added invirt-setquota script (self-documenting) 4 4 5 -- Peter A. Iannucci <iannucci@mit.edu> Mon, 16 Feb 2009 23:48:25-05005 -- Peter A. Iannucci <iannucci@mit.edu> Tue, 17 Feb 2009 01:43:54 -0500 6 6 7 7 invirt-base (0.0.20) unstable; urgency=low -
trunk/packages/invirt-base/scripts/invirt-setquotas
r2132 r2134 2 2 3 3 """ 4 invirt-setquota allows an administrator to set the RAM quotas for an owner.5 Invoking with only an owner name returns the current quotas for that owner. 6 Setting a parameter to -1 restores the default.4 invirt-setquota allows an administrator to set memory, disk, and VM quotas 5 for an owner. Invoking with only an owner name returns the current quotas for 6 that owner. Setting a parameter to -1 restores the default. 7 7 8 8 Examples: 9 9 10 invirt-setquota joeuser - t 512 -s None10 invirt-setquota joeuser -mt 512 -ms None 11 11 """ 12 12 … … 21 21 parser = OptionParser(usage = '%prog owner [options]', 22 22 description = __doc__.strip().split('\n\n')[0]) 23 parser.add_option('- t', '--total',23 parser.add_option('-m', '--mem-total', 24 24 type = 'int', 25 dest = ' total',26 help = 'set t he total concurrent RAM quota')27 parser.add_option('- s', '--single',25 dest = 'memtotal', 26 help = 'set total concurrent RAM quota') 27 parser.add_option('-n', '--mem-single', 28 28 type = 'int', 29 dest = 'single', 30 help = 'set the single VM RAM quota') 29 dest = 'memsingle', 30 help = 'set single VM RAM quota') 31 parser.add_option('-d', '--disk-total', 32 type = 'int', 33 dest = 'disktotal', 34 help = 'set total disk quota') 35 parser.add_option('-e', '--disk-single', 36 type = 'int', 37 dest = 'disksingle', 38 help = 'set single VM disk quota') 39 parser.add_option('-v', '--vms-total', 40 type = 'int', 41 dest = 'vmstotal', 42 help = 'set total VM quota') 43 parser.add_option('-w', '--vms-active', 44 type = 'int', 45 dest = 'vmsactive', 46 help = 'set active VM quota') 31 47 opts, args = parser.parse_args() 32 48 49 print opts 33 50 if len(args) != 1: 34 51 raise invirt_exception(__doc__.strip()) … … 40 57 41 58 edited = False 42 if opts. total != None:43 total = int(opts. total)59 if opts.memtotal != None: 60 total = int(opts.memtotal) 44 61 if total == -1: 45 62 x.ram_quota_total = None … … 48 65 edited = True 49 66 50 if opts. single != None:51 single = int(opts. single)67 if opts.memsingle != None: 68 single = int(opts.memsingle) 52 69 if single == -1: 53 70 x.ram_quota_single = None 54 71 else: 55 72 x.ram_quota_single = single 73 edited = True 74 75 if opts.disktotal != None: 76 total = int(opts.disktotal) 77 if total == -1: 78 x.disk_quota_total = None 79 else: 80 x.disk_quota_total = total 81 edited = True 82 83 if opts.disksingle != None: 84 single = int(opts.disksingle) 85 if single == -1: 86 x.disk_quota_single = None 87 else: 88 x.disk_quota_single = single 89 edited = True 90 91 if opts.vmstotal != None: 92 total = int(opts.vmstotal) 93 if total == -1: 94 x.vms_quota_total = None 95 else: 96 x.vms_quota_total = total 97 edited = True 98 99 if opts.vmsactive != None: 100 active = int(opts.vmsactive) 101 if active == -1: 102 x.vms_quota_active = None 103 else: 104 x.vms_quota_active = active 56 105 edited = True 57 106 -
trunk/packages/invirt-database/debian/changelog
r2132 r2134 1 1 invirt-database (0.1.3) unstable; urgency=low 2 2 3 * Added owner table with ram quotas.3 * Added owner table to database with ram, disk, and VM quotas 4 4 * Refactored Owner class into separate sourcefile 5 5 6 -- Peter A. Iannucci <iannucci@mit.edu> Mon, 16 Feb 2009 23:49:39-05006 -- Peter A. Iannucci <iannucci@mit.edu> Tue, 17 Feb 2009 01:31:53 -0500 7 7 8 8 invirt-database (0.1.2) unstable; urgency=low -
trunk/packages/invirt-database/python/database/models.py
r2132 r2134 88 88 Column('owner_id', String, primary_key=True, nullable=False), 89 89 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)) 91 95 92 96 machine_access_table = Table('machine_access', meta, -
trunk/packages/invirt-database/python/database/owner.py
r2132 r2134 1 1 MAX_MEMORY_TOTAL = 512 2 2 MAX_MEMORY_SINGLE = 512 3 MAX_DISK_TOTAL = 50 4 MAX_DISK_SINGLE = 50 5 MAX_VMS_TOTAL = 10 6 MAX_VMS_ACTIVE = 4 7 3 8 class Owner(object): 4 9 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 11 disk_quota_total=%s MB disk_quota_single=%s MB 12 vms_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): 7 14 owner_info = Owner.query().filter_by(owner_id=owner).first() 8 15 if owner_info != None: … … 17 24 quota_single = MAX_MEMORY_SINGLE 18 25 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) -
trunk/packages/invirt-remote/debian/changelog
r2132 r2134 5 5 refuse to create VMs 6 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 7 8 -- Peter A. Iannucci <iannucci@mit.edu> Tue, 17 Feb 2009 01:31:20 -0500 10 9 11 10 invirt-remote (0.3.3) unstable; urgency=low -
trunk/packages/invirt-remote/server/usr/sbin/invirt-remote-create
r2132 r2134 20 20 """ 21 21 machines = invirt.database.Machine.query().filter_by(owner=owner) 22 (quota_total, quota_single) = invirt.database.Owner.get Quotas(owner)22 (quota_total, quota_single) = invirt.database.Owner.getMemoryQuotas(owner) 23 23 24 24 active_machines = [m for m in machines if m.name in xmlist] -
trunk/packages/invirt-web/code/validation.py
r2132 r2134 11 11 12 12 MIN_MEMORY_SINGLE = 16 13 MAX_DISK_TOTAL = 5014 MAX_DISK_SINGLE = 5015 13 MIN_DISK_SINGLE = 0.1 16 MAX_VMS_TOTAL = 1017 MAX_VMS_ACTIVE = 418 14 19 15 class Validate: … … 90 86 returned. 91 87 """ 92 (quota_total, quota_single) = Owner.get Quotas(machine.owner if machine else owner)88 (quota_total, quota_single) = Owner.getMemoryQuotas(machine.owner if machine else owner) 93 89 94 90 if not on: … … 105 101 return the maximum that a given machine can be changed to. 106 102 """ 103 (quota_total, quota_single) = Owner.getDiskQuotas(machine.owner if machine else owner) 104 107 105 if machine is not None: 108 106 machine_id = machine.machine_id … … 112 110 join('machine').\ 113 111 filter_by(owner=owner).sum(Disk.c.size) or 0 114 return min( MAX_DISK_SINGLE, MAX_DISK_TOTAL-disk_usage/1024.)112 return min(quota_single, quota_total-disk_usage/1024.) 115 113 116 114 def cantAddVm(owner, g): 117 115 machines = getMachinesByOwner(owner) 118 116 active_machines = [m for m in machines if m.name in g.xmlist_raw] 119 if machines.count() >= MAX_VMS_TOTAL: 117 (quota_total, quota_active) = Owner.getVMQuotas(machine.owner if machine else owner) 118 if machines.count() >= quota_total: 120 119 return 'You have too many VMs to create a new one.' 121 if len(active_machines) >= MAX_VMS_ACTIVE:120 if len(active_machines) >= quota_active: 122 121 return ('You already have the maximum number of VMs turned on. ' 123 122 'To create more, turn one off.') -
trunk/packages/invirt-web/debian/changelog
r2132 r2134 3 3 * modified quota checking to refer to invirt.database.Owner for quotas and defaults 4 4 5 -- Peter A. Iannucci <iannucci@mit.edu> Mon, 16 Feb 2009 23:49:21 -05005 -- Peter A. Iannucci <iannucci@mit.edu> Tue, 17 Feb 2009 01:31:01 -0500 6 6 7 7 invirt-web (0.0.18) unstable; urgency=low
Note: See TracChangeset
for help on using the changeset viewer.