def capture_upstart(reactor, host, output_file):
 results = []
 for (directory, service) in [('flocker', 'flocker-control'), ('flocker', 'flocker-dataset-agent'), ('flocker', 'flocker-container-agent'), ('flocker', 'flocker-docker-plugin'), ('upstart', 'docker')]:
  def pull_logs_for_process(directory=directory, service=service):
   path = FilePath('/var/log/').child(directory).child((service + '.log'))
   formatter = TailFormatter(output_file, host, service)
   ran = run_ssh(reactor=reactor, host=host, username='root', command=['tail', '-F', path.path], handle_stdout=formatter.handle_output_line)
   ran.addErrback(write_failure, logger=None)
   ran.addCallback((lambda ignored, formatter=formatter: formatter.handle_output_line('')))
   return ran
  results.append(loop_until(reactor, pull_logs_for_process, repeat(2.0)))
 return gather_deferreds(results)

def capture_upstart ( reactor , host , output_file ) : results = [ ] for ( directory , service ) in [ ( 'flocker' , 'flocker-control' ) , ( 'flocker' , 'flocker-dataset-agent' ) , ( 'flocker' , 'flocker-container-agent' ) , ( 'flocker' , 'flocker-docker-plugin' ) , ( 'upstart' , 'docker' ) ] : def pull_logs_for_process ( directory = directory , service = service ) : path = FilePath ( '/var/log/' ) . child ( directory ) . child ( ( service + '.log' ) ) formatter = TailFormatter ( output_file , host , service ) ran = run_ssh ( reactor = reactor , host = host , username = 'root' , command = [ 'tail' , '-F' , path . path ] , handle_stdout = formatter . handle_output_line ) ran . addErrback ( write_failure , logger = None ) ran . addCallback ( ( lambda ignored , formatter = formatter : formatter . handle_output_line ( '' ) ) ) return ran results . append ( loop_until ( reactor , pull_logs_for_process , repeat ( 2.0 ) ) ) return gather_deferreds ( results )
ssh into given machine and capture relevant logs .