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.
---
lib/bootstrap.py | 8 +++++++-
lib/config.py | 7 +++++--
lib/objects.py | 8 +++++++-
test/ganeti.config_unittest.py | 19 +++++++++++++++----
4 files changed, 34 insertions(+), 8 deletions(-)
diff --git a/lib/bootstrap.py b/lib/bootstrap.py
index b0fb955..16ec8c9 100644
--- a/lib/bootstrap.py
+++ b/lib/bootstrap.py
@@ -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)
diff --git a/lib/config.py b/lib/config.py
index adf1184..41c3052 100644
--- a/lib/config.py
+++ b/lib/config.py
@@ -777,12 +777,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
@@ -793,7 +795,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={})
self._WriteConfig()
diff --git a/lib/objects.py b/lib/objects.py
index a26907d..feedec5 100644
--- a/lib/objects.py
+++ b/lib/objects.py
@@ -237,7 +237,7 @@ class TaggableObject(ConfigObject):
class ConfigData(ConfigObject):
"""Top-level config object."""
- __slots__ = ["cluster", "nodes", "instances"]
+ __slots__ = ["cluster", "nodes", "instances", "version"]
def ToDict(self):
"""Custom function for top-level config data.
@@ -692,6 +692,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):
diff --git a/test/ganeti.config_unittest.py b/test/ganeti.config_unittest.py
index fb7bd02..36188fa 100755
--- a/test/ganeti.config_unittest.py
+++ b/test/ganeti.config_unittest.py
@@ -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"""
--
1.6.0.2