Commit f56618e0 authored by Iustin Pop's avatar Iustin Pop
Browse files

Add the list of master candidates to ssconf

Reviewed-by: imsnah
parent 59303563
...@@ -859,7 +859,7 @@ class ConfigWriter: ...@@ -859,7 +859,7 @@ class ConfigWriter:
os.rename(name, destination) os.rename(name, destination)
self.write_count += 1 self.write_count += 1
# and redistribute the config file # and redistribute the config file to master candidates
self._DistributeConfig() self._DistributeConfig()
# Write ssconf files on all nodes (including locally) # Write ssconf files on all nodes (including locally)
...@@ -877,11 +877,17 @@ class ConfigWriter: ...@@ -877,11 +877,17 @@ class ConfigWriter:
associated value 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 cluster = self._config_data.cluster
return { return {
constants.SS_CLUSTER_NAME: cluster.cluster_name, constants.SS_CLUSTER_NAME: cluster.cluster_name,
constants.SS_FILE_STORAGE_DIR: cluster.file_storage_dir, 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_IP: cluster.master_ip,
constants.SS_MASTER_NETDEV: cluster.master_netdev, constants.SS_MASTER_NETDEV: cluster.master_netdev,
constants.SS_MASTER_NODE: cluster.master_node, constants.SS_MASTER_NODE: cluster.master_node,
......
...@@ -382,6 +382,7 @@ MAX_DISKS = 16 ...@@ -382,6 +382,7 @@ MAX_DISKS = 16
# SSCONF keys # SSCONF keys
SS_CLUSTER_NAME = "cluster_name" SS_CLUSTER_NAME = "cluster_name"
SS_FILE_STORAGE_DIR = "file_storage_dir" SS_FILE_STORAGE_DIR = "file_storage_dir"
SS_MASTER_CANDIDATES = "master_candidates"
SS_MASTER_IP = "master_ip" SS_MASTER_IP = "master_ip"
SS_MASTER_NETDEV = "master_netdev" SS_MASTER_NETDEV = "master_netdev"
SS_MASTER_NODE = "master_node" SS_MASTER_NODE = "master_node"
......
...@@ -127,6 +127,7 @@ class SimpleStore(object): ...@@ -127,6 +127,7 @@ class SimpleStore(object):
_VALID_KEYS = ( _VALID_KEYS = (
constants.SS_CLUSTER_NAME, constants.SS_CLUSTER_NAME,
constants.SS_FILE_STORAGE_DIR, constants.SS_FILE_STORAGE_DIR,
constants.SS_MASTER_CANDIDATES,
constants.SS_MASTER_IP, constants.SS_MASTER_IP,
constants.SS_MASTER_NETDEV, constants.SS_MASTER_NETDEV,
constants.SS_MASTER_NODE, constants.SS_MASTER_NODE,
...@@ -210,6 +211,14 @@ class SimpleStore(object): ...@@ -210,6 +211,14 @@ class SimpleStore(object):
""" """
return self._ReadFile(constants.SS_FILE_STORAGE_DIR) 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): def GetMasterIP(self):
"""Get the IP of the master node for this cluster. """Get the IP of the master node for this cluster.
......
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