On 18/12/15 13:57, David Kupka wrote:
On 17/12/15 13:44, Jan Cholasta wrote:
On 17.12.2015 13:26, David Kupka wrote:
On 17/12/15 12:14, Petr Vobornik wrote:
On 12/16/2015 02:31 PM, David Kupka wrote:
https://www.redhat.com/archives/freeipa-users/2015-December/msg00203.html





please link the patch to https://fedorahosted.org/freeipa/ticket/5556

Updated patches attached.

NACK, this is the correct procedure for the __getattr__(), sorry for
confusing you earlier:

     def __getattr__(self, name):
         for owner_cls, knob_name in self.knobs():
             if knob_name == name:
                 break
         else:
             raise AttributeError(name)

         for component in self.__components:
             if isinstance(component, owner_cls):
                 break
         else:
             raise AttributeError(name)

         return getattr(component, name)

Honza

Updated patches attached.

Completing the update.

--
David Kupka
From f0c07859e5aaf5283418122ba0d492807d8ab92a Mon Sep 17 00:00:00 2001
From: David Kupka <dku...@redhat.com>
Date: Wed, 16 Dec 2015 12:43:13 +0000
Subject: [PATCH] installer: Propagate option values from components instead of
 copying them.

https://fedorahosted.org/freeipa/ticket/5556
---
 ipapython/install/core.py          | 21 ++++++++++++++++++---
 ipaserver/install/server/common.py | 28 ----------------------------
 2 files changed, 18 insertions(+), 31 deletions(-)

diff --git a/ipapython/install/core.py b/ipapython/install/core.py
index 6b2da05d31d26bd3b7222e237c8646fa80ab5290..06acca6782f556b5880e7f6d023ab222f1025062 100644
--- a/ipapython/install/core.py
+++ b/ipapython/install/core.py
@@ -528,6 +528,21 @@ class Composite(Configurable):
             for order, owner_cls, name in result:
                 yield owner_cls, name
 
+    def __getattr__(self, name):
+        for owner_cls, knob_name in self.knobs():
+            if knob_name == name:
+                break
+        else:
+            raise AttributeError(name)
+
+        for component in self.__components:
+            if isinstance(component, owner_cls):
+                break
+        else:
+            raise AttributeError(name)
+
+        return getattr(component, name)
+
     def _reset(self):
         self.__components = list(self._get_components())
 
@@ -545,8 +560,7 @@ class Composite(Configurable):
                 try:
                     validator.next()
                 except StopIteration:
-                    if child.done():
-                        self.__components.remove(child)
+                    pass
                 else:
                     new_validate.append((child, validator))
             if not new_validate:
@@ -560,7 +574,8 @@ class Composite(Configurable):
 
         yield from_(super(Composite, self)._configure())
 
-        execute = [(c, c._executor()) for c in self.__components]
+        execute = [(c, c._executor()) for c in self.__components
+            if not c.done()]
         while True:
             new_execute = []
             for child, executor in execute:
diff --git a/ipaserver/install/server/common.py b/ipaserver/install/server/common.py
index 3eb7279d200ffd6ab33d8d914c8d4f13e567a171..948aac842951dc3cef9dace87b28a92d3f98dea3 100644
--- a/ipaserver/install/server/common.py
+++ b/ipaserver/install/server/common.py
@@ -409,34 +409,6 @@ class BaseServer(common.Installable, common.Interactive, core.Composite):
         # Automatically disable pkinit w/ dogtag until that is supported
         self.no_pkinit = True
 
-        self.external_ca = self.ca.external_ca
-        self.external_ca_type = self.ca.external_ca_type
-        self.external_cert_files = self.ca.external_cert_files
-        self.dirsrv_cert_files = self.ca.dirsrv_cert_files
-        self.http_cert_files = self.ca.http_cert_files
-        self.pkinit_cert_files = self.ca.pkinit_cert_files
-        self.dirsrv_pin = self.ca.dirsrv_pin
-        self.http_pin = self.ca.http_pin
-        self.pkinit_pin = self.ca.pkinit_pin
-        self.dirsrv_cert_name = self.ca.dirsrv_cert_name
-        self.http_cert_name = self.ca.http_cert_name
-        self.pkinit_cert_name = self.ca.pkinit_cert_name
-        self.ca_cert_files = self.ca.ca_cert_files
-        self.subject = self.ca.subject
-        self.ca_signing_algorithm = self.ca.ca_signing_algorithm
-        self.skip_schema_check = self.ca.skip_schema_check
-
-        self.forwarders = self.dns.forwarders
-        self.no_forwarders = self.dns.no_forwarders
-        self.reverse_zones = self.dns.reverse_zones
-        self.no_reverse = self.dns.no_reverse
-        self.no_dnssec_validation = self.dns.no_dnssec_validation
-        self.dnssec_master = self.dns.dnssec_master
-        self.disable_dnssec_master = self.dns.disable_dnssec_master
-        self.kasp_db_file = self.dns.kasp_db_file
-        self.force = self.dns.force
-        self.zonemgr = self.dns.zonemgr
-
         self.unattended = not self.interactive
 
     ca = core.Component(BaseServerCA)
-- 
2.5.0

From ed4724ed80201afb54cb4d881f88fbb2adc756c4 Mon Sep 17 00:00:00 2001
From: David Kupka <dku...@redhat.com>
Date: Wed, 16 Dec 2015 12:43:13 +0000
Subject: [PATCH] installer: Propagate option values from components instead of
 copying them.

https://fedorahosted.org/freeipa/ticket/5556
---
 ipapython/install/core.py          | 21 ++++++++++++++++++---
 ipaserver/install/server/common.py | 31 -------------------------------
 2 files changed, 18 insertions(+), 34 deletions(-)

diff --git a/ipapython/install/core.py b/ipapython/install/core.py
index 2f62b8568fea129255e42b404789fd29b70dca7c..f8cf07dc1cd463f5c98c6cda8edc9d087bd72af0 100644
--- a/ipapython/install/core.py
+++ b/ipapython/install/core.py
@@ -531,6 +531,21 @@ class Composite(Configurable):
             for order, owner_cls, name in result:
                 yield owner_cls, name
 
+    def __getattr__(self, name):
+        for owner_cls, knob_name in self.knobs():
+            if knob_name == name:
+                break
+        else:
+            raise AttributeError(name)
+
+        for component in self.__components:
+            if isinstance(component, owner_cls):
+                break
+        else:
+            raise AttributeError(name)
+
+        return getattr(component, name)
+
     def _reset(self):
         self.__components = list(self._get_components())
 
@@ -548,8 +563,7 @@ class Composite(Configurable):
                 try:
                     next(validator)
                 except StopIteration:
-                    if child.done():
-                        self.__components.remove(child)
+                    pass
                 else:
                     new_validate.append((child, validator))
             if not new_validate:
@@ -563,7 +577,8 @@ class Composite(Configurable):
 
         yield from_(super(Composite, self)._configure())
 
-        execute = [(c, c._executor()) for c in self.__components]
+        execute = [(c, c._executor()) for c in self.__components
+            if not c.done()]
         while True:
             new_execute = []
             for child, executor in execute:
diff --git a/ipaserver/install/server/common.py b/ipaserver/install/server/common.py
index 19a1cc8210cb652b6e00ef6eb8f0d66b214ca398..00b05c9b34abac159d6fcf9277dfe29197025334 100644
--- a/ipaserver/install/server/common.py
+++ b/ipaserver/install/server/common.py
@@ -461,37 +461,6 @@ class BaseServer(common.Installable, common.Interactive, core.Composite):
         # Automatically disable pkinit w/ dogtag until that is supported
         self.no_pkinit = True
 
-        self.external_ca = self.ca.external_ca
-        self.external_ca_type = self.ca.external_ca_type
-        self.external_cert_files = self.ca.external_cert_files
-        self.dirsrv_cert_files = self.ca.dirsrv_cert_files
-        self.http_cert_files = self.ca.http_cert_files
-        self.pkinit_cert_files = self.ca.pkinit_cert_files
-        self.dirsrv_pin = self.ca.dirsrv_pin
-        self.http_pin = self.ca.http_pin
-        self.pkinit_pin = self.ca.pkinit_pin
-        self.dirsrv_cert_name = self.ca.dirsrv_cert_name
-        self.http_cert_name = self.ca.http_cert_name
-        self.pkinit_cert_name = self.ca.pkinit_cert_name
-        self.ca_cert_files = self.ca.ca_cert_files
-        self.subject = self.ca.subject
-        self.ca_signing_algorithm = self.ca.ca_signing_algorithm
-        self.skip_schema_check = self.ca.skip_schema_check
-
-        self.forwarders = self.dns.forwarders
-        self.auto_forwarders = self.dns.auto_forwarders
-        self.no_forwarders = self.dns.no_forwarders
-        self.reverse_zones = self.dns.reverse_zones
-        self.no_reverse = self.dns.no_reverse
-        self.auto_reverse = self.dns.auto_reverse
-        self.allow_zone_overlap = self.dns.allow_zone_overlap
-        self.no_dnssec_validation = self.dns.no_dnssec_validation
-        self.dnssec_master = self.dns.dnssec_master
-        self.disable_dnssec_master = self.dns.disable_dnssec_master
-        self.kasp_db_file = self.dns.kasp_db_file
-        self.force = self.dns.force
-        self.zonemgr = self.dns.zonemgr
-
         self.unattended = not self.interactive
 
     ca = core.Component(BaseServerCA)
-- 
2.5.0

From 4a550e0c574a0d415f10b2aca449ed5acc4a3065 Mon Sep 17 00:00:00 2001
From: David Kupka <dku...@redhat.com>
Date: Wed, 16 Dec 2015 12:45:24 +0000
Subject: [PATCH 2/2] installer: Fix logic of reading option values from cache.

Only options explicitly set must be stored before installer exits first step
of external CA setup. When installer continues all stored option values must
be restored.

https://fedorahosted.org/freeipa/ticket/5556
---
 ipaserver/install/server/install.py | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/ipaserver/install/server/install.py b/ipaserver/install/server/install.py
index 7bd8994f9074d6f3de16c1cb7e7fc46da0f8e086..5c64fab14c56f73e5dc603b1e0053119b9ba20db 100644
--- a/ipaserver/install/server/install.py
+++ b/ipaserver/install/server/install.py
@@ -337,9 +337,7 @@ def install_check(installer):
             sys.exit("Directory Manager password required")
         try:
             cache_vars = read_cache(dm_password)
-            for name, value in cache_vars.iteritems():
-                if name not in options.__dict__:
-                    options.__dict__[name] = value
+            options.__dict__.update(cache_vars)
             if cache_vars.get('external_ca', False):
                 options.external_ca = False
                 options.interactive = False
@@ -761,7 +759,8 @@ def install(installer):
             options.host_name = host_name
             options.forwarders = dns.dns_forwarders
             options.reverse_zones = dns.reverse_zones
-            cache_vars = {n: getattr(options, n) for o, n in installer.knobs()}
+            cache_vars = {n: options.__dict__[n] for o, n in installer.knobs()
+                          if n in options.__dict__}
             write_cache(cache_vars)
 
         ca.install_step_0(False, None, options)
-- 
2.5.0

From 864701d46e061a4b186ed0af2cba5c01342a3f6a Mon Sep 17 00:00:00 2001
From: David Kupka <dku...@redhat.com>
Date: Wed, 16 Dec 2015 12:45:24 +0000
Subject: [PATCH 2/2] installer: Fix logic of reading option values from cache.

Only options explicitly set must be stored before installer exits first step
of external CA setup. When installer continues all stored option values must
be restored.

https://fedorahosted.org/freeipa/ticket/5556
---
 ipaserver/install/server/install.py | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/ipaserver/install/server/install.py b/ipaserver/install/server/install.py
index a07ca664e263a1bb49c6f5e18bc888fa66e56b55..2da1e3d04742f0fcb05470aff49a39b7850fa4b0 100644
--- a/ipaserver/install/server/install.py
+++ b/ipaserver/install/server/install.py
@@ -444,9 +444,7 @@ def install_check(installer):
             sys.exit("Directory Manager password required")
         try:
             cache_vars = read_cache(dm_password)
-            for name, value in cache_vars.items():
-                if name not in options.__dict__:
-                    options.__dict__[name] = value
+            options.__dict__.update(cache_vars)
             if cache_vars.get('external_ca', False):
                 options.external_ca = False
                 options.interactive = False
@@ -867,7 +865,8 @@ def install(installer):
             options.admin_password = admin_password
             options.host_name = host_name
             options.reverse_zones = dns.reverse_zones
-            cache_vars = {n: getattr(options, n) for o, n in installer.knobs()}
+            cache_vars = {n: options.__dict__[n] for o, n in installer.knobs()
+                          if n in options.__dict__}
             write_cache(cache_vars)
 
         ca.install_step_0(False, None, options)
-- 
2.5.0

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to