Having a list of primary/secondary IPs of all the nodes in ssconf can be useful
for scripts/hooks which need to automatically configure network properties for
the whole cluster (e.g.: ipsec/netfilter rules) without relying on a
working DNS.
---
lib/config.py | 6 ++++++
lib/constants.py | 2 ++
lib/ssconf.py | 18 ++++++++++++++++++
3 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/lib/config.py b/lib/config.py
index ba4bbdf..20bf691 100644
--- a/lib/config.py
+++ b/lib/config.py
@@ -1148,12 +1148,16 @@ class ConfigWriter:
instance_names = utils.NiceSort(self._UnlockedGetInstanceList())
node_names = utils.NiceSort(self._UnlockedGetNodeList())
node_info = [self._UnlockedGetNodeInfo(name) for name in node_names]
+ node_pri_ips = [ninfo.primary_ip for ninfo in node_info]
+ node_snd_ips = [ninfo.secondary_ip for ninfo in node_info]
instance_data = fn(instance_names)
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)
node_data = fn(node_names)
+ node_pri_ips_data = fn(node_pri_ips)
+ node_snd_ips_data = fn(node_snd_ips)
cluster = self._config_data.cluster
cluster_tags = fn(cluster.GetTags())
@@ -1166,6 +1170,8 @@ class ConfigWriter:
constants.SS_MASTER_NETDEV: cluster.master_netdev,
constants.SS_MASTER_NODE: cluster.master_node,
constants.SS_NODE_LIST: node_data,
+ constants.SS_NODE_PRIMARY_IPS: node_pri_ips_data,
+ constants.SS_NODE_SECONDARY_IPS: node_snd_ips_data,
constants.SS_OFFLINE_NODES: off_data,
constants.SS_ONLINE_NODES: on_data,
constants.SS_INSTANCE_LIST: instance_data,
diff --git a/lib/constants.py b/lib/constants.py
index 09f7917..95c3898 100644
--- a/lib/constants.py
+++ b/lib/constants.py
@@ -545,6 +545,8 @@ SS_MASTER_IP = "master_ip"
SS_MASTER_NETDEV = "master_netdev"
SS_MASTER_NODE = "master_node"
SS_NODE_LIST = "node_list"
+SS_NODE_PRIMARY_IPS = "node_primary_ips"
+SS_NODE_SECONDARY_IPS = "node_secondary_ips"
SS_OFFLINE_NODES = "offline_nodes"
SS_ONLINE_NODES = "online_nodes"
SS_INSTANCE_LIST = "instance_list"
diff --git a/lib/ssconf.py b/lib/ssconf.py
index 93c057d..6e69eb0 100644
--- a/lib/ssconf.py
+++ b/lib/ssconf.py
@@ -101,6 +101,8 @@ class SimpleStore(object):
constants.SS_MASTER_NETDEV,
constants.SS_MASTER_NODE,
constants.SS_NODE_LIST,
+ constants.SS_NODE_PRIMARY_IPS,
+ constants.SS_NODE_SECONDARY_IPS,
constants.SS_OFFLINE_NODES,
constants.SS_ONLINE_NODES,
constants.SS_INSTANCE_LIST,
@@ -214,6 +216,22 @@ class SimpleStore(object):
nl = data.splitlines(False)
return nl
+ def GetNodePrimaryIPList(self):
+ """Return the list of cluster nodes' primary IP.
+
+ """
+ data = self._ReadFile(constants.SS_NODE_PRIMARY_IPS)
+ nl = data.splitlines(False)
+ return nl
+
+ def GetNodeSecondaryIPList(self):
+ """Return the list of cluster nodes' secondary IP.
+
+ """
+ data = self._ReadFile(constants.SS_NODE_SECONDARY_IPS)
+ nl = data.splitlines(False)
+ return nl
+
def GetClusterTags(self):
"""Return the cluster tags.
--
1.5.4.3