summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-11-06 12:05:30 +0000
committerGerrit Code Review <review@openstack.org>2018-11-06 12:05:30 +0000
commit73a47b66529d4b5b7848fde72e555319b20da284 (patch)
tree58dfd003b96935bdbf89fcad600bc4346c47a28e
parente4621348ab5cd8f30cb74c339b5449343912b692 (diff)
parentb74cae51e3bcad31371e52e762d2dfdeb893e961 (diff)
Merge "Fix novajoin-ipa-setup to set logging correctly"
-rw-r--r--novajoin/configure_ipa.py12
-rw-r--r--novajoin/novajoin/tests/integration/test_ipa.py13
-rwxr-xr-xscripts/novajoin-ipa-setup8
3 files changed, 21 insertions, 12 deletions
diff --git a/novajoin/configure_ipa.py b/novajoin/configure_ipa.py
index ac8c358..ec5c890 100644
--- a/novajoin/configure_ipa.py
+++ b/novajoin/configure_ipa.py
@@ -155,8 +155,11 @@ class NovajoinRole(object):
155 except Exception as e: 155 except Exception as e:
156 raise ConfigurationError("get_ca_certs() error: %s" % e) 156 raise ConfigurationError("get_ca_certs() error: %s" % e)
157 157
158 certs = [x509.load_certificate(c[0], x509.DER) for c in certs 158 if version.NUM_VERSION < 40600:
159 if c[2] is not False] 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 return certs 164 return certs
162 165
@@ -200,8 +203,9 @@ class NovajoinRole(object):
200 os.close(cafile_fd) 203 os.close(cafile_fd)
201 204
202 ca_certs = self._get_ca_certs(server, realm) 205 ca_certs = self._get_ca_certs(server, realm)
203 ca_certs = [cert.public_bytes(serialization.Encoding.PEM) 206 if version.NUM_VERSION < 40600:
204 for cert in ca_certs] 207 ca_certs = [cert.public_bytes(serialization.Encoding.PEM)
208 for cert in ca_certs]
205 x509.write_certificate_list(ca_certs, cafile_name) 209 x509.write_certificate_list(ca_certs, cafile_name)
206 210
207 return cafile_name 211 return cafile_name
diff --git a/novajoin/novajoin/tests/integration/test_ipa.py b/novajoin/novajoin/tests/integration/test_ipa.py
index e50cc06..74220e7 100644
--- a/novajoin/novajoin/tests/integration/test_ipa.py
+++ b/novajoin/novajoin/tests/integration/test_ipa.py
@@ -28,10 +28,8 @@ import testtools
28import time 28import time
29import uuid 29import uuid
30 30
31
32from ipapython.ipa_log_manager import log_mgr
33
34from ipalib import api 31from ipalib import api
32from ipapython import version
35import six 33import six
36 34
37from novajoin import config 35from novajoin import config
@@ -58,9 +56,14 @@ class TestIPAService(testtools.TestCase):
58 CONF.keytab = '/tmp/test.keytab' 56 CONF.keytab = '/tmp/test.keytab'
59 super(TestIPAService, self).setUp() 57 super(TestIPAService, self).setUp()
60 self.ipaclient = IPAClient() 58 self.ipaclient = IPAClient()
59
61 # suppress the Forwarding messages from ipa 60 # suppress the Forwarding messages from ipa
62 console = log_mgr.get_handler('console') 61 # This is not needed in versions newer than 4.7
63 console.setLevel(logging.WARN) 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 if hostname is None: 67 if hostname is None:
65 hostname = six.text_type(str(uuid.uuid4()) + '.' + api.env.domain) 68 hostname = six.text_type(str(uuid.uuid4()) + '.' + api.env.domain)
66 os.environ['KRB5_CONFIG'] = 'krb5.conf' 69 os.environ['KRB5_CONFIG'] = 'krb5.conf'
diff --git a/scripts/novajoin-ipa-setup b/scripts/novajoin-ipa-setup
index 3d63a91..03d9416 100755
--- a/scripts/novajoin-ipa-setup
+++ b/scripts/novajoin-ipa-setup
@@ -20,7 +20,6 @@ import shutil
20import sys 20import sys
21from ipalib import api, errors 21from ipalib import api, errors
22from ipapython import version 22from ipapython import version
23from ipapython.ipa_log_manager import log_mgr
24from novajoin import configure_ipa 23from novajoin import configure_ipa
25from novajoin.errors import ConfigurationError 24from novajoin.errors import ConfigurationError
26 25
@@ -67,8 +66,11 @@ if __name__ == '__main__':
67 and opts.realm and opts.server) 66 and opts.realm and opts.server)
68 67
69 # suppress the Forwarding messages from ipa 68 # suppress the Forwarding messages from ipa
70 console = log_mgr.get_handler('console') 69 # This is not needed in versions newer than 4.7
71 console.setLevel(logging.WARN) 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 novajoin = configure_ipa.NovajoinRole(user=opts.user, 75 novajoin = configure_ipa.NovajoinRole(user=opts.user,
74 hostname=opts.hostname) 76 hostname=opts.hostname)