From ec85e3d5815797204e6a9a5dc0700e22ac6bda48 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Wed, 3 Dec 2008 09:55:59 +0000 Subject: [PATCH] Fix cluster rename and known_hosts This patch rewrites and distributes ganeti's known_hosts file in case of a cluster rename. We also fix a problem in the node add (from where I copied the known_hosts file distribution). Reviewed-by: ultrotter --- lib/cmdlib.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index e4353a75d..3b95fd37a 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -1186,6 +1186,20 @@ class LURenameCluster(LogicalUnit): cluster.cluster_name = clustername cluster.master_ip = ip self.cfg.Update(cluster) + + # update the known hosts file + ssh.WriteKnownHostsFile(self.cfg, constants.SSH_KNOWN_HOSTS_FILE) + node_list = self.cfg.GetNodeList() + try: + node_list.remove(master) + except ValueError: + pass + result = self.rpc.call_upload_file(node_list, + constants.SSH_KNOWN_HOSTS_FILE) + for to_node, to_result in result.iteritems(): + if to_result.failed or not to_result.data: + logging.error("Copy of file %s to node %s failed", fname, to_node) + finally: result = self.rpc.call_node_start_master(master, False) if result.failed or not result.data: @@ -2024,8 +2038,8 @@ class LUAddNode(LogicalUnit): 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 in dist_nodes: - if result[to_node].failed or not result[to_node]: + for to_node, to_result in result.iteritems(): + if to_result.failed or not to_result.data: logging.error("Copy of file %s to node %s failed", fname, to_node) to_copy = [] -- GitLab