mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
install: fix command line option validation
The code which calls the validators was accidentally removed, re-add it. https://fedorahosted.org/freeipa/ticket/5386 https://fedorahosted.org/freeipa/ticket/5391 https://fedorahosted.org/freeipa/ticket/5392 Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
This commit is contained in:
parent
43654c973c
commit
6a55174bb6
@ -282,7 +282,8 @@ class ConfigureTool(admintool.AdminTool):
|
||||
kwargs = {}
|
||||
|
||||
transformed_cls = self._transform(self.configurable_class)
|
||||
for owner_cls, name in transformed_cls.knobs():
|
||||
knob_classes = {n: getattr(c, n) for c, n in transformed_cls.knobs()}
|
||||
for name in knob_classes:
|
||||
value = getattr(self.options, name, None)
|
||||
if value is not None:
|
||||
kwargs[name] = value
|
||||
@ -294,8 +295,10 @@ class ConfigureTool(admintool.AdminTool):
|
||||
try:
|
||||
cfgr = transformed_cls(**kwargs)
|
||||
except core.KnobValueError as e:
|
||||
knob_cls = getattr(transformed_cls, e.name)
|
||||
knob_cls = knob_classes[e.name]
|
||||
try:
|
||||
if self.positional_arguments is None:
|
||||
raise IndexError
|
||||
index = self.positional_arguments.index(e.name)
|
||||
except IndexError:
|
||||
cli_name = knob_cls.cli_name or e.name.replace('_', '-')
|
||||
|
@ -118,6 +118,16 @@ 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
|
||||
|
||||
@ -243,7 +253,8 @@ class Configurable(six.with_metaclass(abc.ABCMeta, object)):
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
setattr(self, name, value)
|
||||
prop = prop_cls(self)
|
||||
prop.__set__(self, value)
|
||||
|
||||
if kwargs:
|
||||
extra = sorted(kwargs)
|
||||
|
Loading…
Reference in New Issue
Block a user