def print_lustre_versions(log, lustre_versions, status=False, print_table=True, field_string=None): """ Print table of BarreleAgent. """ # pylint: disable=too-many-branches,too-many-locals,too-many-statements if not print_table and len(lustre_versions) > 1: log.cl_error("failed to print non-table output with multiple " "Lustre versions") return -1 quick_fields = [barrele_constant.BARRELE_FIELD_LUSTRE_VERSION] slow_fields = [] none_table_fields = [] table_fields = quick_fields + slow_fields all_fields = table_fields + none_table_fields if isinstance(field_string, bool): cmd_general.print_all_fields(log, all_fields) return 0 field_names = cmd_general.parse_field_string(log, field_string, quick_fields, table_fields, all_fields, print_status=status, print_table=print_table) if field_names is None: log.cl_error("invalid field string [%s] for Lustre version", field_string) return -1 rc = cmd_general.print_list(log, lustre_versions, quick_fields, slow_fields, none_table_fields, lustre_version_field, print_table=print_table, print_status=status, field_string=field_string) return rc
def print_servers(log, barreleye_instance, servers, status=False, print_table=True, field_string=None): """ Print table of BarreleServer. """ # pylint: disable=too-many-branches,too-many-locals,too-many-statements if not print_table and len(servers) > 1: log.cl_error("failed to print non-table output with multiple " "servers") return -1 quick_fields = [barrele_constant.BARRELE_FIELD_HOST] slow_fields = [ barrele_constant.BARRELE_FIELD_UP, barrele_constant.BARRELE_FIELD_INFLUXDB, barrele_constant.BARRELE_FIELD_GRAFANA ] none_table_fields = [ barrele_constant.BARRELE_FIELD_INFLUXDB_VERSION, barrele_constant.BARRELE_FIELD_GRAFANA_VERSION ] table_fields = quick_fields + slow_fields all_fields = table_fields + none_table_fields if isinstance(field_string, bool): cmd_general.print_all_fields(log, all_fields) return 0 field_names = cmd_general.parse_field_string(log, field_string, quick_fields, table_fields, all_fields, print_status=status, print_table=print_table) if field_names is None: log.cl_error("invalid field string [%s] for server", field_string) return -1 server_status_list = [] for server in servers: server_status = BarreleServerStatusCache(barreleye_instance, server) server_status_list.append(server_status) if (len(server_status_list) > 0 and not server_status_list[0].bssc_can_skip_init_fields(field_names)): args_array = [] thread_ids = [] for server_status in server_status_list: args = (server_status, field_names) args_array.append(args) server = server_status.bssc_server hostname = server.bes_server_host.sh_hostname thread_id = "server_status_%s" % hostname thread_ids.append(thread_id) parallel_execute = parallel.ParallelExecute( log, barreleye_instance.bei_workspace, "server_status", server_status_init, args_array, thread_ids=thread_ids, parallelism=10) ret = parallel_execute.pe_run() if ret: log.cl_error("failed to init fields %s for servers", field_names) return -1 rc = cmd_general.print_list(log, server_status_list, quick_fields, slow_fields, none_table_fields, server_status_field, print_table=print_table, print_status=status, field_string=field_string) return rc
def print_agents(log, barreleye_instance, agents, status=False, print_table=True, field_string=None): """ Print table of BarreleAgent. """ # pylint: disable=too-many-branches,too-many-locals,too-many-statements if not print_table and len(agents) > 1: log.cl_error("failed to print non-table output with multiple " "agents") return -1 quick_fields = [barrele_constant.BARRELE_FIELD_HOST] slow_fields = [ barrele_constant.BARRELE_FIELD_UP, barrele_constant.BARRELE_FIELD_COLLECTD, barrele_constant.BARRELE_FIELD_COLLECTD_VERSION ] none_table_fields = [] table_fields = quick_fields + slow_fields all_fields = table_fields + none_table_fields if isinstance(field_string, bool): cmd_general.print_all_fields(log, all_fields) return 0 field_names = cmd_general.parse_field_string(log, field_string, quick_fields, table_fields, all_fields, print_status=status, print_table=print_table) if field_names is None: log.cl_error("invalid field string [%s] for agent", field_string) return -1 agent_status_list = [] for agent in agents: agent_status = BarreleAgentStatusCache(barreleye_instance, agent) agent_status_list.append(agent_status) if (len(agent_status_list) > 0 and not agent_status_list[0].basc_can_skip_init_fields(field_names)): args_array = [] thread_ids = [] for agent_status in agent_status_list: args = (agent_status, field_names) args_array.append(args) agent = agent_status.basc_agent hostname = agent.bea_host.sh_hostname thread_id = "agent_status_%s" % hostname thread_ids.append(thread_id) parallel_execute = parallel.ParallelExecute( log, barreleye_instance.bei_workspace, "agent_status", agent_status_init, args_array, thread_ids=thread_ids, parallelism=10) ret = parallel_execute.pe_run() if ret: log.cl_error("failed to init fields %s for agents", field_names) return -1 rc = cmd_general.print_list(log, agent_status_list, quick_fields, slow_fields, none_table_fields, agent_status_field, print_table=print_table, print_status=status, field_string=field_string) return rc