#NEWLINE# @ classmethod #NEWLINE# def gather_logs( cls , options ) : #NEWLINE# #INDENT# 'Collects logs from each machine in the currently running AppScale\n    deployment.\n\n    Args:\n      options: A Namespace that has fields for each parameter that can be\n        passed in via the command-line interface.\n    ' #NEWLINE# if os . path . exists ( options . location ) : #NEWLINE# #INDENT# raise AppScaleException ( ( "Can't gather logs, as the location you " + 'specified, {0}, already exists.' . format ( options . location ) ) ) #NEWLINE# #UNINDENT# acc = AppControllerClient ( LocalState . get_login_host ( options . keyname ) , LocalState . get_secret_key ( options . keyname ) ) #NEWLINE# try : #NEWLINE# #INDENT# all_ips = acc . get_all_public_ips ( ) #NEWLINE# #UNINDENT# except socket . error : #NEWLINE# #INDENT# AppScaleLogger . warn ( ( ( "Couldn't get an up-to-date listing of the " + 'machines in this AppScale deployment. Using our locally cached ' ) + 'info instead.' ) ) #NEWLINE# all_ips = LocalState . get_all_public_ips ( options . keyname ) #NEWLINE# #UNINDENT# os . mkdir ( options . location ) #NEWLINE# log_paths = [ '/var/log/appscale' , '/var/log/kern.log*' , '/var/log/monit.log*' , '/var/log/nginx' , '/var/log/syslog*' , '/var/log/zookeeper' ] #NEWLINE# failures = False #NEWLINE# for ip in all_ips : #NEWLINE# #INDENT# local_dir = '{0}/{1}' . format ( options . location , ip ) #NEWLINE# os . mkdir ( local_dir ) #NEWLINE# for log_path in log_paths : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# RemoteHelper . scp_remote_to_local ( ip , options . keyname , log_path , local_dir , options . verbose ) #NEWLINE# #UNINDENT# except ShellException as shell_exception : #NEWLINE# #INDENT# failures = True #NEWLINE# AppScaleLogger . warn ( "Unable to collect logs from '{}' for host '{}'" . format ( log_path , ip ) ) #NEWLINE# AppScaleLogger . verbose ( 'Encountered exception: {}' . format ( str ( shell_exception ) ) , options . verbose ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if failures : #NEWLINE# #INDENT# AppScaleLogger . log ( 'Done copying to {0}. There were failures while collecting AppScale logs.' . format ( options . location ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# AppScaleLogger . success ( 'Successfully collected all AppScale logs into {0}' . format ( options . location ) )