Commit 28eddce5 authored by Guido Trotter's avatar Guido Trotter
Browse files

_RedistributeAncillaryFiles function

This function is shared between AddNode and RedistributeConfig, and used
to redistribute additional files which are inherently part of the
cluster configuration.
Signed-off-by: default avatarGuido Trotter <>
Reviewed-by: default avatarIustin Pop <>
parent 4d2a7c95
......@@ -1548,6 +1548,39 @@ class LUSetClusterParams(LogicalUnit):
def _RedistributeAncillaryFiles(lu, additional_nodes=None):
"""Distribute additional files which are part of the cluster configuration.
ConfigWriter takes care of distributing the config and ssconf files, but
there are more files which should be distributed to all nodes. This function
makes sure those are copied.
@param lu: calling logical unit
@param additional_nodes: list of nodes not in the config to distribute to
# 1. Gather target nodes
myself = lu.cfg.GetNodeInfo(lu.cfg.GetMasterNode())
dist_nodes = lu.cfg.GetNodeList()
if additional_nodes is not None:
if in dist_nodes:
# 2. Gather files to distribute
dist_files = set([constants.ETC_HOSTS,
# 3. Perform the files upload
for fname in dist_files:
if os.path.exists(fname):
result = lu.rpc.call_upload_file(dist_nodes, fname)
for to_node, to_result in result.items():
if to_result.failed or not
logging.error("Copy of file %s to node %s failed", fname, to_node)
class LURedistributeConfig(NoHooksLU):
"""Force the redistribution of cluster configuration.
......@@ -1573,6 +1606,7 @@ class LURedistributeConfig(NoHooksLU):
def _WaitForSync(lu, instance, oneshot=False, unlock=False):
......@@ -2248,25 +2282,11 @@ class LUAddNode(LogicalUnit):
(verifier, result[verifier].data['nodelist'][failed]))
raise errors.OpExecError("ssh/hostname verification failed.")
# Distribute updated /etc/hosts and known_hosts to all nodes,
# including the node just added
myself = self.cfg.GetNodeInfo(self.cfg.GetMasterNode())
dist_nodes = self.cfg.GetNodeList()
if not self.op.readd:
if in dist_nodes:
logging.debug("Copying hosts and known_hosts to all nodes")
for fname in (constants.ETC_HOSTS, constants.SSH_KNOWN_HOSTS_FILE):
result = self.rpc.call_upload_file(dist_nodes, fname)
for to_node, to_result in result.iteritems():
if to_result.failed or not
logging.error("Copy of file %s to node %s failed", fname, to_node)
if self.op.readd:
_RedistributeAncillaryFiles(self, additional_nodes=node)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment