pgreco / rpms / ipa

Forked from forks/areguera/rpms/ipa 4 years ago
Clone

Blame SOURCES/0033-Disable-message-about-log-in-ipa-backup-if-IPA-is-no.patch

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