Changeset 558 for trunk/packages


Ignore:
Timestamp:
Jun 2, 2008, 2:41:25 AM (17 years ago)
Author:
andersk
Message:

Open remctl pipes in parallel.

File:
1 edited

Legend:

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

    r552 r558  
    1313###
    1414
    15 def run(cmd):
    16   """
    17   Run the given command (a list of program and argument strings) and return the
    18   stdout as a string, raising a CalledProcessError if the program exited with a
    19   non-zero status.
    20   """
    21   p = Popen(cmd, stdout=PIPE)
    22   stdout = p.communicate()[0]
    23   if p.returncode != 0: raise CalledProcessError(p.returncode, cmd)
    24   return stdout
    25 
    2615def main(argv):
    2716  # Query each of the server for their VMs.
     
    3019  servers = [ 'black-mesa.mit.edu', 'sx-blade-2.mit.edu' ]
    3120  # XXX
    32   results = [ safe_load(run(['remctl', server, 'remote', 'web', 'listvms']))
    33               for server in servers ]
     21  pipes = [ Popen(['remctl', server, 'remote', 'web', 'listvms'], stdout=PIPE)
     22            for server in servers ]
     23  outputs = [ p.communicate()[0] for p in pipes ]
     24  for p in pipes:
     25    if p.returncode != 0: raise CalledProcessError(p.returncode, cmd)
     26  results = [ safe_load(o) for o in outputs ]
    3427  results = filter( lambda x: x is not None, results )
    3528
Note: See TracChangeset for help on using the changeset viewer.