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.
10 invirt-setquota joeuser -mt 512 -ms -1
13 from invirt.database import *
14 from sys import argv, exit, stderr, stdout
15 from optparse import OptionParser
18 parser = OptionParser(usage = '%prog owner [options]',
19 description = __doc__.strip().split('\n\n')[0])
20 parser.add_option('-m', '--mem-total',
23 help = 'set total concurrent RAM quota')
24 parser.add_option('-n', '--mem-single',
27 help = 'set single VM RAM quota')
28 parser.add_option('-d', '--disk-total',
31 help = 'set total disk quota')
32 parser.add_option('-e', '--disk-single',
35 help = 'set single VM disk quota')
36 parser.add_option('-v', '--vms-total',
39 help = 'set total VM quota')
40 parser.add_option('-w', '--vms-active',
43 help = 'set active VM quota')
44 opts, args = parser.parse_args()
47 print >> stderr, __doc__.strip()
53 x = Owner.query().filter_by(owner_id=owner).first()
55 x = Owner(owner_id=owner)
57 if opts.memtotal != None:
58 total = int(opts.memtotal)
60 x.ram_quota_total = None
62 x.ram_quota_total = total
64 if opts.memsingle != None:
65 single = int(opts.memsingle)
67 x.ram_quota_single = None
69 x.ram_quota_single = single
71 if opts.disktotal != None:
72 total = int(opts.disktotal)
74 x.disk_quota_total = None
76 x.disk_quota_total = total
78 if opts.disksingle != None:
79 single = int(opts.disksingle)
81 x.disk_quota_single = None
83 x.disk_quota_single = single
85 if opts.vmstotal != None:
86 total = int(opts.vmstotal)
88 x.vms_quota_total = None
90 x.vms_quota_total = total
92 if opts.vmsactive != None:
93 active = int(opts.vmsactive)
95 x.vms_quota_active = None
97 x.vms_quota_active = active
103 if __name__ == '__main__':