Changeset 2198
- Timestamp:
- Feb 27, 2009, 2:56:41 AM (16 years ago)
- Location:
- trunk/packages/invirt-database
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/invirt-database/debian/changelog
r2194 r2198 14 14 * refactor code that sets values 15 15 * print full help on no arguments 16 17 -- Greg Price <price@mit.edu> Thu, 26 Feb 2009 22:51:43 -0500 16 * make EIBTI imports 17 18 -- Greg Price <price@mit.edu> Fri, 27 Feb 2009 02:16:28 -0500 18 19 19 20 invirt-database (0.1.7) unstable; urgency=low -
trunk/packages/invirt-database/scripts/invirt-quota
r2194 r2198 7 7 """ 8 8 9 from invirt.database import * 10 from sys import argv, exit, stderr, stdout 11 from optparse import OptionParser 9 import sys 10 import optparse 11 12 from invirt import database 12 13 13 14 def main(argv): 14 parser = OptionParser(usage = '%prog <owner> [options]',15 parser = optparse.OptionParser(usage = '%prog <owner> [options]', 15 16 description = __doc__.strip()) 16 17 parser.add_option('-m', '--ram-total', … … 41 42 42 43 if len(args) != 1: 43 parser.print_help(s tderr)44 parser.print_help(sys.stderr) 44 45 return 1 45 46 owner = args[0] 46 connect()47 session.begin()47 database.connect() 48 database.session.begin() 48 49 49 x = Owner.query().filter_by(owner_id=owner).first()50 x = database.Owner.query().filter_by(owner_id=owner).first() 50 51 if x is None: 51 x = Owner(owner_id=owner)52 x = database.Owner(owner_id=owner) 52 53 53 54 for resource, scope in [('ram', 'total'), ('ram', 'single'), 54 55 ('disk', 'total'), ('disk', 'single'), 55 56 ('vms', 'total'), ('vms', 'active')]: 56 opt = getattr(opts, resource+scope) 57 if opt is not None: 58 val = int(opt) 57 val = getattr(opts, resource+scope) 58 if val is not None: 59 59 setattr(x, resource+'_quota_'+scope, val if val >= 0 else None) 60 60 61 session.commit()61 database.session.commit() 62 62 print str(x) 63 63 return 0 64 64 65 65 if __name__ == '__main__': 66 exit(main(argv))66 sys.exit(main(sys.argv))
Note: See TracChangeset
for help on using the changeset viewer.