Commit 243cdbcc authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Use new ssconf function to check configuration version

Upgrades will be handled in future patches.

Reviewed-by: iustinp
parent a9369c6e
......@@ -541,6 +541,7 @@ class LUInitCluster(LogicalUnit):
ss.SetKey(ss.SS_MASTER_NETDEV, self.op.master_netdev)
ss.SetKey(ss.SS_CLUSTER_NAME, clustername.name)
ss.SetKey(ss.SS_FILE_STORAGE_DIR, self.op.file_storage_dir)
ss.SetKey(ss.SS_CONFIG_VERSION, constants.CONFIG_VERSION)
# set up the inter-node password and certificate
_InitGanetiServerSetup(ss)
......
......@@ -43,6 +43,17 @@ from ganeti import constants
from ganeti import rpc
from ganeti import objects
from ganeti import serializer
from ganeti import ssconf
def ValidateConfig():
sstore = ssconf.SimpleStore()
if sstore.GetConfigVersion() != constants.CONFIG_VERSION:
raise errors.ConfigurationError("Cluster configuration version"
" mismatch, got %s instead of %s" %
(sstore.GetConfigVersion(),
constants.CONFIG_VERSION))
class ConfigWriter:
......@@ -505,6 +516,10 @@ class ConfigWriter:
self._config_inode == st.st_ino):
# data is current, so skip loading of config file
return
# Make sure the configuration has the right version
ValidateConfig()
f = open(self._cfg_file, 'r')
try:
try:
......@@ -514,14 +529,9 @@ class ConfigWriter:
finally:
f.close()
if (not hasattr(data, 'cluster') or
not hasattr(data.cluster, 'config_version')):
not hasattr(data.cluster, 'rsahostkeypub')):
raise errors.ConfigurationError("Incomplete configuration"
" (missing cluster.config_version)")
if data.cluster.config_version != constants.CONFIG_VERSION:
raise errors.ConfigurationError("Cluster configuration version"
" mismatch, got %s instead of %s" %
(data.cluster.config_version,
constants.CONFIG_VERSION))
" (missing cluster.rsahostkeypub)")
self._config_data = data
self._config_time = st.st_mtime
self._config_size = st.st_size
......@@ -602,8 +612,7 @@ class ConfigWriter:
"""
hu_port = constants.FIRST_DRBD_PORT - 1
globalconfig = objects.Cluster(config_version=constants.CONFIG_VERSION,
serial_no=1,
globalconfig = objects.Cluster(serial_no=1,
rsahostkeypub=hostkeypub,
highest_used_port=hu_port,
mac_prefix=mac_prefix,
......
......@@ -24,12 +24,27 @@
from ganeti import _autoconf
# various versions
CONFIG_VERSION = 3
PROTOCOL_VERSION = 12
RELEASE_VERSION = _autoconf.PACKAGE_VERSION
OS_API_VERSION = 5
EXPORT_VERSION = 0
# Format for CONFIG_VERSION:
# 01 03 0123 = 01030123
# ^^ ^^ ^^^^
# | | + Configuration version/revision
# | + Minor version
# + Major version
#
# It stored as an integer. Make sure not to write an octal number.
#
CONFIG_MAJOR = int(_autoconf.VERSION_MAJOR)
CONFIG_MINOR = int(_autoconf.VERSION_MINOR)
CONFIG_REVISION = 0
CONFIG_VERSION = (
1000000 * CONFIG_MAJOR +
10000 * CONFIG_MINOR +
1 * CONFIG_REVISION)
# file paths
DATA_DIR = _autoconf.LOCALSTATEDIR + "/lib/ganeti"
......
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