Revision 243cdbcc

b/lib/cmdlib.py
541 541
    ss.SetKey(ss.SS_MASTER_NETDEV, self.op.master_netdev)
542 542
    ss.SetKey(ss.SS_CLUSTER_NAME, clustername.name)
543 543
    ss.SetKey(ss.SS_FILE_STORAGE_DIR, self.op.file_storage_dir)
544
    ss.SetKey(ss.SS_CONFIG_VERSION, constants.CONFIG_VERSION)
544 545

  
545 546
    # set up the inter-node password and certificate
546 547
    _InitGanetiServerSetup(ss)
b/lib/config.py
43 43
from ganeti import rpc
44 44
from ganeti import objects
45 45
from ganeti import serializer
46
from ganeti import ssconf
47

  
48

  
49
def ValidateConfig():
50
  sstore = ssconf.SimpleStore()
51

  
52
  if sstore.GetConfigVersion() != constants.CONFIG_VERSION:
53
    raise errors.ConfigurationError("Cluster configuration version"
54
                                    " mismatch, got %s instead of %s" %
55
                                    (sstore.GetConfigVersion(),
56
                                     constants.CONFIG_VERSION))
46 57

  
47 58

  
48 59
class ConfigWriter:
......
505 516
        self._config_inode == st.st_ino):
506 517
      # data is current, so skip loading of config file
507 518
      return
519

  
520
    # Make sure the configuration has the right version
521
    ValidateConfig()
522

  
508 523
    f = open(self._cfg_file, 'r')
509 524
    try:
510 525
      try:
......
514 529
    finally:
515 530
      f.close()
516 531
    if (not hasattr(data, 'cluster') or
517
        not hasattr(data.cluster, 'config_version')):
532
        not hasattr(data.cluster, 'rsahostkeypub')):
518 533
      raise errors.ConfigurationError("Incomplete configuration"
519
                                      " (missing cluster.config_version)")
520
    if data.cluster.config_version != constants.CONFIG_VERSION:
521
      raise errors.ConfigurationError("Cluster configuration version"
522
                                      " mismatch, got %s instead of %s" %
523
                                      (data.cluster.config_version,
524
                                       constants.CONFIG_VERSION))
534
                                      " (missing cluster.rsahostkeypub)")
525 535
    self._config_data = data
526 536
    self._config_time = st.st_mtime
527 537
    self._config_size = st.st_size
......
602 612

  
603 613
    """
604 614
    hu_port = constants.FIRST_DRBD_PORT - 1
605
    globalconfig = objects.Cluster(config_version=constants.CONFIG_VERSION,
606
                                   serial_no=1,
615
    globalconfig = objects.Cluster(serial_no=1,
607 616
                                   rsahostkeypub=hostkeypub,
608 617
                                   highest_used_port=hu_port,
609 618
                                   mac_prefix=mac_prefix,
b/lib/constants.py
24 24
from ganeti import _autoconf
25 25

  
26 26
# various versions
27
CONFIG_VERSION = 3
28 27
PROTOCOL_VERSION = 12
29 28
RELEASE_VERSION = _autoconf.PACKAGE_VERSION
30 29
OS_API_VERSION = 5
31 30
EXPORT_VERSION = 0
32 31

  
32
# Format for CONFIG_VERSION:
33
#   01 03 0123 = 01030123
34
#   ^^ ^^ ^^^^
35
#   |  |  + Configuration version/revision
36
#   |  + Minor version
37
#   + Major version
38
#
39
# It stored as an integer. Make sure not to write an octal number.
40
#
41
CONFIG_MAJOR = int(_autoconf.VERSION_MAJOR)
42
CONFIG_MINOR = int(_autoconf.VERSION_MINOR)
43
CONFIG_REVISION = 0
44
CONFIG_VERSION = (
45
  1000000 * CONFIG_MAJOR +
46
    10000 * CONFIG_MINOR +
47
        1 * CONFIG_REVISION)
33 48

  
34 49
# file paths
35 50
DATA_DIR = _autoconf.LOCALSTATEDIR + "/lib/ganeti"

Also available in: Unified diff