- Timestamp:
- Aug 2, 2008, 8:28:18 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/sipb-xen-remote-server/files/usr/sbin/sipb-xen-remote-listvms
r623 r816 6 6 """ 7 7 8 from subprocess import PIPE, Popen8 from invirt.remote import bcast 9 9 import sys 10 10 import yaml 11 11 12 12 def 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')) 28 15 29 16 # Merge the results and print. … … 37 24 38 25 if __name__ == '__main__': 39 main(sys.argv)26 sys.exit(main(sys.argv)) 40 27 41 28 # vim:et:sw=4:ts=4
Note: See TracChangeset
for help on using the changeset viewer.