From 2c3a042c06b919ff754bfce2ce6e40b9f1827e97 Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Thu, 9 Jul 2020 10:38:42 -0400 Subject: [PATCH] Update check_client_configuration to use new client fact check_client_configuration differs from is_ipa_client_configured in that it raises an exception if not configured so is a nice convenience in AdminTool scripts. Port it to call to is_ipa_client_configured() instead of determining the install state on its own. https://pagure.io/freeipa/issue/8384 Signed-off-by: Rob Crittenden Reviewed-By: Alexander Bokovoy Reviewed-By: Francois Cami --- ipalib/util.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/ipalib/util.py b/ipalib/util.py index cd6cd02c1..1e60543f1 100644 --- a/ipalib/util.py +++ b/ipalib/util.py @@ -60,6 +60,8 @@ from ipalib.constants import ( TLS_VERSIONS, TLS_VERSION_MINIMAL, TLS_VERSION_MAXIMAL, TLS_VERSION_DEFAULT_MIN, TLS_VERSION_DEFAULT_MAX, ) +# pylint: disable=ipa-forbidden-import +from ipalib.facts import is_ipa_client_configured from ipalib.text import _ from ipaplatform.constants import constants from ipaplatform.paths import paths @@ -1174,6 +1176,12 @@ def check_client_configuration(env=None): """ Check if IPA client is configured on the system. + This is a convenience wrapper that also supports using + a custom configuration via IPA_CONFDIR. + + Raises a ScriptError exception if the client is not + configured. + Hardcode return code to avoid recursive imports """ CLIENT_NOT_CONFIGURED = 2 @@ -1187,16 +1195,10 @@ def check_client_configuration(env=None): f'{env.confdir} is missing {env.conf_default})', CLIENT_NOT_CONFIGURED ) - elif ( - os.path.isfile(paths.IPA_DEFAULT_CONF) and - os.path.isfile( - os.path.join(paths.IPA_CLIENT_SYSRESTORE, 'sysrestore.state') - ) - ): - # standard installation, check for config and client sysrestore state + + if is_ipa_client_configured(): return True else: - # client not configured raise ScriptError( 'IPA client is not configured on this system', CLIENT_NOT_CONFIGURED