install: Run all validators at once.

Reviewed-By: Jan Cholasta <jcholast@redhat.com>
This commit is contained in:
David Kupka 2015-12-07 13:35:49 +01:00 committed by Jan Cholasta
parent cac756b87d
commit 2c5a662fd8

View File

@ -118,16 +118,6 @@ class KnobBase(PropertyBase):
def __init__(self, outer):
self.outer = outer
def __set__(self, obj, value):
try:
self.validate(value)
except KnobValueError:
raise
except ValueError as e:
raise KnobValueError(self.__outer_name__, str(e))
super(KnobBase, self).__set__(obj, value)
def validate(self, value):
pass
@ -253,8 +243,25 @@ class Configurable(six.with_metaclass(abc.ABCMeta, object)):
except KeyError:
pass
else:
prop = prop_cls(self)
prop.__set__(self, value)
setattr(self, name, value)
for owner_cls, name in cls.knobs():
if name.startswith('_'):
continue
if not isinstance(self, owner_cls):
continue
value = getattr(self, name, None)
if value is None:
continue
prop_cls = getattr(owner_cls, name)
prop = prop_cls(self)
try:
prop.validate(value)
except KnobValueError:
raise
except ValueError as e:
raise KnobValueError(name, str(e))
if kwargs:
extra = sorted(kwargs)