Ignore:
Timestamp:
Aug 2, 2008, 8:28:18 PM (16 years ago)
Author:
y_z
Message:
  • use invirt.config to get hostnames
  • refactoring: extracted bcast() function into invirt.remote package
  • fixed os.rename import bug
  • using correct default paths in invirt-getconf
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/sipb-xen-remote-server/files/usr/sbin/sipb-xen-remote-listvms

    r623 r816  
    66"""
    77
    8 from subprocess import PIPE, Popen
     8from invirt.remote import bcast
    99import sys
    1010import yaml
    1111
    1212def main(argv):
    13     # Query each of the server for their VMs.
    14     # TODO get `servers` from a real list of all the VM hosts (instead of
    15     # hardcoding the list here)
    16     servers = ['black-mesa.mit.edu', 'sx-blade-2.mit.edu']
    17     # XXX
    18     pipes = [(server,
    19               Popen(['remctl', server, 'remote', 'web', 'listvms'], stdout=PIPE))
    20              for server in servers]
    21     outputs = [(s, p.communicate()[0]) for (s, p) in pipes]
    22     for (s, p) in pipes:
    23         if p.returncode != 0:
    24             raise RuntimeError("remctl to host %s returned non-zero exit status %d"
    25                                % (s, p.returncode))
    26     results = [(s, yaml.load(o, yaml.CSafeLoader)) for (s, o) in outputs]
    27     results = filter(lambda (_, x): x is not None, results)
     13    # Query each of the hosts.
     14    results = filter(lambda (_, x): x is not None, bcast('listvms'))
    2815
    2916    # Merge the results and print.
     
    3724
    3825if __name__ == '__main__':
    39     main(sys.argv)
     26    sys.exit(main(sys.argv))
    4027
    4128# vim:et:sw=4:ts=4
Note: See TracChangeset for help on using the changeset viewer.