source: trunk/packages/invirt-remote/server/usr/sbin/invirt-remote-listuser @ 2508

Last change on this file since 2508 was 2508, checked in by pweaver, 15 years ago

Added a remctl script listuser which an admin can use remctl listuser $user and list machines that
user has permissions on along with contact data of those machines.

This can be used for a remctl script 'list' which will allow a user list their own machines.

  • Property svn:executable set to *
File size: 696 bytes
Line 
1#!/usr/bin/python
2"""
3Lists what a user's VM's are
4"""
5
6from subprocess import PIPE, Popen, call
7import sys
8import yaml
9
10from invirt import database
11from invirt.database import Machine, MachineAccess
12
13
14def main(argv):
15    if len(argv) < 2:
16        print >>sys.stderr, "usage: invirt-remote-listuser <user>"
17        return 2
18    username = argv[1]
19
20    database.connect()
21    machines = Machine.query().join('acl').filter_by(user=username)
22    output = "Machine Name \t\t Owner \t\t contact \n\r"
23    for m in machines:
24        output +=  m.name + "\t" + m.owner +"\t" +  m.contact + "\n\r"
25    print output
26    return 0
27if __name__ == '__main__':
28    sys.exit(main(sys.argv))
29
30# vim:et:sw=4:ts=4
Note: See TracBrowser for help on using the repository browser.