From 81a49123c7c29581eae76fb458c5f3eff43a252d Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Wed, 4 Feb 2009 10:31:00 +0000 Subject: [PATCH] ssconf: add some more keys and some fixes This patch adds the online node list and instance list to the ssconf keys. In order to do distribute correctly the instance list, we need to update the cluster serial number on instance additions and removals. The patch also changes the permissions on the ssconf files to be 0444: - no write for root, in order to signal that these file should not be modified - read for everyone since the files don't contain sensitive data anymore (and permissions can be controlled via the parent directory if needed) The patch also fixes a small typo on gnt-cluster. Reviewed-by: ultrotter --- lib/config.py | 7 +++++++ lib/constants.py | 2 ++ lib/ssconf.py | 4 +++- scripts/gnt-cluster | 2 +- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/config.py b/lib/config.py index 9256bb958..d7a1e9f77 100644 --- a/lib/config.py +++ b/lib/config.py @@ -646,6 +646,7 @@ class ConfigWriter: instance.serial_no = 1 self._config_data.instances[instance.name] = instance + self._config_data.cluster.serial_no += 1 self._UnlockedReleaseDRBDMinors(instance.name) self._WriteConfig() @@ -680,6 +681,7 @@ class ConfigWriter: if instance_name not in self._config_data.instances: raise errors.ConfigurationError("Unknown instance '%s'" % instance_name) del self._config_data.instances[instance_name] + self._config_data.cluster.serial_no += 1 self._WriteConfig() @locking.ssynchronized(_config_lock) @@ -1064,10 +1066,13 @@ class ConfigWriter: """ fn = "\n".join + instance_names = utils.NiceSort(self._UnlockedGetInstanceList()) node_names = utils.NiceSort(self._UnlockedGetNodeList()) node_info = [self._UnlockedGetNodeInfo(name) for name in node_names] + 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) @@ -1081,6 +1086,8 @@ class ConfigWriter: constants.SS_MASTER_NODE: cluster.master_node, constants.SS_NODE_LIST: node_data, constants.SS_OFFLINE_NODES: off_data, + constants.SS_ONLINE_NODES: on_data, + constants.SS_INSTANCE_LIST: instance_data, constants.SS_RELEASE_VERSION: constants.RELEASE_VERSION, } diff --git a/lib/constants.py b/lib/constants.py index 1711728fc..367b31c96 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -422,6 +422,8 @@ SS_MASTER_NETDEV = "master_netdev" SS_MASTER_NODE = "master_node" SS_NODE_LIST = "node_list" SS_OFFLINE_NODES = "offline_nodes" +SS_ONLINE_NODES = "online_nodes" +SS_INSTANCE_LIST = "instance_list" SS_RELEASE_VERSION = "release_version" # cluster wide default parameters diff --git a/lib/ssconf.py b/lib/ssconf.py index f575d129f..a8a8968ff 100644 --- a/lib/ssconf.py +++ b/lib/ssconf.py @@ -133,6 +133,8 @@ class SimpleStore(object): constants.SS_MASTER_NODE, constants.SS_NODE_LIST, constants.SS_OFFLINE_NODES, + constants.SS_ONLINE_NODES, + constants.SS_INSTANCE_LIST, constants.SS_RELEASE_VERSION, ) _MAX_SIZE = 131072 @@ -189,7 +191,7 @@ class SimpleStore(object): for name, value in values.iteritems(): if value and not value.endswith("\n"): value += "\n" - utils.WriteFile(self.KeyToFilename(name), data=value) + utils.WriteFile(self.KeyToFilename(name), data=value, mode=0444) finally: ssconf_lock.Unlock() diff --git a/scripts/gnt-cluster b/scripts/gnt-cluster index 9cd1f52f1..5c9f2c2cd 100755 --- a/scripts/gnt-cluster +++ b/scripts/gnt-cluster @@ -187,7 +187,7 @@ def RedistributeConfig(opts, args): @return: the desired exit code """ - op = opcodes.OpRedistributeConf() + op = opcodes.OpRedistributeConfig() SubmitOrSend(op, opts) return 0 -- GitLab