URL: https://github.com/freeipa/freeipa/pull/741
Author: stlaz
 Title: #741: Migration
Action: opened

PR body:
"""
**Allow rewriting of cached properties**
    
Cached property should not be treated anyway special from a normal
property. If we need to rewrite/remove it, we should be able to do
just so.

**Refresh Dogtag RestClient.ca_host property**
    
Refresh the ca_host property of the Dogtag's RestClient class when
it's requested as a context manager.
    
This solves the problem which would occur on DL0 when installing
CA against an old master which does not have port 8443 accessible.
The setup tries to update the cert profiles via this port but
fail. This operation should be performed against the local instance
anyway.

https://pagure.io/freeipa/issue/6878

"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/741/head:pr741
git checkout pr741
From 35ec2ae8ee9a06ced875372cdf6985fed3cf254a Mon Sep 17 00:00:00 2001
From: Stanislav Laznicka <slazn...@redhat.com>
Date: Thu, 27 Apr 2017 12:38:19 +0200
Subject: [PATCH 1/2] Allow rewriting of cached properties

Cached property should not be treated anyway special from a normal
property. If we need to rewrite/remove it, we should be able to do
just so.

https://pagure.io/freeipa/issue/6878
---
 ipalib/util.py              | 4 +---
 ipaserver/plugins/dogtag.py | 1 +
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/ipalib/util.py b/ipalib/util.py
index e9d4105..b9206eb 100644
--- a/ipalib/util.py
+++ b/ipalib/util.py
@@ -520,10 +520,8 @@ def __get__(self, obj, cls):
         return self.store[obj]
 
     def __set__(self, obj, value):
-        raise AttributeError("can't set attribute")
+        self.store[obj] = value
 
-    def __delete__(self, obj):
-        raise AttributeError("can't delete attribute")
 
 # regexp matching signed floating point number (group 1) followed by
 # optional whitespace followed by time unit, e.g. day, hour (group 7)
diff --git a/ipaserver/plugins/dogtag.py b/ipaserver/plugins/dogtag.py
index 3997531..9e4032c 100644
--- a/ipaserver/plugins/dogtag.py
+++ b/ipaserver/plugins/dogtag.py
@@ -1248,6 +1248,7 @@ def __init__(self, api):
         else:
             self.client_certfile = paths.RA_AGENT_PEM
             self.client_keyfile = paths.RA_AGENT_KEY
+
         super(RestClient, self).__init__(api)
 
         # session cookie

From b3a0361bdaa08a952e810fd69406b3833594fd21 Mon Sep 17 00:00:00 2001
From: Stanislav Laznicka <slazn...@redhat.com>
Date: Thu, 27 Apr 2017 12:51:30 +0200
Subject: [PATCH 2/2] Refresh Dogtag RestClient.ca_host property

Refresh the ca_host property of the Dogtag's RestClient class when
it's requested as a context manager.

This solves the problem which would occur on DL0 when installing
CA against an old master which does not have port 8443 accessible.
The setup tries to update the cert profiles via this port but
fail. This operation should be performed against the local instance
anyway.

https://pagure.io/freeipa/issue/6878
---
 ipaserver/plugins/dogtag.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/ipaserver/plugins/dogtag.py b/ipaserver/plugins/dogtag.py
index 9e4032c..92551f6 100644
--- a/ipaserver/plugins/dogtag.py
+++ b/ipaserver/plugins/dogtag.py
@@ -1279,6 +1279,10 @@ def __enter__(self):
         """Log into the REST API"""
         if self.cookie is not None:
             return
+
+        if not host_has_service(api.env.ca_host, self.api.Backend.ldap2, "CA"):
+            self.ca_host = api.env.ca_host
+
         status, resp_headers, _resp_body = dogtag.https_request(
             self.ca_host, self.override_port or self.env.ca_agent_port,
             url='/ca/rest/account/login',
-- 
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