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, ram_quota_total=None, ram_quota_single=None,
56 disk_quota_total=None, disk_quota_single=None,
57 vms_quota_total=None, vms_quota_active)
59 if opts.memtotal != None:
60 total = int(opts.memtotal)
62 x.ram_quota_total = None
64 x.ram_quota_total = total
66 if opts.memsingle != None:
67 single = int(opts.memsingle)
69 x.ram_quota_single = None
71 x.ram_quota_single = single
73 if opts.disktotal != None:
74 total = int(opts.disktotal)
76 x.disk_quota_total = None
78 x.disk_quota_total = total
80 if opts.disksingle != None:
81 single = int(opts.disksingle)
83 x.disk_quota_single = None
85 x.disk_quota_single = single
87 if opts.vmstotal != None:
88 total = int(opts.vmstotal)
90 x.vms_quota_total = None
92 x.vms_quota_total = total
94 if opts.vmsactive != None:
95 active = int(opts.vmsactive)
97 x.vms_quota_active = None
99 x.vms_quota_active = active
105 if __name__ == '__main__':