Commit f9780ccd authored by Luca Bigliardi's avatar Luca Bigliardi Committed by Guido Trotter
Browse files

Add nodes IPs informations to ssconf

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.
Signed-off-by: default avatarLuca Bigliardi <>
Signed-off-by: default avatarGuido Trotter <>
Reviewed-by: default avatarGuido Trotter <>
parent 59672ca3
......@@ -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( for node in node_info if node.offline)
on_data = fn( for node in node_info if not node.offline)
mc_data = fn( 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,
......@@ -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"
......@@ -101,6 +101,8 @@ class SimpleStore(object):
......@@ -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.
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