Changeset 2516
- Timestamp:
- Oct 29, 2009, 12:52:59 AM (15 years ago)
- Location:
- trunk/packages/invirt-remote
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/invirt-remote/debian/changelog
r2513 r2516 1 invirt-remote (0.4.4) unstable; urgency=low 2 3 [Paul Weaver] 4 * Add methods "listuser", "list" to list the VMs belonging to a 5 specified user or the requesting user. 6 7 -- Greg Price <price@mit.edu> Thu, 29 Oct 2009 00:51:58 -0400 8 1 9 invirt-remote (0.4.3) unstable; urgency=low 2 10 -
trunk/packages/invirt-remote/server/usr/sbin/invirt-remote-list
r2511 r2516 1 1 #!/usr/bin/python 2 2 """ 3 Returns a user's list of vm's 3 Lists the VMs belonging to the remote user. 4 4 """ 5 5 … … 7 7 import sys 8 8 import os 9 import yaml 9 10 10 11 11 def main(argv): 12 12 if len(argv) < 1: 13 print >>sys.stderr, "usage: invirt-remote-list 13 print >>sys.stderr, "usage: invirt-remote-list" 14 14 return 2 15 username = os.environ['REMUSER'].rsplit('@ATHENA.MIT.EDU')[0] 15 16 username = os.environ['REMOTE_USER'].rsplit('@ATHENA.MIT.EDU')[0] 16 17 p = Popen(['/usr/sbin/invirt-remote-listuser', username], stdout=PIPE) 17 18 output = p.communicate()[0] … … 20 21 return p.returncode 21 22 23 22 24 if __name__ == '__main__': 23 25 sys.exit(main(sys.argv)) 24 25 # vim:et:sw=4:ts=4 -
trunk/packages/invirt-remote/server/usr/sbin/invirt-remote-listuser
r2510 r2516 1 1 #!/usr/bin/python 2 2 """ 3 Lists what a user's VM's are3 Lists the VMs belonging to a given user. 4 4 """ 5 5 6 from subprocess import PIPE, Popen, call7 6 import sys 8 7 import yaml 9 8 10 9 from invirt import database 11 from invirt.database import Machine, MachineAccess12 10 13 11 … … 19 17 20 18 database.connect() 21 machines = Machine.query().join('acl').filter_by(user=username)22 19 output = {} 23 for m in machines: 24 25 data = {} 26 data['owner']=m.owner 27 data['contact'] = m.contact 28 output[m.name] = data 20 for m in database.Machine.query().join('acl').filter_by(user=username): 21 output[m.name] = dict(owner=m.owner, contact=m.contact) 29 22 30 23 print yaml.dump(output, Dumper=yaml.CSafeDumper, default_flow_style=False) 31 24 return 0 25 26 32 27 if __name__ == '__main__': 33 28 sys.exit(main(sys.argv)) 34 35 # vim:et:sw=4:ts=4
Note: See TracChangeset
for help on using the changeset viewer.