Added "web vgcapacity" probe for disk utilization.
[invirt/packages/invirt-remote.git] / server / usr / sbin / invirt-remote-listuser
1 #!/usr/bin/python
2 """
3 Lists the VMs belonging to a given user.
4 """
5
6 import sys
7 import yaml
8
9 from invirt import database
10
11
12 def main(argv):
13     if len(argv) < 2:
14         print >>sys.stderr, "usage: invirt-remote-listuser <user>"
15         return 2
16     username = argv[1]
17
18     database.connect()
19     output = {}
20     for m in database.Machine.query().join('acl').filter_by(user=username):
21         output[m.name] = dict(owner=m.owner, contact=m.contact)
22
23     print yaml.dump(output, Dumper=yaml.CSafeDumper, default_flow_style=False)
24     return 0
25
26
27 if __name__ == '__main__':
28     sys.exit(main(sys.argv))