From 022aa317b509fa8228133d6d2a5d1ed308037133 Mon Sep 17 00:00:00 2001 From: chengyang Date: Mon, 20 Nov 2017 17:10:49 +0800 Subject: [PATCH] Improve code to reduce traverse times There is no need to traverse 3 times to get all guestagents. Improve code to recude the count to 1. Change-Id: I134a1624f54f6ad6bee069df76fef4d7112c05a1 --- .../cluster/experimental/galera_common/taskmanager.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/trove/common/strategies/cluster/experimental/galera_common/taskmanager.py b/trove/common/strategies/cluster/experimental/galera_common/taskmanager.py index 47972ea956..e3bfb6bd43 100644 --- a/trove/common/strategies/cluster/experimental/galera_common/taskmanager.py +++ b/trove/common/strategies/cluster/experimental/galera_common/taskmanager.py @@ -86,8 +86,7 @@ class GaleraCommonClusterTasks(task_models.ClusterTasks): in instance_ids] cluster_ips = [self.get_ip(instance) for instance in instances] - instance_guests = [self.get_guest(instance) - for instance in instances] + instance_guests = [] # Create replication user and password for synchronizing the # galera cluster @@ -108,13 +107,12 @@ class GaleraCommonClusterTasks(task_models.ClusterTasks): # password in the my.cnf will be wrong after the joiner # instances syncs with the donor instance. admin_password = str(utils.generate_random_password()) - for guest in instance_guests: - guest.reset_admin_password(admin_password) bootstrap = True for instance in instances: guest = self.get_guest(instance) - + instance_guests.append(guest) + guest.reset_admin_password(admin_password) # render the conf.d/cluster.cnf configuration cluster_configuration = self._render_cluster_config( context,