Browse Source

Merge "Fix novajoin-ipa-setup to set logging correctly"

tags/1.0.21
Zuul 7 months ago
parent
commit
73a47b6652

+ 8
- 4
novajoin/configure_ipa.py View File

@@ -155,8 +155,11 @@ class NovajoinRole(object):
155 155
             except Exception as e:
156 156
                 raise ConfigurationError("get_ca_certs() error: %s" % e)
157 157
 
158
-        certs = [x509.load_certificate(c[0], x509.DER) for c in certs
159
-                 if c[2] is not False]
158
+        if version.NUM_VERSION < 40600:
159
+            certs = [x509.load_certificate(c[0], x509.DER) for c in certs
160
+                     if c[2] is not False]
161
+        else:
162
+            certs = [c[0] for c in certs if c[2] is not False]
160 163
 
161 164
         return certs
162 165
 
@@ -200,8 +203,9 @@ class NovajoinRole(object):
200 203
         os.close(cafile_fd)
201 204
 
202 205
         ca_certs = self._get_ca_certs(server, realm)
203
-        ca_certs = [cert.public_bytes(serialization.Encoding.PEM)
204
-                    for cert in ca_certs]
206
+        if version.NUM_VERSION < 40600:
207
+            ca_certs = [cert.public_bytes(serialization.Encoding.PEM)
208
+                        for cert in ca_certs]
205 209
         x509.write_certificate_list(ca_certs, cafile_name)
206 210
 
207 211
         return cafile_name

+ 8
- 5
novajoin/novajoin/tests/integration/test_ipa.py View File

@@ -28,10 +28,8 @@ import testtools
28 28
 import time
29 29
 import uuid
30 30
 
31
-
32
-from ipapython.ipa_log_manager import log_mgr
33
-
34 31
 from ipalib import api
32
+from ipapython import version
35 33
 import six
36 34
 
37 35
 from novajoin import config
@@ -58,9 +56,14 @@ class TestIPAService(testtools.TestCase):
58 56
         CONF.keytab = '/tmp/test.keytab'
59 57
         super(TestIPAService, self).setUp()
60 58
         self.ipaclient = IPAClient()
59
+
61 60
         # suppress the Forwarding messages from ipa
62
-        console = log_mgr.get_handler('console')
63
-        console.setLevel(logging.WARN)
61
+        # This is not needed in versions newer than 4.7
62
+        if version.NUM_VERSION < 40600:
63
+            from ipapython.ipa_log_manager import log_mgr
64
+            console = log_mgr.get_handler('console')
65
+            console.setLevel(logging.WARN)
66
+
64 67
         if hostname is None:
65 68
             hostname = six.text_type(str(uuid.uuid4()) + '.' + api.env.domain)
66 69
         os.environ['KRB5_CONFIG'] = 'krb5.conf'

+ 5
- 3
scripts/novajoin-ipa-setup View File

@@ -20,7 +20,6 @@ import shutil
20 20
 import sys
21 21
 from ipalib import api, errors
22 22
 from ipapython import version
23
-from ipapython.ipa_log_manager import log_mgr
24 23
 from novajoin import configure_ipa
25 24
 from novajoin.errors import ConfigurationError
26 25
 
@@ -67,8 +66,11 @@ if __name__ == '__main__':
67 66
                                 and opts.realm and opts.server)
68 67
 
69 68
     # suppress the Forwarding messages from ipa
70
-    console = log_mgr.get_handler('console')
71
-    console.setLevel(logging.WARN)
69
+    # This is not needed in versions newer than 4.7
70
+    if version.NUM_VERSION < 40600:
71
+        from ipapython.ipa_log_manager import log_mgr
72
+        console = log_mgr.get_handler('console')
73
+        console.setLevel(logging.WARN)
72 74
 
73 75
     novajoin = configure_ipa.NovajoinRole(user=opts.user,
74 76
                                           hostname=opts.hostname)

Loading…
Cancel
Save