Commit 9ac307a6 authored by Petr Pudlak's avatar Petr Pudlak

Move _ValidateConfig to the verify.py submodule

.. in order to get the size of config/__init__ under 3600 lines again.
Signed-off-by: default avatarPetr Pudlak <pudlak@google.com>
Reviewed-by: default avatarKlaus Aehlig <aehlig@google.com>
parent 6d9446fa
......@@ -40,13 +40,9 @@ much memory.
"""
# pylint: disable=R0904,C0302
# pylint: disable=R0904
# R0904: Too many public methods
# C0302: This module has become too big and should be split up
# FIXME: This has been added only temporarily as a merge introduced enough lines
# to hit the threshold. This will be fixed in a follow-up patch.
import copy
import os
import random
......@@ -57,7 +53,8 @@ import itertools
from ganeti.config.temporary_reservations import TemporaryReservationManager
from ganeti.config.utils import ConfigSync, ConfigManager
from ganeti.config.verify import VerifyType, VerifyNic, VerifyIpolicy
from ganeti.config.verify import (VerifyType, VerifyNic, VerifyIpolicy,
ValidateConfig)
from ganeti import errors
from ganeti import utils
......@@ -123,20 +120,6 @@ def GetConfig(ec_id, livelock, **kwargs):
_UPGRADE_CONFIG_JID = "jid-cfg-upgrade"
def _ValidateConfig(data):
"""Verifies that a configuration dict looks valid.
This only verifies the version of the configuration.
@raise errors.ConfigurationError: if the version differs from what
we expect
"""
if data['version'] != constants.CONFIG_VERSION:
raise errors.ConfigVersionMismatch(constants.CONFIG_VERSION,
data['version'])
def _MatchNameComponentIgnoreCase(short_name, names):
"""Wrapper around L{utils.text.MatchNameComponent}.
......@@ -2839,7 +2822,7 @@ class ConfigWriter(object):
raw_data = utils.ReadFile(self._cfg_file)
data_dict = serializer.Load(raw_data)
# Make sure the configuration has the right version
_ValidateConfig(data_dict)
ValidateConfig(data_dict)
data = objects.ConfigData.FromDict(data_dict)
except errors.ConfigVersionMismatch:
raise
......
......@@ -36,6 +36,20 @@ from ganeti import objects
from ganeti import utils
def ValidateConfig(data):
"""Verifies that a configuration dict looks valid.
This only verifies the version of the configuration.
@raise errors.ConfigurationError: if the version differs from what
we expect
"""
if data['version'] != constants.CONFIG_VERSION:
raise errors.ConfigVersionMismatch(constants.CONFIG_VERSION,
data['version'])
def VerifyType(owner, attr, value, template, callback):
"""Checks if an attribute has correct form.
......
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