Commit 81a49123 authored by Iustin Pop's avatar Iustin Pop
Browse files

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
parent ec79568d
......@@ -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,
}
......
......@@ -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
......
......@@ -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()
......
......@@ -187,7 +187,7 @@ def RedistributeConfig(opts, args):
@return: the desired exit code
"""
op = opcodes.OpRedistributeConf()
op = opcodes.OpRedistributeConfig()
SubmitOrSend(op, opts)
return 0
......
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