def remove_one_replica_from_elasticsearch_index(cluster: str, index: str, force: bool = False): """Remove one replica.""" elastic = sreElastic(host=cluster) elastic.decr_replica_amount(index=index, without_confirmation=force)
def add_one_replica_to_elasticsearch_index(cluster: str, index: str, force: bool = False): """Add one replica.""" elastic = sreElastic(host=cluster) elastic.incr_replica_amount(index=index, without_confirmation=force)
def show_elasticsearch_index_info(cluster: str, index: str): """Show index allocation and routing settings.""" elastic = sreElastic(host=cluster) pp = pprint.PrettyPrinter(indent=2, width=120) print("\nLocation:") pp.pprint(elastic.get_index_location(index)) print("\nRouting:") pp.pprint(elastic.get_index_routing(index)) print("\n")
def move_index_to_nodes(cluster: str, index: str, nodes: tuple, timeout: int, force: bool = False): """Move index shard by shard to the new location.""" elastic = sreElastic(host=cluster) elastic.move_index_to_custom_nodes(index=index, nodes=nodes, timeout=timeout, without_confirmation=force)
def reset_elasticsearch_index_allocation(cluster: str, index: str): """Reset index allocation (remove allocation settings).""" elastic = sreElastic(host=cluster) elastic.index_reset(index=index)
def fix__elasticsearch_index_allocation(cluster: str, index: str): """Fix index allocation to the current data nodes.""" elastic = sreElastic(host=cluster) elastic.index_fix(index=index)
def wait_for_elasticsearch_index(cluster: str, index: str): """Wait until index relocating""" elastic = sreElastic(host=cluster) elastic.wait_index_relocation(index=index)
def show_elasticsearch_indices(cluster: str, node: str): """Show elasticsearch indices with additional information""" elastic = sreElastic(host=cluster) elastic.list_indices(only_this_node=node)
def delete_elasticsearch_index(cluster: str, index: str): """Delete index.""" elastic = sreElastic(host=cluster) elastic.delete_index(index=index)
def setup_index_shards_per_node(cluster: str, index: str, number: int): """Set number of shards per one node setting.""" elastic = sreElastic(host=cluster) elastic.set_number_shards_per_node(index=index, number=number)