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
This commit is contained in:
chengyang 2017-11-20 17:10:49 +08:00
parent 5f458ffc38
commit 022aa317b5
1 changed files with 3 additions and 5 deletions

View File

@ -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,