Revision 243cdbcc lib/config.py
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, |
Also available in: Unified diff