<s> from lib . controller import ShellController <EOL> from lib . controllerlib import * <EOL> from lib import terminal <EOL> from lib . view import CliView <EOL> def strip_string ( search_str ) : <EOL> search_str = search_str . strip ( ) <EOL> if search_str [ <NUM_LIT:0> ] == "<STR_LIT>" or search_str [ <NUM_LIT:0> ] == "<STR_LIT>" : <EOL> return search_str [ <NUM_LIT:1> : len ( search_str ) - <NUM_LIT:1> ] <EOL> else : <EOL> return search_str <EOL> def clear_option_from_mods ( self , option ) : <EOL> for mod in self . modifiers : <EOL> if mod in self . mods and option in self . mods [ mod ] : <EOL> self . mods [ mod ] . remove ( option ) <EOL> def flip_keys ( orig_data ) : <EOL> new_data = { } <EOL> for key1 , data1 in orig_data . iteritems ( ) : <EOL> if isinstance ( data1 , Exception ) : <EOL> continue <EOL> for key2 , data2 in data1 . iteritems ( ) : <EOL> if key2 not in new_data : <EOL> new_data [ key2 ] = { } <EOL> new_data [ key2 ] [ key1 ] = data2 <EOL> return new_data <EOL> @ CommandHelp ( '<STR_LIT>' ) <EOL> class LogRootController ( BaseController ) : <EOL> def __init__ ( <EOL> self , <EOL> seed_nodes = [ <EOL> ( '<STR_LIT:127.0.0.1>' , <EOL> <NUM_LIT> ) ] , <EOL> use_telnet = False , <EOL> user = None , <EOL> password = None , <EOL> log_path = "<STR_LIT:U+0020>" ) : <EOL> super ( <EOL> LogRootController , <EOL> self ) . __init__ ( <EOL> seed_nodes = seed_nodes , <EOL> use_telnet = use_telnet , <EOL> user = user , <EOL> password = password , <EOL> log_path = log_path ) <EOL> self . controller_map = { <EOL> '<STR_LIT:info>' : InfoController , <EOL> '<STR_LIT>' : ShowController , <EOL> '<STR_LIT:!>' : ShellController , <EOL> '<STR_LIT>' : ShellController , <EOL> '<STR_LIT>' : LogGrepController , <EOL> '<STR_LIT>' : LogLatencyController , <EOL> '<STR_LIT>' : AddController , <EOL> '<STR_LIT>' : RemoveController , <EOL> '<STR_LIT:list>' : ListController , <EOL> '<STR_LIT>' : SelectController , <EOL> '<STR_LIT>' : FeaturesController , <EOL> '<STR_LIT>' : PagerController } <EOL> @ CommandHelp ( '<STR_LIT>' ) <EOL> def do_exit ( self , line ) : <EOL> return "<STR_LIT>" <EOL> @ CommandHelp ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> def do_help ( self , line ) : <EOL> self . executeHelp ( line ) <EOL> @ CommandHelp ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> class InfoController ( CommandController ) : <EOL> def __init__ ( self ) : <EOL> self . modifiers = set ( ) <EOL> @ CommandHelp ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> def _do_default ( self , line ) : <EOL> self . do_network ( line ) <EOL> self . do_namespace ( line ) <EOL> self . do_xdr ( line ) <EOL> @ CommandHelp ( <EOL> '<STR_LIT>' ) <EOL> def do_network ( self , line ) : <EOL> network_infos = self . logger . infoSummary ( stanza = '<STR_LIT>' ) <EOL> service_infos = self . logger . infoSummary ( stanza = '<STR_LIT>' ) <EOL> network_stats = self . logger . infoStatistics ( stanza = '<STR_LIT>' ) <EOL> for timestamp in sorted ( network_stats . keys ( ) ) : <EOL> if not network_stats [ timestamp ] : <EOL> try : <EOL> if service_infos [ timestamp ] : <EOL> self . view . infoString ( timestamp , service_infos [ timestamp ] ) <EOL> except : <EOL> pass <EOL> try : <EOL> if network_infos [ timestamp ] : <EOL> self . view . infoString ( timestamp , network_infos [ timestamp ] ) <EOL> except : <EOL> pass <EOL> continue <EOL> logsnapshot_controller = self . logger . get_log_snapshot ( timestamp = timestamp ) <EOL> builds = logsnapshot_controller . get_asd_build ( ) <EOL> versions = logsnapshot_controller . get_asd_version ( ) <EOL> self . view . infoNetwork ( network_stats [ timestamp ] , versions , builds , logsnapshot_controller , title_suffix = "<STR_LIT>" % ( timestamp ) , ** self . mods ) <EOL> @ CommandHelp ( '<STR_LIT>' ) <EOL> def do_namespace ( self , line ) : <EOL> ns_infos = self . logger . infoSummary ( stanza = '<STR_LIT>' ) <EOL> ns_stats = self . logger . infoStatistics ( stanza = '<STR_LIT>' ) <EOL> for timestamp in sorted ( ns_stats . keys ( ) ) : <EOL> if not ns_stats [ timestamp ] : <EOL> try : <EOL> if ns_infos [ timestamp ] : <EOL> self . view . infoString ( timestamp , ns_infos [ timestamp ] ) <EOL> except : <EOL> pass <EOL> continue <EOL> self . view . infoNamespace ( flip_keys ( ns_stats [ timestamp ] ) , self . logger . get_log_snapshot ( timestamp = timestamp ) , title_suffix = "<STR_LIT>" % ( timestamp ) , ** self . mods ) <EOL> def convert_key_to_tuple ( self , stats ) : <EOL> for key in stats . keys ( ) : <EOL> key_tuple = tuple ( key . split ( ) ) <EOL> stats [ key_tuple ] = stats [ key ] <EOL> del stats [ key ] <EOL> @ CommandHelp ( '<STR_LIT>' ) <EOL> def do_set ( self , line ) : <EOL> set_infos = self . logger . infoSummary ( stanza = '<STR_LIT>' ) <EOL> set_stats = self . logger . infoStatistics ( stanza = '<STR_LIT>' ) <EOL> for timestamp in sorted ( set_stats . keys ( ) ) : <EOL> if not set_stats [ timestamp ] : <EOL> try : <EOL> if set_infos [ timestamp ] : <EOL> self . view . infoString ( timestamp , set_infos [ timestamp ] ) <EOL> except : <EOL> pass <EOL> continue <EOL> self . convert_key_to_tuple ( set_stats [ timestamp ] ) <EOL> self . view . infoSet ( flip_keys ( set_stats [ timestamp ] ) , self . logger . get_log_snapshot ( timestamp = timestamp ) , title_suffix = "<STR_LIT>" % ( timestamp ) , ** self . mods ) <EOL> @ CommandHelp ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> def do_xdr ( self , line ) : <EOL> xdr_infos = self . logger . infoSummary ( stanza = '<STR_LIT>' ) <EOL> xdr_stats = self . logger . infoStatistics ( stanza = '<STR_LIT>' ) <EOL> for timestamp in sorted ( xdr_stats . keys ( ) ) : <EOL> if not xdr_stats [ timestamp ] : <EOL> try : <EOL> if xdr_infos [ timestamp ] : <EOL> self . view . infoString ( timestamp , xdr_infos [ timestamp ] ) <EOL> except : <EOL> pass <EOL> continue <EOL> xdr_enable = { } <EOL> logsnapshot_controller = self . logger . get_log_snapshot ( timestamp = timestamp ) <EOL> builds = logsnapshot_controller . get_xdr_build ( ) <EOL> for xdr_node in xdr_stats [ timestamp ] . keys ( ) : <EOL> xdr_enable [ xdr_node ] = True <EOL> self . view . infoXDR ( xdr_stats [ timestamp ] , builds , xdr_enable , logsnapshot_controller , title_suffix = "<STR_LIT>" % ( timestamp ) , ** self . mods ) <EOL> @ CommandHelp ( '<STR_LIT>' ) <EOL> def do_dc ( self , line ) : <EOL> dc_infos = self . logger . infoSummary ( stanza = '<STR_LIT>' ) <EOL> dc_stats = self . logger . infoStatistics ( stanza = '<STR_LIT>' ) <EOL> dc_config = self . logger . infoGetConfig ( stanza = '<STR_LIT>' ) <EOL> for timestamp in sorted ( dc_stats . keys ( ) ) : <EOL> if not dc_stats [ timestamp ] : <EOL> try : <EOL> if dc_infos [ timestamp ] : <EOL> self . view . infoString ( timestamp , dc_infos [ timestamp ] ) <EOL> except : <EOL> pass <EOL> continue <EOL> for node in dc_stats [ timestamp ] . keys ( ) : <EOL> if dc_stats [ timestamp ] [ node ] and not isinstance ( dc_stats [ timestamp ] [ node ] , Exception ) and dc_config [ timestamp ] [ node ] and not isinstance ( dc_config [ timestamp ] [ node ] , Exception ) : <EOL> for dc in dc_stats [ timestamp ] [ node ] . keys ( ) : <EOL> dc_stats [ timestamp ] [ node ] [ dc ] . update ( dc_config [ timestamp ] [ node ] [ dc ] ) <EOL> elif ( not dc_stats [ timestamp ] [ node ] or isinstance ( dc_stats [ timestamp ] [ node ] , Exception ) ) and dc_config [ timestamp ] [ node ] and not isinstance ( dc_config [ timestamp ] [ node ] , Exception ) : <EOL> dc_stats [ timestamp ] [ node ] = dc_config [ timestamp ] [ node ] <EOL> self . view . infoDC ( flip_keys ( dc_stats [ timestamp ] ) , self . logger . get_log_snapshot ( timestamp = timestamp ) , title_suffix = "<STR_LIT>" % ( timestamp ) , ** self . mods ) <EOL> @ CommandHelp ( '<STR_LIT>' ) <EOL> def do_sindex ( self , line ) : <EOL> sindex_infos = self . logger . infoSummary ( stanza = '<STR_LIT>' ) <EOL> sindex_stats = self . logger . infoStatistics ( stanza = '<STR_LIT>' ) <EOL> for timestamp in sorted ( sindex_stats . keys ( ) ) : <EOL> if not sindex_stats [ timestamp ] : <EOL> try : <EOL> if sindex_infos [ timestamp ] : <EOL> self . view . infoString ( timestamp , sindex_infos [ timestamp ] ) <EOL> except : <EOL> pass <EOL> continue <EOL> self . view . infoSIndex ( sindex_stats [ timestamp ] , self . logger . get_log_snapshot ( timestamp = timestamp ) , title_suffix = "<STR_LIT>" % ( timestamp ) , ** self . mods ) <EOL> @ CommandHelp ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> class ShowController ( CommandController ) : <EOL> def __init__ ( self ) : <EOL> self . controller_map = { <EOL> '<STR_LIT>' : ShowConfigController , <EOL> '<STR_LIT>' : ShowStatisticsController , <EOL> '<STR_LIT>' : ShowDistributionController } <EOL> self . modifiers = set ( ) <EOL> def _do_default ( self , line ) : <EOL> self . executeHelp ( line ) <EOL> @ CommandHelp ( <EOL> '<STR_LIT>' ) <EOL> class ShowConfigController ( CommandController ) : <EOL> def __init__ ( self ) : <EOL> self . modifiers = set ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> @ CommandHelp ( '<STR_LIT>' ) <EOL> def _do_default ( self , line ) : <EOL> self . do_service ( line ) <EOL> self . do_network ( line ) <EOL> self . do_namespace ( line ) <EOL> @ CommandHelp ( '<STR_LIT>' ) <EOL> def do_service ( self , line ) : <EOL> service_configs = self . logger . infoGetConfig ( stanza = '<STR_LIT>' ) <EOL> for timestamp in sorted ( service_configs . keys ( ) ) : <EOL> self . view . showConfig ( <EOL> "<STR_LIT>" % <EOL> ( timestamp ) , <EOL> service_configs [ timestamp ] , self . logger . get_log_snapshot ( timestamp = timestamp ) , <EOL> ** self . mods ) <EOL> @ CommandHelp ( '<STR_LIT>' ) <EOL> def do_network ( self , line ) : <EOL> service_configs = self . logger . infoGetConfig ( stanza = '<STR_LIT>' ) <EOL> for timestamp in sorted ( service_configs . keys ( ) ) : <EOL> self . view . showConfig ( <EOL> "<STR_LIT>" % <EOL> ( timestamp ) , <EOL> service_configs [ timestamp ] , self . logger . get_log_snapshot ( timestamp = timestamp ) , <EOL> ** self . mods ) <EOL> @ CommandHelp ( '<STR_LIT>' ) <EOL> def do_namespace ( self , line ) : <EOL> ns_configs = self . logger . infoGetConfig ( stanza = '<STR_LIT>' ) <EOL> for timestamp in sorted ( ns_configs . keys ( ) ) : <EOL> for ns , configs in ns_configs [ timestamp ] . iteritems ( ) : <EOL> self . view . showConfig ( <EOL> "<STR_LIT>" % <EOL> ( ns , timestamp ) , configs , self . logger . get_log_snapshot ( timestamp = timestamp ) , ** self . mods ) <EOL> @ CommandHelp ( '<STR_LIT>' ) <EOL> def do_xdr ( self , line ) : <EOL> xdr_configs = self . logger . infoGetConfig ( stanza = '<STR_LIT>' ) <EOL> for timestamp in sorted ( xdr_configs . keys ( ) ) : <EOL> self . view . showConfig ( <EOL> "<STR_LIT>" % <EOL> ( timestamp ) , <EOL> xdr_configs [ timestamp ] , self . logger . get_log_snapshot ( timestamp = timestamp ) , <EOL> ** self . mods ) <EOL> @ CommandHelp ( '<STR_LIT>' ) <EOL> def do_dc ( self , line ) : <EOL> dc_configs = self . logger . infoGetConfig ( stanza = '<STR_LIT>' ) <EOL> for timestamp in sorted ( dc_configs . keys ( ) ) : <EOL> for dc , configs in dc_configs [ timestamp ] . iteritems ( ) : <EOL> self . view . showConfig ( <EOL> "<STR_LIT>" % <EOL> ( dc , timestamp ) , configs , self . logger . get_log_snapshot ( timestamp = timestamp ) , ** self . mods ) <EOL> @ CommandHelp ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> class ShowDistributionController ( CommandController ) : <EOL> def __init__ ( self ) : <EOL> self . modifiers = set ( [ '<STR_LIT>' ] ) <EOL> @ CommandHelp ( '<STR_LIT>' <EOL> , '<STR_LIT>' <EOL> , '<STR_LIT>' ) <EOL> def _do_default ( self , line ) : <EOL> self . do_time_to_live ( line ) <EOL> self . do_object_size ( line ) <EOL> def _do_distribution ( self , histogram_name , title , unit ) : <EOL> histogram = self . logger . infoGetHistogram ( histogram_name ) <EOL> for timestamp in sorted ( histogram . keys ( ) ) : <EOL> self . view . showDistribution ( title , <EOL> histogram [ timestamp ] , <EOL> unit , <EOL> histogram_name , self . logger . get_log_snapshot ( timestamp = timestamp ) , <EOL> title_suffix = "<STR_LIT>" % ( timestamp ) , ** self . mods ) <EOL> @ CommandHelp ( '<STR_LIT>' ) <EOL> def do_time_to_live ( self , line ) : <EOL> return self . _do_distribution ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> @ CommandHelp ( '<STR_LIT>' <EOL> , '<STR_LIT>' <EOL> , '<STR_LIT>' ) <EOL> def do_object_size ( self , line ) : <EOL> if '<STR_LIT>' in line : <EOL> histogram = self . logger . infoGetHistogram ( "<STR_LIT>" ) <EOL> for timestamp in histogram : <EOL> self . view . showObjectDistribution ( '<STR_LIT>' , histogram [ timestamp ] , '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT:10> , False , <EOL> self . logger . get_log_snapshot ( timestamp = timestamp ) , title_suffix = "<STR_LIT>" % ( timestamp ) , loganalyser_mode = True <EOL> , ** self . mods ) <EOL> else : <EOL> return self . _do_distribution ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> @ CommandHelp ( '<STR_LIT>' ) <EOL> def do_eviction ( self , line ) : <EOL> return self . _do_distribution ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> @ CommandHelp ( '<STR_LIT>' ) <EOL> class LogLatencyController ( CommandController ) : <EOL> def __init__ ( self ) : <EOL> self . modifiers = set ( ) <EOL> self . grepFile = GrepFile ( False , self . modifiers ) <EOL> @ CommandHelp ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> def _do_default ( self , line ) : <EOL> self . grepFile . do_latency ( line ) <EOL> @ CommandHelp ( '<STR_LIT>' ) <EOL> class ShowStatisticsController ( CommandController ) : <EOL> def __init__ ( self ) : <EOL> self . modifiers = set ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> def need_to_show_total ( self , line ) : <EOL> show_total = False <EOL> try : <EOL> if "<STR_LIT>" in line : <EOL> show_total = True <EOL> clear_option_from_mods ( "<STR_LIT>" ) <EOL> except : <EOL> pass <EOL> return show_total <EOL> @ CommandHelp ( '<STR_LIT>' <EOL> , '<STR_LIT>' <EOL> , '<STR_LIT>' ) <EOL> def _do_default ( self , line ) : <EOL> self . do_bins ( line ) <EOL> self . do_sets ( line ) <EOL> self . do_service ( line ) <EOL> self . do_namespace ( line ) <EOL> @ CommandHelp ( '<STR_LIT>' <EOL> , '<STR_LIT>' <EOL> , '<STR_LIT>' ) <EOL> def do_service ( self , line ) : <EOL> show_total = self . need_to_show_total ( line ) <EOL> service_stats = self . logger . infoStatistics ( stanza = "<STR_LIT>" ) <EOL> for timestamp in sorted ( service_stats . keys ( ) ) : <EOL> self . view . showConfig ( <EOL> "<STR_LIT>" % <EOL> ( timestamp ) , <EOL> service_stats [ timestamp ] , self . logger . get_log_snapshot ( timestamp = timestamp ) , show_total = show_total , <EOL> ** self . mods ) <EOL> @ CommandHelp ( '<STR_LIT>' <EOL> , '<STR_LIT>' <EOL> , '<STR_LIT>' ) <EOL> def do_namespace ( self , line ) : <EOL> show_total = self . need_to_show_total ( line ) <EOL> ns_stats = self . logger . infoStatistics ( stanza = "<STR_LIT>" ) <EOL> for timestamp in sorted ( ns_stats . keys ( ) ) : <EOL> namespace_list = util . filter_list ( ns_stats [ timestamp ] . keys ( ) , self . mods [ '<STR_LIT>' ] ) <EOL> for ns in sorted ( namespace_list ) : <EOL> stats = ns_stats [ timestamp ] [ ns ] <EOL> self . view . showStats ( <EOL> "<STR_LIT>" % <EOL> ( ns , timestamp ) , stats , self . logger . get_log_snapshot ( timestamp = timestamp ) , show_total = show_total , ** self . mods ) <EOL> @ CommandHelp ( '<STR_LIT>' <EOL> , '<STR_LIT>' <EOL> , '<STR_LIT>' ) <EOL> def do_sets ( self , line ) : <EOL> show_total = self . need_to_show_total ( line ) <EOL> set_stats = self . logger . infoStatistics ( stanza = "<STR_LIT>" ) <EOL> for timestamp in sorted ( set_stats . keys ( ) ) : <EOL> if not set_stats [ timestamp ] : <EOL> continue <EOL> namespace_list = [ ns_set . split ( ) [ <NUM_LIT:0> ] for ns_set in set_stats [ timestamp ] . keys ( ) ] <EOL> namespace_list = util . filter_list ( namespace_list , self . mods [ '<STR_LIT>' ] ) <EOL> for ns_set , stats in set_stats [ timestamp ] . iteritems ( ) : <EOL> if ns_set . split ( ) [ <NUM_LIT:0> ] not in namespace_list : <EOL> continue <EOL> self . view . showStats ( <EOL> "<STR_LIT>" % <EOL> ( ns_set , timestamp ) , stats , self . logger . get_log_snapshot ( timestamp = timestamp ) , show_total = show_total , ** self . mods ) <EOL> @ CommandHelp ( '<STR_LIT>' <EOL> , '<STR_LIT>' <EOL> , '<STR_LIT>' ) <EOL> def do_bins ( self , line ) : <EOL> show_total = self . need_to_show_total ( line ) <EOL> new_bin_stats = self . logger . infoStatistics ( stanza = "<STR_LIT>" ) <EOL> for timestamp in sorted ( new_bin_stats . keys ( ) ) : <EOL> if not new_bin_stats [ timestamp ] or isinstance ( new_bin_stats [ timestamp ] , Exception ) : <EOL> continue <EOL> namespace_list = util . filter_list ( new_bin_stats [ timestamp ] . keys ( ) , self . mods [ '<STR_LIT>' ] ) <EOL> for ns , stats in new_bin_stats [ timestamp ] . iteritems ( ) : <EOL> if ns not in namespace_list : <EOL> continue <EOL> self . view . showStats ( <EOL> "<STR_LIT>" % <EOL> ( ns , timestamp ) , stats , self . logger . get_log_snapshot ( timestamp = timestamp ) , show_total = show_total , ** self . mods ) <EOL> @ CommandHelp ( '<STR_LIT>' <EOL> , '<STR_LIT>' <EOL> , '<STR_LIT>' ) <EOL> def do_xdr ( self , line ) : <EOL> show_total = self . need_to_show_total ( line ) <EOL> xdr_stats = self . logger . infoStatistics ( stanza = "<STR_LIT>" ) <EOL> for timestamp in sorted ( xdr_stats . keys ( ) ) : <EOL> self . view . showConfig ( <EOL> "<STR_LIT>" % <EOL> ( timestamp ) , <EOL> xdr_stats [ timestamp ] , self . logger . get_log_snapshot ( timestamp = timestamp ) , show_total = show_total , <EOL> ** self . mods ) <EOL> @ CommandHelp ( '<STR_LIT>' <EOL> , '<STR_LIT>' <EOL> , '<STR_LIT>' ) <EOL> def do_dc ( self , line ) : <EOL> show_total = self . need_to_show_total ( line ) <EOL> dc_stats = self . logger . infoStatistics ( stanza = "<STR_LIT>" ) <EOL> for timestamp in sorted ( dc_stats . keys ( ) ) : <EOL> for dc , stats in dc_stats [ timestamp ] . iteritems ( ) : <EOL> self . view . showStats ( <EOL> "<STR_LIT>" % <EOL> ( dc , timestamp ) , stats , self . logger . get_log_snapshot ( timestamp = timestamp ) , show_total = show_total , ** self . mods ) <EOL> @ CommandHelp ( '<STR_LIT>' <EOL> , '<STR_LIT>' <EOL> , '<STR_LIT>' ) <EOL> def do_sindex ( self , line ) : <EOL> show_total = self . need_to_show_total ( line ) <EOL> sindex_stats = self . logger . infoStatistics ( stanza = "<STR_LIT>" ) <EOL> for timestamp in sorted ( sindex_stats . keys ( ) ) : <EOL> if not sindex_stats [ timestamp ] or isinstance ( sindex_stats [ timestamp ] , Exception ) : <EOL> continue <EOL> namespace_list = [ ns_set_sindex . split ( ) [ <NUM_LIT:0> ] for ns_set_sindex in sindex_stats [ timestamp ] . keys ( ) ] <EOL> namespace_list = util . filter_list ( namespace_list , self . mods [ '<STR_LIT>' ] ) <EOL> for sindex , stats in sindex_stats [ timestamp ] . iteritems ( ) : <EOL> if sindex . split ( ) [ <NUM_LIT:0> ] not in namespace_list : <EOL> continue <EOL> self . view . showStats ( <EOL> "<STR_LIT>" % <EOL> ( sindex , timestamp ) , stats , self . logger . get_log_snapshot ( timestamp = timestamp ) , show_total = show_total , ** self . mods ) <EOL> @ CommandHelp ( '<STR_LIT>' ) <EOL> class FeaturesController ( CommandController ) : <EOL> def __init__ ( self ) : <EOL> self . modifiers = set ( [ '<STR_LIT>' ] ) <EOL> def _do_default ( self , line ) : <EOL> service_stats = self . logger . infoStatistics ( stanza = "<STR_LIT>" ) <EOL> ns_stats = self . logger . infoStatistics ( stanza = "<STR_LIT>" ) <EOL> for timestamp in sorted ( service_stats . keys ( ) ) : <EOL> features = { } <EOL> for node , stats in service_stats [ timestamp ] . iteritems ( ) : <EOL> features [ node ] = { } <EOL> features [ node ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> try : <EOL> if int ( <EOL> stats [ "<STR_LIT>" ] ) > <NUM_LIT:0> or int ( <EOL> stats [ "<STR_LIT>" ] ) > <NUM_LIT:0> : <EOL> features [ node ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> except : <EOL> pass <EOL> features [ node ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> try : <EOL> if int ( <EOL> stats [ "<STR_LIT>" ] ) > <NUM_LIT:0> or int ( <EOL> stats [ "<STR_LIT>" ] ) > <NUM_LIT:0> : <EOL> features [ node ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> except : <EOL> pass <EOL> features [ node ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> try : <EOL> if int ( stats [ "<STR_LIT>" ] ) > <NUM_LIT:0> : <EOL> features [ node ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> except : <EOL> pass <EOL> features [ node ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> try : <EOL> if int ( stats [ "<STR_LIT>" ] ) > <NUM_LIT:0> : <EOL> features [ node ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> except : <EOL> pass <EOL> features [ node ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> try : <EOL> if int ( stats [ "<STR_LIT>" ] ) > <NUM_LIT:0> : <EOL> features [ node ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> except : <EOL> pass <EOL> features [ node ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> try : <EOL> if int ( <EOL> stats [ "<STR_LIT>" ] ) > <NUM_LIT:0> or int ( <EOL> stats [ "<STR_LIT>" ] ) > <NUM_LIT:0> : <EOL> features [ node ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> except : <EOL> pass <EOL> features [ node ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> try : <EOL> if int ( <EOL> stats [ "<STR_LIT>" ] ) > <NUM_LIT:0> or int ( <EOL> stats [ "<STR_LIT>" ] ) > <NUM_LIT:0> : <EOL> features [ node ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> except : <EOL> pass <EOL> try : <EOL> if ( timestamp in ns_stats ) : <EOL> namespace_stats = ns_stats [ timestamp ] <EOL> for ns in namespace_stats : <EOL> features [ node ] [ "<STR_LIT>" % ( ns ) ] = "<STR_LIT>" <EOL> try : <EOL> if int ( namespace_stats [ ns ] [ node ] . get ( "<STR_LIT>" , "<STR_LIT:0>" ) ) > <NUM_LIT:0> or int ( namespace_stats [ ns ] [ node ] . get ( "<STR_LIT>" , "<STR_LIT:0>" ) ) > <NUM_LIT:0> or int ( <EOL> namespace_stats [ ns ] [ node ] . get ( "<STR_LIT>" , "<STR_LIT:0>" ) ) > <NUM_LIT:0> or int ( namespace_stats [ ns ] [ node ] . get ( "<STR_LIT>" , "<STR_LIT:0>" ) ) > <NUM_LIT:0> or int ( <EOL> namespace_stats [ ns ] [ node ] . get ( "<STR_LIT>" , "<STR_LIT:0>" ) ) > <NUM_LIT:0> or int ( namespace_stats [ ns ] [ node ] . get ( "<STR_LIT>" , "<STR_LIT:0>" ) ) > <NUM_LIT:0> : <EOL> features [ node ] [ "<STR_LIT>" % ( ns ) ] = "<STR_LIT>" <EOL> except : <EOL> pass <EOL> except : <EOL> pass <EOL> features [ node ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> try : <EOL> if int ( stats [ "<STR_LIT>" ] ) > <NUM_LIT:0> : <EOL> features [ node ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> except : <EOL> pass <EOL> features [ node ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> try : <EOL> if int ( stats [ "<STR_LIT>" ] ) > <NUM_LIT:0> : <EOL> features [ node ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> except : <EOL> pass <EOL> self . view . showConfig ( <EOL> "<STR_LIT>" % <EOL> ( timestamp ) , <EOL> features , <EOL> self . logger . get_log_snapshot ( timestamp = timestamp ) , <EOL> ** self . mods ) <EOL> @ CommandHelp ( '<STR_LIT>' ) <EOL> class LogGrepController ( CommandController ) : <EOL> def __init__ ( self ) : <EOL> self . controller_map = { <EOL> '<STR_LIT>' : LogGrepServerController , <EOL> '<STR_LIT>' : LogGrepClusterController } <EOL> self . modifiers = set ( ) <EOL> def _do_default ( self , line ) : <EOL> self . executeHelp ( line ) <EOL> @ CommandHelp ( '<STR_LIT>' ) <EOL> class LogGrepServerController ( CommandController ) : <EOL> def __init__ ( self ) : <EOL> self . modifiers = set ( ) <EOL> self . grepFile = GrepFile ( False , self . modifiers ) <EOL> def _do_default ( self , line ) : <EOL> self . grepFile . do_show ( line ) <EOL> @ CommandHelp ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> def do_show ( self , line ) : <EOL> self . grepFile . do_show ( line ) <EOL> @ CommandHelp ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> def do_count ( self , line ) : <EOL> self . grepFile . do_count ( line ) <EOL> @ CommandHelp ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> def do_diff ( self , line ) : <EOL> self . grepFile . do_diff ( line ) <EOL> class GrepFile ( CommandController ) : <EOL> def __init__ ( self , grep_cluster , modifiers ) : <EOL> self . grep_cluster = grep_cluster <EOL> self . modifiers = modifiers <EOL> def do_show ( self , line ) : <EOL> if not line : <EOL> raise ShellException ( "<STR_LIT>" + <EOL> "<STR_LIT>" ) <EOL> mods = self . parseModifiers ( line ) <EOL> line = mods [ '<STR_LIT>' ] <EOL> tline = line [ : ] <EOL> search_strs = [ ] <EOL> ignore_str = "<STR_LIT>" <EOL> start_tm = "<STR_LIT>" <EOL> duration = "<STR_LIT>" <EOL> sources = [ ] <EOL> unique = False <EOL> is_and = False <EOL> is_casesensitive = True <EOL> reading_search_strings = False <EOL> search_string_read = False <EOL> while tline : <EOL> search_string_read = False <EOL> word = tline . pop ( <NUM_LIT:0> ) <EOL> if word == '<STR_LIT>' : <EOL> try : <EOL> search_strs . append ( strip_string ( tline . pop ( <NUM_LIT:0> ) ) ) <EOL> reading_search_strings = True <EOL> search_string_read = True <EOL> except : <EOL> search_strs = [ ] <EOL> elif word == '<STR_LIT>' : <EOL> is_and = True <EOL> elif word == '<STR_LIT>' : <EOL> ignore_str = tline . pop ( <NUM_LIT:0> ) <EOL> ignore_str = strip_string ( ignore_str ) <EOL> elif word == '<STR_LIT>' : <EOL> unique = True <EOL> elif word == '<STR_LIT>' : <EOL> is_casesensitive = False <EOL> elif word == '<STR_LIT>' and not self . grep_cluster : <EOL> start_tm = tline . pop ( <NUM_LIT:0> ) <EOL> start_tm = strip_string ( start_tm ) <EOL> elif word == '<STR_LIT>' and not self . grep_cluster : <EOL> duration = tline . pop ( <NUM_LIT:0> ) <EOL> duration = strip_string ( duration ) <EOL> elif word == '<STR_LIT>' : <EOL> try : <EOL> sources = [ <EOL> int ( i ) for i in strip_string ( <EOL> tline . pop ( <NUM_LIT:0> ) ) . split ( "<STR_LIT:U+002C>" ) ] <EOL> except : <EOL> sources = [ ] <EOL> elif reading_search_strings : <EOL> try : <EOL> search_strs . append ( strip_string ( word ) ) <EOL> except : <EOL> pass <EOL> search_string_read = True <EOL> else : <EOL> raise ShellException ( <EOL> "<STR_LIT>" % ( word , "<STR_LIT:U+0020>" . join ( line ) ) ) <EOL> if not search_string_read : <EOL> reading_search_strings = False <EOL> if search_strs : <EOL> files = self . logger . get_files_by_index ( <EOL> self . grep_cluster , <EOL> sources ) <EOL> for timestamp in sorted ( files . keys ( ) ) : <EOL> grepRes = self . logger . grep ( <EOL> files [ timestamp ] , <EOL> search_strs , <EOL> ignore_str , <EOL> unique , <EOL> self . grep_cluster , <EOL> start_tm , <EOL> duration , <EOL> is_and , is_casesensitive ) <EOL> merged_res = "<STR_LIT>" <EOL> for key in sorted ( grepRes . keys ( ) ) : <EOL> merged_res += grepRes [ key ] <EOL> merged_res += "<STR_LIT:\n>" <EOL> self . view . infoString ( timestamp , merged_res ) <EOL> def do_count ( self , line ) : <EOL> if not line : <EOL> raise ShellException ( "<STR_LIT>" + <EOL> "<STR_LIT>" ) <EOL> mods = self . parseModifiers ( line ) <EOL> line = mods [ '<STR_LIT>' ] <EOL> tline = line [ : ] <EOL> search_strs = [ ] <EOL> ignore_str = "<STR_LIT>" <EOL> unique = False <EOL> is_and = False <EOL> is_casesensitive = True <EOL> start_tm = "<STR_LIT>" <EOL> duration = "<STR_LIT>" <EOL> sources = [ ] <EOL> reading_search_strings = False <EOL> search_string_read = False <EOL> while tline : <EOL> search_string_read = False <EOL> word = tline . pop ( <NUM_LIT:0> ) <EOL> if word == '<STR_LIT>' : <EOL> try : <EOL> search_strs . append ( strip_string ( tline . pop ( <NUM_LIT:0> ) ) ) <EOL> reading_search_strings = True <EOL> search_string_read = True <EOL> except : <EOL> search_strs = [ ] <EOL> elif word == '<STR_LIT>' : <EOL> is_and = True <EOL> elif word == '<STR_LIT>' : <EOL> unique = True <EOL> elif word == '<STR_LIT>' : <EOL> is_casesensitive = False <EOL> elif word == '<STR_LIT>' : <EOL> ignore_str = tline . pop ( <NUM_LIT:0> ) <EOL> ignore_str = strip_string ( ignore_str ) <EOL> elif word == '<STR_LIT>' and not self . grep_cluster : <EOL> start_tm = tline . pop ( <NUM_LIT:0> ) <EOL> start_tm = strip_string ( start_tm ) <EOL> elif word == '<STR_LIT>' and not self . grep_cluster : <EOL> duration = tline . pop ( <NUM_LIT:0> ) <EOL> duration = strip_string ( duration ) <EOL> elif word == '<STR_LIT>' : <EOL> try : <EOL> sources = [ <EOL> int ( i ) for i in strip_string ( <EOL> tline . pop ( <NUM_LIT:0> ) ) . split ( "<STR_LIT:U+002C>" ) ] <EOL> except : <EOL> sources = [ ] <EOL> elif reading_search_strings : <EOL> try : <EOL> search_strs . append ( strip_string ( word ) ) <EOL> except : <EOL> pass <EOL> search_string_read = True <EOL> else : <EOL> raise ShellException ( <EOL> "<STR_LIT>" % ( word , "<STR_LIT:U+0020>" . join ( line ) ) ) <EOL> if not search_string_read : <EOL> reading_search_strings = False <EOL> if search_strs : <EOL> files = self . logger . get_files_by_index ( <EOL> self . grep_cluster , <EOL> sources ) <EOL> for timestamp in sorted ( files . keys ( ) ) : <EOL> res = self . logger . grepCount ( <EOL> files [ timestamp ] , <EOL> search_strs , ignore_str , <EOL> unique , self . grep_cluster , <EOL> start_tm , duration , <EOL> is_and , is_casesensitive ) <EOL> merged_res = "<STR_LIT>" <EOL> for key in sorted ( res . keys ( ) ) : <EOL> str = "<STR_LIT:U+0020>" <EOL> if not self . grep_cluster : <EOL> str = key + "<STR_LIT>" <EOL> merged_res += str + "<STR_LIT>" % ( search_strs , res [ key ] ) <EOL> merged_res += "<STR_LIT:\n>" <EOL> self . view . infoString ( timestamp , merged_res ) <EOL> def do_diff ( self , line ) : <EOL> if not line : <EOL> raise ShellException ( "<STR_LIT>" + <EOL> "<STR_LIT>" ) <EOL> mods = self . parseModifiers ( line ) <EOL> line = mods [ '<STR_LIT>' ] <EOL> tline = line [ : ] <EOL> search_str = "<STR_LIT>" <EOL> start_tm = "<STR_LIT>" <EOL> duration = "<STR_LIT>" <EOL> slice_tm = "<STR_LIT>" <EOL> show_count = <NUM_LIT:1> <EOL> limit = "<STR_LIT>" <EOL> sources = [ ] <EOL> is_casesensitive = True <EOL> while tline : <EOL> word = tline . pop ( <NUM_LIT:0> ) <EOL> if word == '<STR_LIT>' : <EOL> search_str = tline . pop ( <NUM_LIT:0> ) <EOL> search_str = strip_string ( search_str ) <EOL> elif word == '<STR_LIT>' : <EOL> start_tm = tline . pop ( <NUM_LIT:0> ) <EOL> start_tm = strip_string ( start_tm ) <EOL> elif word == '<STR_LIT>' : <EOL> duration = tline . pop ( <NUM_LIT:0> ) <EOL> duration = strip_string ( duration ) <EOL> elif word == '<STR_LIT>' : <EOL> slice_tm = tline . pop ( <NUM_LIT:0> ) <EOL> slice_tm = strip_string ( slice_tm ) <EOL> elif word == '<STR_LIT>' : <EOL> show_count = tline . pop ( <NUM_LIT:0> ) <EOL> show_count = int ( strip_string ( show_count ) ) <EOL> elif word == '<STR_LIT>' : <EOL> is_casesensitive = False <EOL> elif word == '<STR_LIT>' : <EOL> try : <EOL> sources = [ <EOL> int ( i ) for i in strip_string ( <EOL> tline . pop ( <NUM_LIT:0> ) ) . split ( "<STR_LIT:U+002C>" ) ] <EOL> except : <EOL> sources = [ ] <EOL> elif word == '<STR_LIT>' and tline : <EOL> limit = tline . pop ( <NUM_LIT:0> ) <EOL> limit = int ( strip_string ( limit ) ) <EOL> else : <EOL> raise ShellException ( <EOL> "<STR_LIT>" % ( word , "<STR_LIT:U+0020>" . join ( line ) ) ) <EOL> grepRes = { } <EOL> if search_str : <EOL> files = self . logger . get_files_by_index ( <EOL> self . grep_cluster , <EOL> sources ) <EOL> for timestamp in sorted ( files . keys ( ) ) : <EOL> grep_res = self . logger . grepDiff ( <EOL> files [ timestamp ] , <EOL> search_str , <EOL> self . grep_cluster , <EOL> start_tm , <EOL> duration , <EOL> slice_tm , <EOL> show_count , <EOL> limit , is_casesensitive ) <EOL> self . view . showGrepDiff ( timestamp , grep_res ) <EOL> def do_latency ( self , line ) : <EOL> if not line : <EOL> raise ShellException ( <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" ) <EOL> mods = self . parseModifiers ( line ) <EOL> line = mods [ '<STR_LIT>' ] <EOL> tline = line [ : ] <EOL> hist = "<STR_LIT>" <EOL> start_tm = "<STR_LIT>" <EOL> duration = None <EOL> slice_tm = "<STR_LIT>" <EOL> bucket_count = <NUM_LIT:3> <EOL> show_count = <NUM_LIT:3> <EOL> sources = [ ] <EOL> no_time_rounding = False <EOL> while tline : <EOL> word = tline . pop ( <NUM_LIT:0> ) <EOL> if word == '<STR_LIT>' : <EOL> hist = tline . pop ( <NUM_LIT:0> ) <EOL> hist = strip_string ( hist ) <EOL> elif word == '<STR_LIT>' : <EOL> start_tm = tline . pop ( <NUM_LIT:0> ) <EOL> start_tm = strip_string ( start_tm ) <EOL> elif word == '<STR_LIT>' : <EOL> duration = tline . pop ( <NUM_LIT:0> ) <EOL> duration = strip_string ( duration ) <EOL> elif word == '<STR_LIT>' : <EOL> slice_tm = tline . pop ( <NUM_LIT:0> ) <EOL> slice_tm = strip_string ( slice_tm ) <EOL> elif word == '<STR_LIT>' : <EOL> show_count = tline . pop ( <NUM_LIT:0> ) <EOL> show_count = int ( strip_string ( show_count ) ) <EOL> elif word == '<STR_LIT>' : <EOL> bucket_count = tline . pop ( <NUM_LIT:0> ) <EOL> bucket_count = int ( strip_string ( bucket_count ) ) <EOL> elif word == '<STR_LIT>' : <EOL> try : <EOL> sources = [ <EOL> int ( i ) for i in strip_string ( <EOL> tline . pop ( <NUM_LIT:0> ) ) . split ( "<STR_LIT:U+002C>" ) ] <EOL> except : <EOL> sources = [ ] <EOL> elif word == '<STR_LIT>' : <EOL> no_time_rounding = True <EOL> else : <EOL> raise ShellException ( <EOL> "<STR_LIT>" % ( word , "<STR_LIT:U+0020>" . join ( line ) ) ) <EOL> if hist : <EOL> files = self . logger . get_files_by_index ( <EOL> self . grep_cluster , <EOL> sources ) <EOL> for timestamp in sorted ( files . keys ( ) ) : <EOL> latency_res = self . logger . loglatency ( <EOL> files [ timestamp ] , <EOL> hist , <EOL> slice_tm , <EOL> start_tm , <EOL> duration , <EOL> bucket_count , <EOL> show_count , <EOL> no_time_rounding ) <EOL> self . view . showLogLatency ( timestamp , latency_res ) <EOL> @ CommandHelp ( '<STR_LIT>' ) <EOL> class LogGrepClusterController ( CommandController ) : <EOL> def __init__ ( self ) : <EOL> self . modifiers = set ( ) <EOL> self . grepFile = GrepFile ( True , self . modifiers ) <EOL> def _do_default ( self , line ) : <EOL> self . grepFile . do_show ( line ) <EOL> @ CommandHelp ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> def do_show ( self , line ) : <EOL> self . grepFile . do_show ( line ) <EOL> @ CommandHelp ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> def do_count ( self , line ) : <EOL> self . grepFile . do_count ( line ) <EOL> @ CommandHelp ( '<STR_LIT>' ) <EOL> class HealthController ( CommandController ) : <EOL> def __init__ ( self ) : <EOL> self . controller_map = { <EOL> '<STR_LIT>' : HealthClusterController , <EOL> '<STR_LIT>' : HealthServersController } <EOL> self . modifiers = set ( ) <EOL> def _do_default ( self , line ) : <EOL> self . executeHelp ( line ) <EOL> @ CommandHelp ( '<STR_LIT>' ) <EOL> class ListController ( CommandController ) : <EOL> def __init__ ( self ) : <EOL> self . controller_map = { } <EOL> self . modifiers = set ( ) <EOL> def _do_default ( self , line ) : <EOL> self . do_all ( line ) <EOL> @ CommandHelp ( '<STR_LIT>' ) <EOL> def do_all ( self , line ) : <EOL> print "<STR_LIT>" <EOL> index = <NUM_LIT:1> <EOL> all_cluster_files = self . logger . get_list ( cluster_snapshot = True , all_list = True ) <EOL> for timestamp in sorted ( all_cluster_files . keys ( ) ) : <EOL> print str ( index ) + "<STR_LIT>" + timestamp + "<STR_LIT:\t>" + all_cluster_files [ timestamp ] <EOL> index += <NUM_LIT:1> <EOL> print "<STR_LIT>" <EOL> index = <NUM_LIT:1> <EOL> all_server_files = self . logger . get_list ( cluster_snapshot = False , all_list = True ) <EOL> for node in sorted ( all_server_files . keys ( ) ) : <EOL> print str ( index ) + "<STR_LIT>" + node + "<STR_LIT:\t>" + all_server_files [ node ] <EOL> index += <NUM_LIT:1> <EOL> @ CommandHelp ( '<STR_LIT>' ) <EOL> def do_selected ( self , line ) : <EOL> print "<STR_LIT>" <EOL> index = <NUM_LIT:1> <EOL> selected_cluster_files = self . logger . get_list ( cluster_snapshot = True , all_list = False ) <EOL> for timestamp in sorted ( selected_cluster_files . keys ( ) ) : <EOL> print str ( index ) + "<STR_LIT>" + timestamp + "<STR_LIT:\t>" + selected_cluster_files [ timestamp ] <EOL> index += <NUM_LIT:1> <EOL> print "<STR_LIT>" <EOL> index = <NUM_LIT:1> <EOL> selected_server_files = self . logger . get_list ( cluster_snapshot = False , all_list = False ) <EOL> for node in sorted ( selected_server_files . keys ( ) ) : <EOL> print str ( index ) + "<STR_LIT>" + node + "<STR_LIT:\t>" + selected_server_files [ node ] <EOL> index += <NUM_LIT:1> <EOL> @ CommandHelp ( '<STR_LIT>' ) <EOL> class SelectController ( CommandController ) : <EOL> def __init__ ( self ) : <EOL> self . controller_map = { } <EOL> self . modifiers = set ( ) <EOL> @ CommandHelp ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> def do_time ( self , line ) : <EOL> tline = line [ : ] <EOL> year = "<STR_LIT>" <EOL> month = "<STR_LIT>" <EOL> date = "<STR_LIT>" <EOL> hr = "<STR_LIT>" <EOL> minutes = "<STR_LIT>" <EOL> sec = "<STR_LIT>" <EOL> while tline : <EOL> word = tline . pop ( <NUM_LIT:0> ) <EOL> if word == '<STR_LIT>' : <EOL> year = tline . pop ( <NUM_LIT:0> ) <EOL> year = strip_string ( year ) <EOL> elif word == '<STR_LIT>' : <EOL> month = tline . pop ( <NUM_LIT:0> ) <EOL> month = strip_string ( month ) <EOL> elif word == '<STR_LIT>' : <EOL> date = tline . pop ( <NUM_LIT:0> ) <EOL> date = strip_string ( date ) <EOL> elif word == '<STR_LIT>' : <EOL> hr = tline . pop ( <NUM_LIT:0> ) <EOL> hr = strip_string ( hr ) <EOL> elif word == '<STR_LIT>' : <EOL> minutes = tline . pop ( <NUM_LIT:0> ) <EOL> minutes = strip_string ( minutes ) <EOL> elif word == '<STR_LIT>' : <EOL> sec = tline . pop ( <NUM_LIT:0> ) <EOL> sec = strip_string ( sec ) <EOL> else : <EOL> raise ShellException ( <EOL> "<STR_LIT>" % ( word , "<STR_LIT:U+0020>" . join ( line ) ) ) <EOL> self . logger . select_cluster_snapshots ( <EOL> year , <EOL> month , <EOL> date , <EOL> hr , <EOL> minutes , <EOL> sec ) <EOL> @ CommandHelp ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> def do_cluster ( self , line ) : <EOL> self . logger . select_logs ( line , cluster_snapshot = True ) <EOL> @ CommandHelp ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> def do_server ( self , line ) : <EOL> self . logger . select_logs ( line , cluster_snapshot = False ) <EOL> class HealthClusterController ( CommandController ) : <EOL> def __init__ ( self ) : <EOL> self . modifiers = set ( ) <EOL> self . grepFile = GrepFile ( True , self . modifiers ) <EOL> @ CommandHelp ( '<STR_LIT>' ) <EOL> def _do_default ( self , line ) : <EOL> service_stats = self . logger . infoStatistics ( stanza = "<STR_LIT>" ) <EOL> namespace_stats = self . logger . infoStatistics ( stanza = "<STR_LIT>" ) <EOL> asserts = { } <EOL> NOT_OK = <NUM_LIT:0> <EOL> WARNING = <NUM_LIT:0> <EOL> CRITICAL = <NUM_LIT:0> <EOL> for timestamp in sorted ( service_stats . keys ( ) ) : <EOL> asserts [ timestamp ] = { } <EOL> tot_objects = <NUM_LIT:0> <EOL> tot_refs = <NUM_LIT:0> <EOL> for node , stats in service_stats [ timestamp ] . iteritems ( ) : <EOL> tot_objects += int ( stats [ "<STR_LIT>" ] ) <EOL> tot_refs += int ( stats [ "<STR_LIT>" ] ) <EOL> if tot_objects != tot_refs : <EOL> asserts [ timestamp ] [ "<STR_LIT>" ] = "<STR_LIT>" + str ( tot_objects ) + "<STR_LIT>" + str ( tot_refs ) <EOL> WARNING += <NUM_LIT:1> <EOL> for timestamp in sorted ( service_stats . keys ( ) ) : <EOL> print terminal . fg_blue ( ) + "<STR_LIT>" % ( timestamp ) + terminal . fg_clear ( ) <EOL> for node , string in asserts [ timestamp ] . iteritems ( ) : <EOL> print terminal . bold ( ) + node + terminal . unbold ( ) + terminal . fg_red ( ) + string + terminal . fg_clear ( ) <EOL> class HealthServersController ( CommandController ) : <EOL> def __init__ ( self ) : <EOL> self . modifiers = set ( ) <EOL> self . grepFile = GrepFile ( False , self . modifiers ) <EOL> @ CommandHelp ( '<STR_LIT>' ) <EOL> def _do_default ( self , line ) : <EOL> print "<STR_LIT>" <EOL> @ CommandHelp ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> class AddController ( CommandController ) : <EOL> def __init__ ( self ) : <EOL> self . controller_map = { <EOL> '<STR_LIT>' : AddClusterController , '<STR_LIT>' : AddServerController <EOL> } <EOL> self . modifiers = set ( ) <EOL> def _do_default ( self , line ) : <EOL> self . executeHelp ( line ) <EOL> @ CommandHelp ( "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> class AddClusterController ( CommandController ) : <EOL> def __init__ ( self ) : <EOL> self . modifiers = set ( ) <EOL> def _do_default ( self , line ) : <EOL> for path in line : <EOL> path = strip_string ( path ) <EOL> snapshots_added , error = self . logger . add_cluster_snapshots ( path ) <EOL> if snapshots_added == <NUM_LIT:1> : <EOL> print "<STR_LIT>" % ( snapshots_added ) <EOL> elif snapshots_added > <NUM_LIT:1> : <EOL> print "<STR_LIT>" % ( snapshots_added ) <EOL> if error : <EOL> print "<STR_LIT:\n>" + terminal . fg_red ( ) + error + terminal . fg_clear ( ) <EOL> @ CommandHelp ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> class AddServerController ( CommandController ) : <EOL> def __init__ ( self ) : <EOL> self . modifiers = set ( ) <EOL> def _do_default ( self , line ) : <EOL> length = len ( line ) <EOL> if length < <NUM_LIT:2> : <EOL> return <EOL> for index in range ( <NUM_LIT:0> , length , <NUM_LIT:2> ) : <EOL> if index == length - <NUM_LIT:1> : <EOL> break <EOL> path = strip_string ( line [ index + <NUM_LIT:1> ] ) <EOL> prefix = strip_string ( line [ index ] ) <EOL> server_logs_added , error = self . logger . add_server_logs ( prefix , path ) <EOL> if server_logs_added == <NUM_LIT:1> : <EOL> print "<STR_LIT>" % ( server_logs_added ) <EOL> elif server_logs_added > <NUM_LIT:1> : <EOL> print "<STR_LIT>" % ( server_logs_added ) <EOL> if error : <EOL> print "<STR_LIT:\n>" + terminal . fg_red ( ) + error + terminal . fg_clear ( ) <EOL> @ CommandHelp ( <EOL> '<STR_LIT>' ) <EOL> class RemoveController ( CommandController ) : <EOL> def __init__ ( self ) : <EOL> self . controller_map = { <EOL> '<STR_LIT>' : RemoveClusterController , '<STR_LIT>' : RemoveServerController <EOL> } <EOL> self . modifiers = set ( ) <EOL> def _do_default ( self , line ) : <EOL> self . executeHelp ( line ) <EOL> @ CommandHelp ( "<STR_LIT>" ) <EOL> class RemoveClusterController ( CommandController ) : <EOL> def __init__ ( self ) : <EOL> self . modifiers = set ( ) <EOL> @ CommandHelp ( '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> def _do_default ( self , line ) : <EOL> if not line : <EOL> raise ShellException ( <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" ) <EOL> mods = self . parseModifiers ( line ) <EOL> line = mods [ '<STR_LIT>' ] <EOL> tline = line [ : ] <EOL> selected_remove_list = [ ] <EOL> all_remove_list = [ ] <EOL> while tline : <EOL> word = tline . pop ( <NUM_LIT:0> ) <EOL> if word == '<STR_LIT>' : <EOL> try : <EOL> values = strip_string ( tline . pop ( <NUM_LIT:0> ) ) <EOL> for i in values . split ( "<STR_LIT:U+002C>" ) : <EOL> index = int ( i ) - <NUM_LIT:1> <EOL> all_remove_list . append ( index ) <EOL> except : <EOL> pass <EOL> elif word == '<STR_LIT>' : <EOL> try : <EOL> values = strip_string ( tline . pop ( <NUM_LIT:0> ) ) <EOL> for i in values . split ( "<STR_LIT:U+002C>" ) : <EOL> index = int ( i ) - <NUM_LIT:1> <EOL> selected_remove_list . append ( index ) <EOL> except : <EOL> pass <EOL> else : <EOL> raise ShellException ( "<STR_LIT>" % ( word , "<STR_LIT:U+0020>" . join ( line ) ) ) <EOL> all_rm_list = self . logger . get_name_by_index ( indices = all_remove_list , cluster_snapshot = True , from_all_list = True ) <EOL> selected_rm_list = self . logger . get_name_by_index ( indices = selected_remove_list , cluster_snapshot = True , from_all_list = False ) <EOL> if all_rm_list : <EOL> self . logger . remove_logs ( all_rm_list ) <EOL> if selected_rm_list : <EOL> self . logger . remove_logs ( selected_rm_list , from_all_list = False ) <EOL> @ CommandHelp ( "<STR_LIT>" ) <EOL> class RemoveServerController ( CommandController ) : <EOL> def __init__ ( self ) : <EOL> self . modifiers = set ( ) <EOL> @ CommandHelp ( '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> def _do_default ( self , line ) : <EOL> if not line : <EOL> raise ShellException ( <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" ) <EOL> mods = self . parseModifiers ( line ) <EOL> line = mods [ '<STR_LIT>' ] <EOL> tline = line [ : ] <EOL> selected_remove_list = [ ] <EOL> all_remove_list = [ ] <EOL> while tline : <EOL> word = tline . pop ( <NUM_LIT:0> ) <EOL> if word == '<STR_LIT>' : <EOL> try : <EOL> values = strip_string ( tline . pop ( <NUM_LIT:0> ) ) <EOL> for i in values . split ( "<STR_LIT:U+002C>" ) : <EOL> index = int ( i ) - <NUM_LIT:1> <EOL> all_remove_list . append ( index ) <EOL> except : <EOL> pass <EOL> elif word == '<STR_LIT>' : <EOL> try : <EOL> values = strip_string ( tline . pop ( <NUM_LIT:0> ) ) <EOL> for i in values . split ( "<STR_LIT:U+002C>" ) : <EOL> index = int ( i ) - <NUM_LIT:1> <EOL> selected_remove_list . append ( index ) <EOL> except : <EOL> pass <EOL> else : <EOL> raise ShellException ( "<STR_LIT>" % ( word , "<STR_LIT:U+0020>" . join ( line ) ) ) <EOL> all_rm_list = self . logger . get_name_by_index ( indices = all_remove_list , cluster_snapshot = False , from_all_list = True ) <EOL> selected_rm_list = self . logger . get_name_by_index ( indices = selected_remove_list , cluster_snapshot = False , from_all_list = False ) <EOL> if all_rm_list : <EOL> self . logger . remove_logs ( all_rm_list , cluster_snapshot = False , from_all_list = True ) <EOL> if selected_rm_list : <EOL> self . logger . remove_logs ( selected_rm_list , cluster_snapshot = False , from_all_list = False ) <EOL> @ CommandHelp ( "<STR_LIT>" ) <EOL> class PagerController ( CommandController ) : <EOL> def __init__ ( self ) : <EOL> self . modifiers = set ( ) <EOL> def _do_default ( self , line ) : <EOL> self . executeHelp ( line ) <EOL> @ CommandHelp ( "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> def do_less ( self , line ) : <EOL> CliView . pager = CliView . LESS <EOL> @ CommandHelp ( "<STR_LIT>" ) <EOL> def do_remove ( self , line ) : <EOL> CliView . pager = CliView . NO_PAGER <EOL> @ CommandHelp ( "<STR_LIT>" ) <EOL> def do_show ( self , line ) : <EOL> CliView . print_pager ( ) </s>
