diff --git a/lib/config.py b/lib/config.py index f82b5247ceb7fcf8209cf88e9364d999b3954394..9138e7901c7811a3c90e52c68877407b77371acf 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 47adc84b8a5105558c01770b28a020034f5704f5..9b1cd8c262e4a44f65aff98807e6b5b45630837f 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 5e2ec042938a62531e471e54caf90b2df370d060..15b90f8213708e2c1d3dcb96faa41df04499d2f7 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.