Blob Blame History Raw
From 4ab54ece01d015f6b4e58542e377f60bc6726815 Mon Sep 17 00:00:00 2001
From: Jan Cholasta <jcholast@redhat.com>
Date: Mon, 2 Nov 2015 15:32:35 +0100
Subject: [PATCH] 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>
---
 ipapython/install/cli.py  | 7 +++++--
 ipapython/install/core.py | 3 ++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/ipapython/install/cli.py b/ipapython/install/cli.py
index 1ba9a815c4c499dff0e7974f399f2de31eb932cd..f6cc0fc351fd1f9fc3f51987bbb938deca377fe1 100644
--- a/ipapython/install/cli.py
+++ b/ipapython/install/cli.py
@@ -275,7 +275,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
@@ -287,8 +288,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('_', '-')
diff --git a/ipapython/install/core.py b/ipapython/install/core.py
index c313c278e09cbf68e4f5c4b4c57f00d6e2870bea..91ae854cdb2a8846e2a2673a5bfe54b4f75f3823 100644
--- a/ipapython/install/core.py
+++ b/ipapython/install/core.py
@@ -226,7 +226,8 @@ class Configurable(object):
             except KeyError:
                 pass
             else:
-                setattr(self, name, value)
+                prop = knob_cls(self)
+                prop.__set__(self, value)
 
         if kwargs:
             extra = sorted(kwargs.keys())
-- 
2.4.3