Last change
on this file since 2509 was
2509,
checked in by pweaver, 15 years ago
|
Modified the output of remctl listuser to use YAML
|
-
Property svn:executable set to
*
|
File size:
787 bytes
|
Line | |
---|
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 = {} |
---|
23 | for m in machines: |
---|
24 | |
---|
25 | data = {} |
---|
26 | data['owner']=m.owner |
---|
27 | data['contact'] = m.contact |
---|
28 | output[m.name] = data |
---|
29 | |
---|
30 | print output |
---|
31 | print yaml.dump(output, Dumper=yaml.CSafeDumper, default_flow_style=False) |
---|
32 | return 0 |
---|
33 | if __name__ == '__main__': |
---|
34 | sys.exit(main(sys.argv)) |
---|
35 | |
---|
36 | # vim:et:sw=4:ts=4 |
---|
Note: See
TracBrowser
for help on using the repository browser.