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
This commit is contained in:
Rob Crittenden 2017-09-08 13:27:09 -04:00
parent 313569bfa9
commit 70173f38ee
2 changed files with 12 additions and 7 deletions

View File

@ -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

View File

@ -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