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

Last change on this file since 2967 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
RevLine 
[2508]1#!/usr/bin/python
2"""
[2516]3Lists the VMs belonging to a given user.
[2508]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()
[2509]19    output = {}
[2516]20    for m in database.Machine.query().join('acl').filter_by(user=username):
21        output[m.name] = dict(owner=m.owner, contact=m.contact)
[2509]22
23    print yaml.dump(output, Dumper=yaml.CSafeDumper, default_flow_style=False)
[2508]24    return 0
[2516]25
26
[2508]27if __name__ == '__main__':
28    sys.exit(main(sys.argv))
Note: See TracBrowser for help on using the repository browser.