The list of master candidates IPs is needed by confd when DNS is not available.

Signed-off-by: Luca Bigliardi <[email protected]>
---
 lib/config.py    |    2 ++
 lib/constants.py |    1 +
 lib/ssconf.py    |    9 +++++++++
 3 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/lib/config.py b/lib/config.py
index 20bf691..e21a0d8 100644
--- a/lib/config.py
+++ b/lib/config.py
@@ -1155,6 +1155,7 @@ class ConfigWriter:
     off_data = fn(node.name for node in node_info if node.offline)
     on_data = fn(node.name for node in node_info if not node.offline)
     mc_data = fn(node.name for node in node_info if node.master_candidate)
+    mc_ips_data = fn(node.primary_ip for node in node_info if
node.master_candidate)
     node_data = fn(node_names)
     node_pri_ips_data = fn(node_pri_ips)
     node_snd_ips_data = fn(node_snd_ips)
@@ -1166,6 +1167,7 @@ class ConfigWriter:
       constants.SS_CLUSTER_TAGS: cluster_tags,
       constants.SS_FILE_STORAGE_DIR: cluster.file_storage_dir,
       constants.SS_MASTER_CANDIDATES: mc_data,
+      constants.SS_MASTER_CANDIDATES_IPS: mc_ips_data,
       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 95c3898..f9431bd 100644
--- a/lib/constants.py
+++ b/lib/constants.py
@@ -541,6 +541,7 @@ SS_CLUSTER_NAME = "cluster_name"
 SS_CLUSTER_TAGS = "cluster_tags"
 SS_FILE_STORAGE_DIR = "file_storage_dir"
 SS_MASTER_CANDIDATES = "master_candidates"
+SS_MASTER_CANDIDATES_IPS = "master_candidates_ips"
 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 6e69eb0..874b208 100644
--- a/lib/ssconf.py
+++ b/lib/ssconf.py
@@ -97,6 +97,7 @@ class SimpleStore(object):
     constants.SS_CLUSTER_TAGS,
     constants.SS_FILE_STORAGE_DIR,
     constants.SS_MASTER_CANDIDATES,
+    constants.SS_MASTER_CANDIDATES_IPS,
     constants.SS_MASTER_IP,
     constants.SS_MASTER_NETDEV,
     constants.SS_MASTER_NODE,
@@ -190,6 +191,14 @@ class SimpleStore(object):
     nl = data.splitlines(False)
     return nl

+  def GetMasterCandidatesIPList(self):
+    """Return the list of master candidates' primary IP.
+
+    """
+    data = self._ReadFile(constants.SS_MASTER_CANDIDATES_IPS)
+    nl = data.splitlines(False)
+    return nl
+
   def GetMasterIP(self):
     """Get the IP of the master node for this cluster.

-- 
1.5.4.3

Reply via email to