From 70173f38eeb149ef9f1987d918c96f262f6ffd34 Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Fri, 8 Sep 2017 13:27:09 -0400 Subject: [PATCH] Fix IPA v4.5.0 import issue with kinit_keytab Centralize ipalib_imported so that all primary IPA imports are done in one place. The issue was that IPA imports were being done in two places one of which was simpler and not aware of the import errors of the other. The symptom was that if one of the moved IPA v4.5.0 imports failed then this was handled properly in ipa.py but in util.py where only ipalib.api is imported the import would succeed. This mismatch meant that api.finalize() wouddln't have been called in ipa.py so any references to api.env.* in util.py would fail. Change-Id: I6016892630510b816721cea5b20c8d6e7f8d34fa --- novajoin/ipa.py | 11 ++++++++++- novajoin/util.py | 8 ++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/novajoin/ipa.py b/novajoin/ipa.py index f96f450..5817f4c 100644 --- a/novajoin/ipa.py +++ b/novajoin/ipa.py @@ -20,13 +20,22 @@ try: from gssapi.exceptions import GSSError from ipalib import api from ipalib import errors - from ipapython.ipautil import kinit_keytab ipalib_imported = True except ImportError: # ipalib/ipapython are not available in PyPy yet, don't make it # a showstopper for the tests. ipalib_imported = False +if ipalib_imported: + try: + from ipapython.ipautil import kinit_keytab + except ImportError: + # The import moved in freeIPA 4.5.0 + try: + from ipalib.install.kinit import kinit_keytab + except ImportError: + ipalib_imported = False + from novajoin.util import get_domain from oslo_config import cfg from oslo_log import log as logging diff --git a/novajoin/util.py b/novajoin/util.py index a6c321b..1d4fc90 100644 --- a/novajoin/util.py +++ b/novajoin/util.py @@ -18,13 +18,9 @@ from novajoin.errors import ConfigurationError from oslo_config import cfg from oslo_log import log as logging -try: +from novajoin.ipa import ipalib_imported +if ipalib_imported: from ipalib import api - ipalib_imported = True -except ImportError: - # ipalib/ipapython are not available in PyPi yet, don't make it - # a showstopper for the tests. - ipalib_imported = False CONF = cfg.CONF