From 868a98cac08ac2e3ebf74ef6866e38a103064fb5 Mon Sep 17 00:00:00 2001 From: Manuel Franceschini <livewire@google.com> Date: Mon, 2 Aug 2010 18:10:38 +0200 Subject: [PATCH] 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: Manuel Franceschini <livewire@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- lib/config.py | 10 ++++++++++ lib/constants.py | 1 + lib/ssconf.py | 11 +++++++++++ 3 files changed, 22 insertions(+) diff --git a/lib/config.py b/lib/config.py index c92dec9f8..e620c2104 100644 --- a/lib/config.py +++ b/lib/config.py @@ -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, diff --git a/lib/constants.py b/lib/constants.py index 74495a97a..ce68abdd9 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -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" diff --git a/lib/ssconf.py b/lib/ssconf.py index 6ed9d1232..0449f8081 100644 --- a/lib/ssconf.py +++ b/lib/ssconf.py @@ -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. -- GitLab