def take_action(self, parsed_args): repository = self.es.snapshot.get_repository( repository=parsed_args.repository, format="json").get(parsed_args.repository) return JSONToCliffFormatter(repository).to_show_one( lines=list(repository.keys()))
def take_action(self, parsed_args): users = [{ "name": user_name, "username": user_definition.get("username"), "password": user_definition.get("password"), } for user_name, user_definition in Esctl._config.get("users").items()] return JSONToCliffFormatter(users).format_for_lister( columns=[("name"), ("username"), ("password")])
def take_action(self, parsed_args): clusters = [{ "name": cluster_name, "servers": "\n".join(cluster_definition.get("servers")), } for cluster_name, cluster_definition in Esctl._config.get( "clusters").items()] return JSONToCliffFormatter(clusters).format_for_lister( columns=[("name"), ("servers")])
def take_action(self, parsed_args): contexts = [{ "name": context_name, "user": context_definition.get("user"), "cluster": context_definition.get("cluster"), } for context_name, context_definition in Esctl._config.get( "contexts").items()] return JSONToCliffFormatter( self.transform(contexts)).format_for_lister( columns=[("name"), ("user"), ("cluster")])
def _settings_get(self, setting: str): s = self.cluster_settings.mget(setting) return JSONToCliffFormatter({ "transient": s.get("transient").value, "persistent": s.get("persistent").value, "defaults": s.get("defaults").value, }).to_show_one( lines=[("transient"), ("persistent"), ("defaults")], none_as="" if self.uses_table_formatter() else None, )
def take_action(self, parsed_args): headers = parsed_args.headers if parsed_args.headers else self._default_headers thread_pools = self.transform( self.es.cat.thread_pool( format="json", h=headers, thread_pool_patterns=parsed_args.thread_pool_patterns, )) return JSONToCliffFormatter(thread_pools).format_for_lister( columns=[(h, ) for h in headers.split(",")])
def take_action(self, parsed_args): roles = self.transform( self._sort_and_order_dict( self.es.security.get_role(format="json", name=parsed_args.roles))) return JSONToCliffFormatter(roles).format_for_lister(columns=[ ("role", ), ("cluster", "Cluster-level permissions"), ("indices", "Index-level permissions"), ("applications", ), ("run_as", ), ])
def take_action(self, parsed_args): users = self.transform( self._sort_and_order_dict( self.es.security.get_user(format="json", username=parsed_args.username))) return JSONToCliffFormatter(users).format_for_lister(columns=[ ("username", ), ("roles", ), ("fullname", ), ("email", ), ("metadata", ), ("enabled", ), ])
def take_action(self, parsed_args): allocation = self.transform(self.es.cat.allocation(format="json")) return JSONToCliffFormatter(allocation).format_for_lister(columns=[ ("shards"), ("disk.indices"), ("disk.used"), ("disk.avail"), ("disk.total"), ("disk.percent"), ("host"), ("ip", "IP"), ("node"), ])
def take_action(self, parsed_args): return JSONToCliffFormatter(self.es.cat.nodes(format="json")).format_for_lister( columns=[ ("ip", "IP"), ("heap.percent",), ("ram.percent",), ("cpu"), ("load_1m"), ("load_5m"), ("load_15m"), ("node.role", "Role"), ("master"), ("name"), ] )
def take_action(self, parsed_args): snapshots = self.transform( self.es.cat.snapshots(repository=parsed_args.repository, format="json")) return JSONToCliffFormatter(snapshots).format_for_lister(columns=[ ("id"), ("status"), ("start_time"), ("end_time"), ("duration"), ("indices"), ("successful_shards"), ("failed_shards"), ("total_shards"), ])
def take_action(self, parsed_args): indices = self.transform( self.es.cat.indices(format="json", index=parsed_args.index) ) return JSONToCliffFormatter(indices).format_for_lister( columns=[ ("index"), ("health",), ("status"), ("uuid", "UUID"), ("pri", "Primary"), ("rep", "Replica"), ("docs.count"), ("docs.deleted"), ("store.size"), ("pri.store.size", "Primary Store Size"), ] )
def take_action(self, parsed_args): stats = self.es.nodes.stats( format="json", node_id=parsed_args.node, metric=parsed_args.metric, index_metric=parsed_args.index_metric, level=parsed_args.level, ).get("nodes") if parsed_args.jmespath is not None: path = self.jmespath_search(parsed_args.jmespath, stats) return (tuple(["Result"]), tuple([path])) stats = self.transform(stats) return JSONToCliffFormatter( stats, pretty_key=not parsed_args.no_pretty ).to_show_one(lines=list(stats.keys()))
def take_action(self, parsed_args): nodes = [ n.get("name") for n in self.es.cat.nodes(format="json", h="name") ] shards = self.transform( self.es.cat.shards(format="json", index=parsed_args.index, h="index,node,shard,prirep"), nodes, ) columns = [("index", )] + [( n, n.lower(), ) for n in nodes] if self.has_unassigned_shards: columns = columns + [("UNASSIGNED", )] return JSONToCliffFormatter(shards).format_for_lister(columns=columns)
def take_action(self, parsed_args): tasks = self.transform( self.es.tasks.list( actions=parsed_args.actions, detailed=parsed_args.detailed, parent_task_id=parsed_args.parent_task_id, ).get("nodes") ) return JSONToCliffFormatter(tasks).format_for_lister( columns=[ ("name"), ("node"), ("id"), ("type"), ("action"), ("start_time_human_readable"), ("running_time_in_nanos"), ("parent_task_id"), ("cancellable"), ("headers"), ] )
def take_action(self, parsed_args): aliases = self.es.cat.aliases(name=parsed_args.alias, format="json") return JSONToCliffFormatter(aliases).format_for_lister( columns=[("index",), ("alias",)] )
def take_action(self, parsed_args): templates = self.es.cat.templates(name=parsed_args.name, format="json") return JSONToCliffFormatter(templates).format_for_lister(columns=[( "name", ), ("index_patterns", ), ("order", ), ("version")])
def take_action(self, parsed_args): plugins = self.transform(self.es.cat.plugins(format="json")) return JSONToCliffFormatter(plugins).format_for_lister( columns=[("name", "node"), ("component", "plugin"), ("version")])
def take_action(self, parsed_args): document = flatten_dict( self.es.get(format="json", index=parsed_args.index, id=parsed_args.id) ) return JSONToCliffFormatter(document).to_show_one(lines=list(document.keys()))
def take_action(self, parsed_args): return JSONToCliffFormatter( self.retrieve_setting( parsed_args.setting, parsed_args.index)).format_for_lister( columns=[("index", ), ("setting", ), ("value", )])
def take_action(self, parsed_args): repositories = self.es.cat.repositories(format="json") return JSONToCliffFormatter(repositories).format_for_lister( columns=[("id"), ("type")])