Added all the other quotas for great win.
authorPeter Iannucci <iannucci@mit.edu>
Tue, 17 Feb 2009 06:54:26 +0000 (01:54 -0500)
committerPeter Iannucci <iannucci@mit.edu>
Tue, 17 Feb 2009 06:54:26 +0000 (01:54 -0500)
svn path=/trunk/packages/invirt-base/; revision=2134

debian/changelog
scripts/invirt-setquota [deleted file]
scripts/invirt-setquotas [new file with mode: 0755]

index a369b18..c59f73f 100644 (file)
@@ -2,7 +2,7 @@ invirt-base (0.0.21) unstable; urgency=low
 
   * added invirt-setquota script (self-documenting)
 
- -- Peter A. Iannucci <iannucci@mit.edu>  Mon, 16 Feb 2009 23:48:25 -0500
+ -- Peter A. Iannucci <iannucci@mit.edu>  Tue, 17 Feb 2009 01:43:54 -0500
 
 invirt-base (0.0.20) unstable; urgency=low
 
diff --git a/scripts/invirt-setquota b/scripts/invirt-setquota
deleted file mode 100755 (executable)
index 45b49c3..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/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))
diff --git a/scripts/invirt-setquotas b/scripts/invirt-setquotas
new file mode 100755 (executable)
index 0000000..af33eec
--- /dev/null
@@ -0,0 +1,116 @@
+#!/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 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('-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()
+
+        print opts
+        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.memtotal != None:
+            total = int(opts.memtotal)
+            if total == -1:
+                x.ram_quota_total = None
+            else:
+                x.ram_quota_total = total
+            edited = True
+
+        if opts.memsingle != None:
+            single = int(opts.memsingle)
+            if single == -1:
+                x.ram_quota_single = None
+            else:
+                x.ram_quota_single = single
+            edited = True
+
+        if opts.disktotal != None:
+            total = int(opts.disktotal)
+            if total == -1:
+                x.disk_quota_total = None
+            else:
+                x.disk_quota_total = total
+            edited = True
+
+        if opts.disksingle != None:
+            single = int(opts.disksingle)
+            if single == -1:
+                x.disk_quota_single = None
+            else:
+                x.disk_quota_single = single
+            edited = True
+
+        if opts.vmstotal != None:
+            total = int(opts.vmstotal)
+            if total == -1:
+                x.vms_quota_total = None
+            else:
+                x.vms_quota_total = total
+            edited = True
+
+        if opts.vmsactive != None:
+            active = int(opts.vmsactive)
+            if active == -1:
+                x.vms_quota_active = None
+            else:
+                x.vms_quota_active = active
+            edited = True
+
+        if edited:
+            session.commit()
+        print str(x)
+
+    except invirt_exception, ex:
+        print >> stderr, ex
+        return 1
+
+if __name__ == '__main__':
+    exit(main(argv))