From: Greg Price <price@mit.edu>
Date: Thu, 29 Oct 2009 04:52:59 +0000 (-0400)
Subject: Style fixes in, and Debian changelog for, list and listuser.
X-Git-Tag: 0.4.4^0
X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-remote.git/commitdiff_plain/a1a2e0da2263c28d59bc76741e0ccd0bbc3f082c

Style fixes in, and Debian changelog for, list and listuser.

svn path=/trunk/packages/invirt-remote/; revision=2516
---

diff --git a/debian/changelog b/debian/changelog
index db16eff..7915caa 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+invirt-remote (0.4.4) unstable; urgency=low
+
+  [Paul Weaver]
+  * Add methods "listuser", "list" to list the VMs belonging to a
+    specified user or the requesting user.
+
+ -- Greg Price <price@mit.edu>  Thu, 29 Oct 2009 00:51:58 -0400
+
 invirt-remote (0.4.3) unstable; urgency=low
 
   * Minor cleanup of 0.4.2
diff --git a/server/usr/sbin/invirt-remote-list b/server/usr/sbin/invirt-remote-list
index 40a90ea..04bfaf2 100755
--- a/server/usr/sbin/invirt-remote-list
+++ b/server/usr/sbin/invirt-remote-list
@@ -1,25 +1,25 @@
 #!/usr/bin/python
 """
-Returns a user's list of vm's
+Lists the VMs belonging to the remote user.
 """
 
 from subprocess import PIPE, Popen, call
 import sys
 import os
-import yaml
+
 
 def main(argv):
     if len(argv) < 1:
-        print >>sys.stderr, "usage: invirt-remote-list "
+        print >>sys.stderr, "usage: invirt-remote-list"
         return 2
-    username = os.environ['REMUSER'].rsplit('@ATHENA.MIT.EDU')[0]
+
+    username = os.environ['REMOTE_USER'].rsplit('@ATHENA.MIT.EDU')[0]
     p = Popen(['/usr/sbin/invirt-remote-listuser', username], stdout=PIPE)
     output = p.communicate()[0]
 
     print output
     return p.returncode
 
+
 if __name__ == '__main__':
     sys.exit(main(sys.argv))
-
-# vim:et:sw=4:ts=4
diff --git a/server/usr/sbin/invirt-remote-listuser b/server/usr/sbin/invirt-remote-listuser
index b226413..38bd744 100755
--- a/server/usr/sbin/invirt-remote-listuser
+++ b/server/usr/sbin/invirt-remote-listuser
@@ -1,14 +1,12 @@
 #!/usr/bin/python
 """
-Lists what a user's VM's are
+Lists the VMs belonging to a given user.
 """
 
-from subprocess import PIPE, Popen, call
 import sys
 import yaml
 
 from invirt import database
-from invirt.database import Machine, MachineAccess
 
 
 def main(argv):
@@ -18,18 +16,13 @@ def main(argv):
     username = argv[1]
 
     database.connect()
-    machines = Machine.query().join('acl').filter_by(user=username)
     output = {}
-    for m in machines:
-        
-        data = {}
-        data['owner']=m.owner
-        data['contact'] = m.contact
-        output[m.name] = data
+    for m in database.Machine.query().join('acl').filter_by(user=username):
+        output[m.name] = dict(owner=m.owner, contact=m.contact)
 
     print yaml.dump(output, Dumper=yaml.CSafeDumper, default_flow_style=False)
     return 0
+
+
 if __name__ == '__main__':
     sys.exit(main(sys.argv))
-
-# vim:et:sw=4:ts=4