def clear_zone_awareness(es): # There doesn't appear to be a proper way to unset settings # https://github.com/elastic/elasticsearch/issues/6732 cluster = ClusterClient(es) cmd = {"persistent": {"cluster.routing.allocation.awareness.force.zone.values": "", "cluster.routing.allocation.awareness.attributes": ""}} confirm("Remove the allocation awareness settings from the cluster?") pprint(cluster.put_settings(cmd)) print("Cleared")
def force_zone_awareness(es): cluster = ClusterClient(es) print("NODE SETTINGS:") for node in get_nodes_info(es): pprint(node.settings) zones = input("\nEnter the zone names, separated by a comma\n") confirm("Are you sure these zones exist?") cmd = {"persistent": {"cluster.routing.allocation.awareness.force.zone.values": zones, "cluster.routing.allocation.awareness.attributes": "zone"}} print("This will add the following settings") pprint(cmd) confirm("Okay?") pprint(cluster.put_settings(cmd)) print("Finished")
def force_zone_awareness(es): cluster = ClusterClient(es) print("NODE SETTINGS:") for node in get_nodes_info(es): pprint(node.settings) zones = raw_input("\nEnter the zone names, separated by a comma\n") confirm("Are you sure these zones exist?") cmd = {"persistent": {"cluster.routing.allocation.awareness.force.zone.values": zones, "cluster.routing.allocation.awareness.attributes": "zone"}} print("This will add the following settings") pprint(cmd) confirm("Okay?") pprint(cluster.put_settings(cmd)) print("Finished")
def decommission_node(es): cluster = ClusterClient(es) print("The nodes are:") nodes = get_nodes_info(es) for node in nodes: print(node.name, node.docs) confirm("Are you sure you want to decommission a node?") node_name = raw_input("Which one would you like to decommission?\nname:") names = [node.name for node in nodes] if node_name not in names: print("You must enter one of {}".format(", ".join(names))) return confirm("This will remove all shards from {}, okay?".format(node_name)) cmd = {"transient": {"cluster.routing.allocation.exclude._name": node_name}} pprint(cluster.put_settings(cmd)) print("The node is now being decommissioned.")
def decommission_node(es): cluster = ClusterClient(es) print "The nodes are:" nodes = get_nodes_info(es) for node in nodes: print node.name, node.docs confirm("Are you sure you want to decommission a node?") node_name = raw_input("Which one would you like to decommission?\nname:") names = [node.name for node in nodes] if node_name not in names: print "You must enter one of {}".format(", ".join(names)) return confirm("This will remove all shards from {}, okay?".format(node_name)) cmd = {"transient": {"cluster.routing.allocation.exclude._name": node_name}} pprint(cluster.put_settings(cmd)) print "The node is now being decommissioned."
def _update_max_compilations_limit(es, limit="10000/1m"): print("Updating script.max_compilations_rate to ", limit) cluster_client = ClusterClient(es) body = {"transient": {"script.max_compilations_rate": limit}} cluster_client.put_settings(body=body)