From: Evan Broder Date: Tue, 17 Feb 2009 08:45:26 +0000 (-0500) Subject: Move invirt-setquotas into invirt-database. X-Git-Tag: 0.0.24^0 X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-base.git/commitdiff_plain/17dff65c494a703eabfd5d56e80873698357251d?hp=9014d0616c6c4fe5f2e19b2a3889700cf70dd654 Move invirt-setquotas into invirt-database. While we're at it, clean up the mechanism to list scripts in a Python package. svn path=/trunk/packages/invirt-base/; revision=2151 --- diff --git a/debian/changelog b/debian/changelog index 3af50fa..e740ed2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +invirt-base (0.0.24) unstable; urgency=low + + * Move invirt-setquotas to invirt-database + * Glob together all scripts instead of listing them + + -- Evan Broder Tue, 17 Feb 2009 03:40:50 -0500 + invirt-base (0.0.23) unstable; urgency=low * another minor bugfix diff --git a/scripts/invirt-setquotas b/scripts/invirt-setquotas deleted file mode 100755 index ceae1bf..0000000 --- a/scripts/invirt-setquotas +++ /dev/null @@ -1,106 +0,0 @@ -#!/usr/bin/env python - -""" -invirt-setquota allows an administrator to set memory, disk, and VM 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 -mt 512 -ms -1 -""" - -from invirt.database import * -from sys import argv, exit, stderr, stdout -from optparse import OptionParser - -def main(argv): - parser = OptionParser(usage = '%prog owner [options]', - description = __doc__.strip().split('\n\n')[0]) - parser.add_option('-m', '--mem-total', - type = 'int', - dest = 'memtotal', - help = 'set total concurrent RAM quota') - parser.add_option('-n', '--mem-single', - type = 'int', - dest = 'memsingle', - help = 'set single VM RAM quota') - parser.add_option('-d', '--disk-total', - type = 'int', - dest = 'disktotal', - help = 'set total disk quota') - parser.add_option('-e', '--disk-single', - type = 'int', - dest = 'disksingle', - help = 'set single VM disk quota') - parser.add_option('-v', '--vms-total', - type = 'int', - dest = 'vmstotal', - help = 'set total VM quota') - parser.add_option('-w', '--vms-active', - type = 'int', - dest = 'vmsactive', - help = 'set active VM quota') - opts, args = parser.parse_args() - - if len(args) != 1: - print >> stderr, __doc__.strip() - return 1 - owner = args[0] - connect() - session.begin() - - x = Owner.query().filter_by(owner_id=owner).first() - if x == None: - x = Owner(owner_id=owner, ram_quota_total=None, ram_quota_single=None, - disk_quota_total=None, disk_quota_single=None, - vms_quota_total=None, vms_quota_active=None) - - if opts.memtotal != None: - total = int(opts.memtotal) - if total == -1: - x.ram_quota_total = None - else: - x.ram_quota_total = total - - if opts.memsingle != None: - single = int(opts.memsingle) - if single == -1: - x.ram_quota_single = None - else: - x.ram_quota_single = single - - if opts.disktotal != None: - total = int(opts.disktotal) - if total == -1: - x.disk_quota_total = None - else: - x.disk_quota_total = total - - if opts.disksingle != None: - single = int(opts.disksingle) - if single == -1: - x.disk_quota_single = None - else: - x.disk_quota_single = single - - if opts.vmstotal != None: - total = int(opts.vmstotal) - if total == -1: - x.vms_quota_total = None - else: - x.vms_quota_total = total - - if opts.vmsactive != None: - active = int(opts.vmsactive) - if active == -1: - x.vms_quota_active = None - else: - x.vms_quota_active = active - - session.commit() - print str(x) - return 0 - -if __name__ == '__main__': - exit(main(argv)) diff --git a/setup.py b/setup.py index f1ab03d..edb0ecc 100755 --- a/setup.py +++ b/setup.py @@ -4,6 +4,7 @@ from os import path from debian_bundle.changelog import Changelog from debian_bundle.deb822 import Deb822 from email.utils import parseaddr +from glob import glob from setuptools import setup version = Changelog(open(path.join(path.dirname(__file__), 'debian/changelog')).read()).\ @@ -20,5 +21,5 @@ setup( packages = ['invirt'], package_dir = {'': 'python'}, - scripts=['scripts/invirt-getconf', 'scripts/invirt-reload', 'scripts/invirt-setquotas'] + scripts=glob('scripts/*') )