From 7bfa0658bd7e6ffa526ed965fb4a9680414320e5 Mon Sep 17 00:00:00 2001 From: Tomas Jelinek Date: Tue, 19 Feb 2019 15:40:05 +0100 Subject: [PATCH 1/3] cache tokens read from pcsd --- pcs/cluster.py | 4 ++++ pcs/status.py | 1 + pcs/utils.py | 1 + 3 files changed, 6 insertions(+) diff --git a/pcs/cluster.py b/pcs/cluster.py index 7d13e11e..8cb27c82 100644 --- a/pcs/cluster.py +++ b/pcs/cluster.py @@ -1167,6 +1167,7 @@ def start_cluster_nodes(nodes): ) was_error = False + utils.read_token_file() # cache node tokens task_list = [ IsComponentStartSupported(node) for node in nodes ] @@ -1278,6 +1279,7 @@ def wait_for_nodes_started(node_list, timeout=None): else: print(output) else: + utils.read_token_file() # cache node tokens node_errors = parallel_for_nodes( wait_for_remote_node_started, node_list, stop_at, interval ) @@ -1296,6 +1298,7 @@ def stop_cluster_nodes(nodes): % "', '".join(unknown_nodes) ) + utils.read_token_file() # cache node tokens stopping_all = set(nodes) >= set(all_nodes) if "--force" not in utils.pcs_options and not stopping_all: error_list = [] @@ -1406,6 +1409,7 @@ def destroy_cluster(argv, keep_going=False): if len(argv) > 0: # stop pacemaker and resources while cluster is still quorate nodes = argv + utils.read_token_file() # cache node tokens node_errors = parallel_for_nodes( utils.repeat_if_timeout(utils.stopPacemaker), nodes, diff --git a/pcs/status.py b/pcs/status.py index 69cea716..647faed8 100644 --- a/pcs/status.py +++ b/pcs/status.py @@ -401,6 +401,7 @@ def check_nodes(node_list, prefix=""): )) status_list.append(returncode) + utils.read_token_file() # cache node tokens utils.run_parallel( utils.create_task_list(report, utils.checkAuthorization, node_list) ) diff --git a/pcs/utils.py b/pcs/utils.py index 343a611b..839e931f 100644 --- a/pcs/utils.py +++ b/pcs/utils.py @@ -245,6 +245,7 @@ def remove_uid_gid_file(uid,gid): def readTokens(): return read_token_file()["tokens"] +@simple_cache def read_token_file(): data = { "tokens": {}, -- 2.17.0