#!/usr/bin/python

"""
Collates the results of listvms from multiple VM servers.  Part of the xvm
suite.
"""

from invirt.remote import bcast
import sys
import yaml

def main(argv):
    # Query each of the hosts.
    results = filter(lambda (_, x): x is not None, bcast('listvms'))

    # Merge the results and print.
    merged = {}
    for server, result in results:
        for data in result.itervalues():
            data['host'] = server
        merged.update(result)

    print yaml.dump(merged, Dumper=yaml.CSafeDumper, default_flow_style=False)

if __name__ == '__main__':
    sys.exit(main(sys.argv))

# vim:et:sw=4:ts=4
