Commit f6bd6e98 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Add cluster options from ssconf to configuration

ssconf will become write-only from ganeti-masterd's point of view,
therefore all settings in there need to go into the main configuration
file.

Reviewed-by: iustinp
parent b9eeeb02
......@@ -230,12 +230,18 @@ def InitCluster(cluster_name, hypervisor_type, mac_prefix, def_bridge,
volume_group_name=vg_name,
default_bridge=def_bridge,
tcpudp_port_pool=set(),
hypervisor=hypervisor_type,
master_node=hostname.name,
master_ip=clustername.ip,
master_netdev=master_netdev,
cluster_name=clustername.name,
file_storage_dir=file_storage_dir,
)
master_node_config = objects.Node(name=hostname.name,
primary_ip=hostname.ip,
secondary_ip=secondary_ip)
cfg = config.ConfigWriter()
cfg.InitConfig(cluster_config, master_node_config)
cfg.InitConfig(constants.CONFIG_VERSION, cluster_config, master_node_config)
ssh.WriteKnownHostsFile(cfg, ss, constants.SSH_KNOWN_HOSTS_FILE)
......
......@@ -861,12 +861,14 @@ class ConfigWriter:
self._DistributeConfig()
@locking.ssynchronized(_config_lock)
def InitConfig(self, cluster_config, master_node_config):
def InitConfig(self, version, cluster_config, master_node_config):
"""Create the initial cluster configuration.
It will contain the current node, which will also be the master
node, and no instances.
@type version: int
@param version: Configuration version
@type cluster_config: objects.Cluster
@param cluster_config: Cluster configuration
@type master_node_config: objects.Node
......@@ -877,7 +879,8 @@ class ConfigWriter:
master_node_config.name: master_node_config,
}
self._config_data = objects.ConfigData(cluster=cluster_config,
self._config_data = objects.ConfigData(version=version,
cluster=cluster_config,
nodes=nodes,
instances={},
serial_no=1)
......
......@@ -237,7 +237,7 @@ class TaggableObject(ConfigObject):
class ConfigData(ConfigObject):
"""Top-level config object."""
__slots__ = ["cluster", "nodes", "instances", "serial_no"]
__slots__ = ["version", "cluster", "nodes", "instances", "serial_no"]
def ToDict(self):
"""Custom function for top-level config data.
......@@ -695,6 +695,12 @@ class Cluster(TaggableObject):
"mac_prefix",
"volume_group_name",
"default_bridge",
"hypervisor",
"master_node",
"master_ip",
"master_netdev",
"cluster_name",
"file_storage_dir",
]
def ToDict(self):
......
......@@ -55,6 +55,9 @@ class TestConfigRunner(unittest.TestCase):
def _init_cluster(self, cfg):
"""Initializes the cfg object"""
me = utils.HostInfo()
ip = constants.LOCALHOST_IP_ADDRESS
cluster_config = objects.Cluster(
serial_no=1,
rsahostkeypub="",
......@@ -63,12 +66,20 @@ class TestConfigRunner(unittest.TestCase):
volume_group_name="xenvg",
default_bridge=constants.DEFAULT_BRIDGE,
tcpudp_port_pool=set(),
hypervisor=constants.HT_FAKE,
master_node=me.name,
master_ip="127.0.0.1",
master_netdev=constants.DEFAULT_BRIDGE,
cluster_name="cluster.local",
file_storage_dir="/tmp",
)
ip = constants.LOCALHOST_IP_ADDRESS
master_node_config = objects.Node(name=utils.HostInfo().name,
primary_ip=ip,
master_node_config = objects.Node(name=me.name,
primary_ip=me.ip,
secondary_ip=ip)
cfg.InitConfig(cluster_config, master_node_config)
cfg.InitConfig(constants.CONFIG_VERSION,
cluster_config, master_node_config)
def _create_instance(self):
"""Create and return an instance object"""
......
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