Commit 868a98ca authored by Manuel Franceschini's avatar Manuel Franceschini

Add primary_ip_family to ssconf

Since this parameter will be used on all daemon startups, it needs to be
available on all nodes. This is achieved by querying it via ssconf. This
patch additionally adds a getter method to readily retrieve the primary
ip family from a ConfigWriter object.

This patch also disables the 'R0904: Too many public methods' pylint
warning, as it crosses the 50 methods limit.
Signed-off-by: default avatarManuel Franceschini <livewire@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 2f20d07b
......@@ -827,6 +827,15 @@ class ConfigWriter:
"""
return self._config_data.cluster.default_iallocator
@locking.ssynchronized(_config_lock, shared=1)
def GetPrimaryIPFamily(self):
"""Get cluster primary ip family.
@return: primary ip family
"""
return self._config_data.cluster.primary_ip_family
@locking.ssynchronized(_config_lock)
def AddInstance(self, instance, ec_id):
"""Add an instance to the config.
......@@ -1407,6 +1416,7 @@ class ConfigWriter:
constants.SS_NODE_SECONDARY_IPS: node_snd_ips_data,
constants.SS_OFFLINE_NODES: off_data,
constants.SS_ONLINE_NODES: on_data,
constants.SS_PRIMARY_IP_FAMILY: str(cluster.primary_ip_family),
constants.SS_INSTANCE_LIST: instance_data,
constants.SS_RELEASE_VERSION: constants.RELEASE_VERSION,
constants.SS_HYPERVISOR_LIST: hypervisor_list,
......
......@@ -871,6 +871,7 @@ 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_PRIMARY_IP_FAMILY = "primary_ip_family"
SS_INSTANCE_LIST = "instance_list"
SS_RELEASE_VERSION = "release_version"
SS_HYPERVISOR_LIST = "hypervisor_list"
......
......@@ -281,6 +281,7 @@ class SimpleStore(object):
constants.SS_NODE_SECONDARY_IPS,
constants.SS_OFFLINE_NODES,
constants.SS_ONLINE_NODES,
constants.SS_PRIMARY_IP_FAMILY,
constants.SS_INSTANCE_LIST,
constants.SS_RELEASE_VERSION,
constants.SS_HYPERVISOR_LIST,
......@@ -460,6 +461,16 @@ class SimpleStore(object):
data = self._ReadFile(constants.SS_UID_POOL)
return data
def GetPrimaryIPFamily(self):
"""Return the cluster-wide primary address family.
"""
try:
return int(self._ReadFile(constants.SS_PRIMARY_IP_FAMILY))
except (ValueError, TypeError), err:
raise errors.ConfigurationError("Error while trying to parse primary ip"
" family: %s" % err)
def GetMasterAndMyself(ss=None):
"""Get the master node and my own hostname.
......
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