source: package_branches/invirt-remote/hvirt/server/usr/sbin/invirt-remote-listuser @ 2866

Last change on this file since 2866 was 2516, checked in by price, 15 years ago

Style fixes in, and Debian changelog for, list and listuser.

  • Property svn:executable set to *
File size: 598 bytes
Line 
1#!/usr/bin/python
2"""
3Lists the VMs belonging to a given user.
4"""
5
6import sys
7import yaml
8
9from invirt import database
10
11
12def 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
27if __name__ == '__main__':
28    sys.exit(main(sys.argv))
Note: See TracBrowser for help on using the repository browser.