From 6e7837411da81af19311418047b719e689a8c5ad Mon Sep 17 00:00:00 2001 From: Justin Henderson Date: Tue, 26 Apr 2022 03:44:10 +0000 Subject: [PATCH] go --- allocation.py | 21 ++++++++++++++++----- retention.py | 2 +- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/allocation.py b/allocation.py index ae172fd..1bc39df 100644 --- a/allocation.py +++ b/allocation.py @@ -59,12 +59,23 @@ def allocate_indices(client_config, index, index_allocation_policies): allocation_type = key if allocation_type != '': # Change index allocation per policy - print("Changing allocation of index " + str(index) + \ - " to " + str(allocation_type)) - elastic_connection.indices.put_settings( - index=index, - body={"index.routing.allocation.require.box_type": allocation_type} + index_settings = elastic_connection.indices.get_settings( + index=index ) + index_settings = index_settings[index]['settings']['index'] + box_type = 'hot' + if 'routing' in index_settings: + if 'allocation' in index_settings['routing']: + if 'require' in index_settings['routing']['allocation']: + if 'box_type' in index_settings['routing']['allocation']['require']: + box_type= index_settings['routing']['allocation']['require']['box_type'] + if allocation_type != box_type: + print("Changing allocation of index " + str(index) + \ + " to " + str(allocation_type)) + elastic_connection.indices.put_settings( + index=index, + body={"index.routing.allocation.require.box_type": allocation_type} + ) elastic_connection.close() def apply_allocation_to_indices(indices, index_allocation_policies, client_config): diff --git a/retention.py b/retention.py index dcc92a6..2708657 100644 --- a/retention.py +++ b/retention.py @@ -95,7 +95,7 @@ def apply_retention_policies(health_check_level, manual_client=""): print("Processing retention for " + client_name) # If client set at command line only run it otherwise # execute for all clients - if limit_to_client == client_name or limit_to_client == "": + if limit_to_client == manual_client or limit_to_client == "": while retry_count >= 0 and success == 0: # Check cluster health - Expect Yellow to continue if es.check_cluster_health_status(client_config, health_check_level):