Changeset 2194 for trunk/packages/invirt-database/scripts/invirt-quota
- Timestamp:
- Feb 27, 2009, 2:11:39 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/invirt-database/scripts/invirt-quota
r2176 r2194 5 5 for an owner. Invoking with only an owner name returns the current quotas for 6 6 that owner. Setting a parameter to -1 restores the default. 7 8 Examples:9 10 invirt-quota joeuser -mt 512 -ms -111 7 """ 12 8 … … 16 12 17 13 def main(argv): 18 parser = OptionParser(usage = '%prog owner[options]',19 description = __doc__.strip() .split('\n\n')[0])20 parser.add_option('-m', '-- mem-total',14 parser = OptionParser(usage = '%prog <owner> [options]', 15 description = __doc__.strip()) 16 parser.add_option('-m', '--ram-total', 21 17 type = 'int', 22 dest = ' memtotal',18 dest = 'ramtotal', 23 19 help = 'set total concurrent RAM quota') 24 parser.add_option('-n', '-- mem-single',20 parser.add_option('-n', '--ram-single', 25 21 type = 'int', 26 dest = ' memsingle',22 dest = 'ramsingle', 27 23 help = 'set single VM RAM quota') 28 24 parser.add_option('-d', '--disk-total', … … 45 41 46 42 if len(args) != 1: 47 p rint >> stderr, __doc__.strip()43 parser.print_help(stderr) 48 44 return 1 49 45 owner = args[0] … … 52 48 53 49 x = Owner.query().filter_by(owner_id=owner).first() 54 if x ==None:50 if x is None: 55 51 x = Owner(owner_id=owner) 56 52 57 if opts.memtotal != None: 58 total = int(opts.memtotal) 59 if total == -1: 60 x.ram_quota_total = None 61 else: 62 x.ram_quota_total = total 63 64 if opts.memsingle != None: 65 single = int(opts.memsingle) 66 if single == -1: 67 x.ram_quota_single = None 68 else: 69 x.ram_quota_single = single 70 71 if opts.disktotal != None: 72 total = int(opts.disktotal) 73 if total == -1: 74 x.disk_quota_total = None 75 else: 76 x.disk_quota_total = total 77 78 if opts.disksingle != None: 79 single = int(opts.disksingle) 80 if single == -1: 81 x.disk_quota_single = None 82 else: 83 x.disk_quota_single = single 84 85 if opts.vmstotal != None: 86 total = int(opts.vmstotal) 87 if total == -1: 88 x.vms_quota_total = None 89 else: 90 x.vms_quota_total = total 91 92 if opts.vmsactive != None: 93 active = int(opts.vmsactive) 94 if active == -1: 95 x.vms_quota_active = None 96 else: 97 x.vms_quota_active = active 53 for resource, scope in [('ram', 'total'), ('ram', 'single'), 54 ('disk', 'total'), ('disk', 'single'), 55 ('vms', 'total'), ('vms', 'active')]: 56 opt = getattr(opts, resource+scope) 57 if opt is not None: 58 val = int(opt) 59 setattr(x, resource+'_quota_'+scope, val if val >= 0 else None) 98 60 99 61 session.commit()
Note: See TracChangeset
for help on using the changeset viewer.