From 648d7c0d38ef99196531e94cd9803c630e7fb05c Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Tue, 1 May 2018 11:15:18 -0400 Subject: [PATCH] Disable message about log in ipa-backup if IPA is not configured Introduce server installation constants similar to the client but only tie in SERVER_NOT_CONFIGURED right now. For the case of not configured don't spit out the "See for more information" because no logging was actually done. In the case of ipa-backup this could also be confusing if the --log-file option was also passed in because it would not be used. https://pagure.io/freeipa/issue/6843 Signed-off-by: Rob Crittenden Reviewed-By: Christian Heimes --- install/tools/man/ipa-backup.1 | 2 ++ ipapython/admintool.py | 8 +++++++- ipaserver/install/installutils.py | 5 +++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/install/tools/man/ipa-backup.1 b/install/tools/man/ipa-backup.1 index ff9759ec7..9e2900f77 100644 --- a/install/tools/man/ipa-backup.1 +++ b/install/tools/man/ipa-backup.1 @@ -69,6 +69,8 @@ Log to the given file 0 if the command was successful 1 if an error occurred + +2 if IPA is not configured .SH "FILES" .PP \fI/var/lib/ipa/backup\fR diff --git a/ipapython/admintool.py b/ipapython/admintool.py index 329e20f37..5a5d3eb42 100644 --- a/ipapython/admintool.py +++ b/ipapython/admintool.py @@ -32,6 +32,10 @@ from ipapython import version from ipapython import config from ipapython.ipa_log_manager import standard_logging_setup +SUCCESS = 0 +SERVER_INSTALL_ERROR = 1 +SERVER_NOT_CONFIGURED = 2 + logger = logging.getLogger(__name__) @@ -301,7 +305,9 @@ class AdminTool(object): if error_message: logger.error('%s', error_message) message = "The %s command failed." % self.command_name - if self.log_file_name: + if self.log_file_name and return_value != 2: + # magic value because this is common between server and client + # but imports are not straigthforward message += " See %s for more information" % self.log_file_name logger.error('%s', message) diff --git a/ipaserver/install/installutils.py b/ipaserver/install/installutils.py index 9cee1a5f8..39f0bb677 100644 --- a/ipaserver/install/installutils.py +++ b/ipaserver/install/installutils.py @@ -56,7 +56,7 @@ from ipalib.install import sysrestore from ipalib.install.kinit import kinit_password import ipaplatform from ipapython import ipautil, admintool, version -from ipapython.admintool import ScriptError +from ipapython.admintool import ScriptError, SERVER_NOT_CONFIGURED # noqa: E402 from ipapython.certdb import EXTERNAL_CA_TRUST_FLAGS from ipapython.ipaldap import DIRMAN_DN, LDAPClient from ipalib.util import validate_hostname @@ -970,7 +970,8 @@ def check_server_configuration(): """ server_fstore = sysrestore.FileStore(paths.SYSRESTORE) if not server_fstore.has_files(): - raise RuntimeError("IPA is not configured on this system.") + raise ScriptError("IPA is not configured on this system.", + rval=SERVER_NOT_CONFIGURED) def remove_file(filename):