client: move checks to client.install_check

Move checks from ipa-client-install to clien.install_check

https://fedorahosted.org/freeipa/ticket/6392

Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
This commit is contained in:
Martin Basti 2016-10-27 18:50:29 +02:00 committed by Jan Cholasta
parent 33537f5556
commit 2c226ebc27
2 changed files with 24 additions and 17 deletions

View File

@ -28,10 +28,8 @@ from optparse import SUPPRESS_HELP, OptionGroup, OptionValueError
from ipaclient.install import client
from ipapython.ipa_log_manager import standard_logging_setup, root_logger
from ipapython.ipautil import is_fips_enabled
from ipaplatform.tasks import tasks
from ipaplatform.paths import paths
from ipapython import version, sysrestore
from ipapython import version
from ipapython.config import IPAOptionParser
from ipalib import x509
from ipalib.util import normalize_hostname, validate_domain_name
@ -223,15 +221,8 @@ def logging_setup(options):
def main():
fstore = sysrestore.FileStore(paths.IPA_CLIENT_SYSRESTORE)
safe_options, options = parse_options()
if not os.getegid() == 0:
sys.exit("\nYou must be root to run ipa-client-install.\n")
if is_fips_enabled():
sys.exit("Installing IPA client in FIPS mode is not supported")
tasks.check_selinux_status()
logging_setup(options)
root_logger.debug(
'%s was invoked with options: %s', sys.argv[0], safe_options)
@ -243,12 +234,9 @@ def main():
if options.uninstall:
return client.uninstall(options, env)
if client.is_ipa_client_installed(fstore, on_master=options.on_master):
root_logger.error("IPA client is already configured on this system.")
root_logger.info(
"If you want to reinstall the IPA client, uninstall it first " +
"using 'ipa-client-install --uninstall'.")
return client.CLIENT_ALREADY_CONFIGURED
rval_check = client.install_check(options)
if rval_check != client.SUCCESS:
return rval_check
rval = client.install(options, env)
if rval == client.CLIENT_INSTALL_ERROR:

View File

@ -65,13 +65,13 @@ from ipapython.ipautil import (
CalledProcessError,
dir_exists,
file_exists,
is_fips_enabled,
realm_to_suffix,
run,
user_input,
)
from ipapython.ssh import SSHPublicKey
SUCCESS = 0
CLIENT_INSTALL_ERROR = 1
CLIENT_NOT_CONFIGURED = 2
@ -1918,6 +1918,25 @@ def purge_host_keytab(realm):
realm, paths.KRB5_KEYTAB)
def install_check(options):
fstore = sysrestore.FileStore(paths.IPA_CLIENT_SYSRESTORE)
if not os.getegid() == 0:
sys.exit("\nYou must be root to run ipa-client-install.\n")
if is_fips_enabled():
sys.exit("Installing IPA client in FIPS mode is not supported")
tasks.check_selinux_status()
if is_ipa_client_installed(fstore, on_master=options.on_master):
root_logger.error("IPA client is already configured on this system.")
root_logger.info(
"If you want to reinstall the IPA client, uninstall it first " +
"using 'ipa-client-install --uninstall'.")
return CLIENT_ALREADY_CONFIGURED
return SUCCESS
def install(options, env):
fstore = sysrestore.FileStore(paths.IPA_CLIENT_SYSRESTORE)
statestore = sysrestore.StateFile(paths.IPA_CLIENT_SYSRESTORE)