From: Peter Iannucci Date: Tue, 17 Feb 2009 04:52:01 +0000 (-0500) Subject: RAM quotas at remctl; RAM quota exception script, table, and usage in -web and -remot... X-Git-Tag: 0.0.21~2 X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-base.git/commitdiff_plain/88c0269e83f71b56805408b58dfd191fe71c2329 RAM quotas at remctl; RAM quota exception script, table, and usage in -web and -remote-create; /etc/nocreate support svn path=/trunk/packages/invirt-base/; revision=2132 --- diff --git a/debian/changelog b/debian/changelog index 6210c79..a369b18 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +invirt-base (0.0.21) unstable; urgency=low + + * added invirt-setquota script (self-documenting) + + -- Peter A. Iannucci Mon, 16 Feb 2009 23:48:25 -0500 + invirt-base (0.0.20) unstable; urgency=low * depend on remctl-client diff --git a/scripts/invirt-setquota b/scripts/invirt-setquota new file mode 100755 index 0000000..45b49c3 --- /dev/null +++ b/scripts/invirt-setquota @@ -0,0 +1,67 @@ +#!/usr/bin/env python + +""" +invirt-setquota allows an administrator to set the RAM quotas for an owner. +Invoking with only an owner name returns the current quotas for that owner. +Setting a parameter to -1 restores the default. + +Examples: + + invirt-setquota joeuser -t 512 -s None +""" + +from invirt.database import * +from sys import argv, exit, stderr, stdout +from optparse import OptionParser + +class invirt_exception(Exception): pass + +def main(argv): + try: + parser = OptionParser(usage = '%prog owner [options]', + description = __doc__.strip().split('\n\n')[0]) + parser.add_option('-t', '--total', + type = 'int', + dest = 'total', + help = 'set the total concurrent RAM quota') + parser.add_option('-s', '--single', + type = 'int', + dest = 'single', + help = 'set the single VM RAM quota') + opts, args = parser.parse_args() + + if len(args) != 1: + raise invirt_exception(__doc__.strip()) + owner = args[0] + connect() + session.begin() + + x = Owner.query().filter_by(owner_id=owner).first() + + edited = False + if opts.total != None: + total = int(opts.total) + if total == -1: + x.ram_quota_total = None + else: + x.ram_quota_total = total + edited = True + + if opts.single != None: + single = int(opts.single) + if single == -1: + x.ram_quota_single = None + else: + x.ram_quota_single = single + edited = True + + if edited: + session.commit() + print str(x) + + except invirt_exception, ex: + print >> stderr, ex + return 1 + +if __name__ == '__main__': + exit(main(argv))