From f56618e0b11301e9a314b7285bc462ee2f7f0bd0 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Tue, 2 Dec 2008 05:05:40 +0000 Subject: [PATCH] Add the list of master candidates to ssconf Reviewed-by: imsnah --- lib/config.py | 10 ++++++++-- lib/constants.py | 1 + lib/ssconf.py | 9 +++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/config.py b/lib/config.py index f82b5247c..9138e7901 100644 --- a/lib/config.py +++ b/lib/config.py @@ -859,7 +859,7 @@ class ConfigWriter: os.rename(name, destination) self.write_count += 1 - # and redistribute the config file + # and redistribute the config file to master candidates self._DistributeConfig() # Write ssconf files on all nodes (including locally) @@ -877,11 +877,17 @@ class ConfigWriter: associated value """ - node_list = "\n".join(utils.NiceSort(self._UnlockedGetNodeList())) + node_list = utils.NiceSort(self._UnlockedGetNodeList()) + mc_list = [self._UnlockedGetNodeInfo(name) for name in node_list] + mc_list = [node.name for node in mc_list if node.master_candidate] + node_list = "\n".join(node_list) + mc_list = "\n".join(mc_list) + cluster = self._config_data.cluster return { constants.SS_CLUSTER_NAME: cluster.cluster_name, constants.SS_FILE_STORAGE_DIR: cluster.file_storage_dir, + constants.SS_MASTER_CANDIDATES: mc_list, constants.SS_MASTER_IP: cluster.master_ip, constants.SS_MASTER_NETDEV: cluster.master_netdev, constants.SS_MASTER_NODE: cluster.master_node, diff --git a/lib/constants.py b/lib/constants.py index 47adc84b8..9b1cd8c26 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -382,6 +382,7 @@ MAX_DISKS = 16 # SSCONF keys SS_CLUSTER_NAME = "cluster_name" SS_FILE_STORAGE_DIR = "file_storage_dir" +SS_MASTER_CANDIDATES = "master_candidates" SS_MASTER_IP = "master_ip" SS_MASTER_NETDEV = "master_netdev" SS_MASTER_NODE = "master_node" diff --git a/lib/ssconf.py b/lib/ssconf.py index 5e2ec0429..15b90f821 100644 --- a/lib/ssconf.py +++ b/lib/ssconf.py @@ -127,6 +127,7 @@ class SimpleStore(object): _VALID_KEYS = ( constants.SS_CLUSTER_NAME, constants.SS_FILE_STORAGE_DIR, + constants.SS_MASTER_CANDIDATES, constants.SS_MASTER_IP, constants.SS_MASTER_NETDEV, constants.SS_MASTER_NODE, @@ -210,6 +211,14 @@ class SimpleStore(object): """ return self._ReadFile(constants.SS_FILE_STORAGE_DIR) + def GetMasterCandidates(self): + """Return the list of master candidates. + + """ + data = self._ReadFile(constants.SS_MASTER_CANDIDATES) + nl = data.splitlines(False) + return nl + def GetMasterIP(self): """Get the IP of the master node for this cluster. -- GitLab