Ignore:
Timestamp:
Jun 21, 2008, 7:56:50 PM (16 years ago)
Author:
price
Message:

note host in listvms

File:
1 edited

Legend:

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

    r622 r623  
    1010import yaml
    1111
    12 ###
    13 
    1412def main(argv):
    1513    # Query each of the server for their VMs.
     
    1816    servers = ['black-mesa.mit.edu', 'sx-blade-2.mit.edu']
    1917    # XXX
    20     pipes = [Popen(['remctl', server, 'remote', 'web', 'listvms'], stdout=PIPE)
     18    pipes = [(server,
     19              Popen(['remctl', server, 'remote', 'web', 'listvms'], stdout=PIPE))
    2120             for server in servers]
    22     outputs = [p.communicate()[0] for p in pipes]
    23     for p in pipes:
     21    outputs = [(s, p.communicate()[0]) for (s, p) in pipes]
     22    for (s, p) in pipes:
    2423        if p.returncode != 0:
    25             raise RuntimeError("Command '%s' returned non-zero exit status %d"
    26                                % ('remctl', p.returncode))
    27     results = [yaml.load(o, yaml.CSafeLoader) for o in outputs]
    28     results = filter(lambda x: x is not None, results)
     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)
    2928
    3029    # Merge the results and print.
    3130    merged = {}
    32     for result in results:
     31    for server, result in results:
     32        for data in result.itervalues():
     33            data['host'] = server
    3334        merged.update(result)
    3435
Note: See TracChangeset for help on using the changeset viewer.