summaryrefslogtreecommitdiffstats
path: root/ipapython
diff options
context:
space:
mode:
authorDavid Kupka <dkupka@redhat.com>2015-12-07 13:35:49 +0100
committerJan Cholasta <jcholast@redhat.com>2015-12-08 08:12:22 +0100
commit2c5a662fd80f7152834dfebf45628d3a7b8a68bf (patch)
tree3e15bc7e3c0312f37d7ee59d50fb84a6d19f51e0 /ipapython
parentcac756b87d2eb521f038d0fb2ddb2a98569cf1af (diff)
downloadfreeipa-2c5a662fd80f7152834dfebf45628d3a7b8a68bf.tar.gz
freeipa-2c5a662fd80f7152834dfebf45628d3a7b8a68bf.tar.xz
freeipa-2c5a662fd80f7152834dfebf45628d3a7b8a68bf.zip
install: Run all validators at once.
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
Diffstat (limited to 'ipapython')
-rw-r--r--ipapython/install/core.py31
1 files changed, 19 insertions, 12 deletions
diff --git a/ipapython/install/core.py b/ipapython/install/core.py
index 8e3ba5802..2f62b8568 100644
--- a/ipapython/install/core.py
+++ b/ipapython/install/core.py
@@ -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)