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
|
Rev | Line | |
---|
[2508] | 1 | #!/usr/bin/python |
---|
| 2 | """ |
---|
| 3 | Lists what a user's VM's are |
---|
| 4 | """ |
---|
| 5 | |
---|
| 6 | from subprocess import PIPE, Popen, call |
---|
| 7 | import sys |
---|
| 8 | import yaml |
---|
| 9 | |
---|
| 10 | from invirt import database |
---|
| 11 | from invirt.database import Machine, MachineAccess |
---|
| 12 | |
---|
| 13 | |
---|
| 14 | def 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 |
---|
| 27 | if __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.