>From cf8911d9193eb4ec4404204d1cd87cc35d1780e9 Mon Sep 17 00:00:00 2001
From: Abhishek Koneru <akoneru@redhat.com>
Date: Wed, 5 Jun 2013 14:30:37 -0400
Subject: [PATCH] Changes to the displayed installation summary.

If pki_skip_configuration=True, then do not display the installation
summary. And, display client database details only when
pki_client_database_purge=False. Also replace \t with spaces in the
print messages.

Ticket #599
---
 base/server/src/engine/pkimessages.py |   58 ++++++++++++++++-----------------
 base/server/src/pkispawn              |   34 ++++++++++---------
 2 files changed, 48 insertions(+), 44 deletions(-)

diff --git a/base/server/src/engine/pkimessages.py b/base/server/src/engine/pkimessages.py
index 6f390fe9e9bf6cdbaa02d1c68addd312b5c715c3..26e5ab7916777103f2c63298972cbe4f21e15dc9 100644
--- a/base/server/src/engine/pkimessages.py
+++ b/base/server/src/engine/pkimessages.py
@@ -20,23 +20,23 @@
 #
 
 # PKI Deployment Engine Messages
-PKI_DICTIONARY_DEFAULT ="\n"\
+PKI_DICTIONARY_DEFAULT = "\n"\
 "=====================================================\n"\
 "    DISPLAY CONTENTS OF PKI DEFAULT DICTIONARY\n"\
 "====================================================="
-PKI_DICTIONARY_MASTER="\n"\
+PKI_DICTIONARY_MASTER = "\n"\
 "=====================================================\n"\
 "    DISPLAY CONTENTS OF PKI MASTER DICTIONARY\n"\
 "====================================================="
-PKI_DICTIONARY_SLOTS="\n"\
+PKI_DICTIONARY_SLOTS = "\n"\
 "=====================================================\n"\
 "    DISPLAY CONTENTS OF PKI SLOTS DICTIONARY\n"\
 "====================================================="
-PKI_DICTIONARY_SUBSYSTEM="\n"\
+PKI_DICTIONARY_SUBSYSTEM = "\n"\
 "=====================================================\n"\
 "    DISPLAY CONTENTS OF PKI SUBSYSTEM DICTIONARY\n"\
 "====================================================="
-PKI_DICTIONARY_WEB_SERVER="\n"\
+PKI_DICTIONARY_WEB_SERVER = "\n"\
 "=====================================================\n"\
 "    DISPLAY CONTENTS OF PKI WEB SERVER DICTIONARY\n"\
 "====================================================="
@@ -44,7 +44,7 @@ PKI_DICTIONARY_WEB_SERVER="\n"\
 
 
 # PKI Deployment Log Messages
-PKI_VERBOSITY=\
+PKI_VERBOSITY = \
 "VERBOSITY FLAGS    CONSOLE MESSAGE LEVEL       LOG MESSAGE LEVEL\n"\
 "=======================================================================\n"\
 "  NONE             error|warning               error|warning|info|debug\n"\
@@ -109,7 +109,7 @@ PKIDESTROY_BEGIN_MESSAGE_2 = "BEGIN destroying subsystem '%s' of "\
                              "instance '%s' . . ."
 PKIDESTROY_END_MESSAGE_2 = "END destroying subsystem '%s' of "\
                            "instance '%s'"
-PKIDESTROY_EPILOG =\
+PKIDESTROY_EPILOG = \
 "REMINDER:\n\n"\
 "    The default PKI instance path will be calculated and placed in front\n"\
 "    of the mandatory '-i <instance>' parameter, and the values that reside\n"\
@@ -118,13 +118,13 @@ PKIDESTROY_EPILOG =\
 "    utilized by 'pkidestroy' to remove this instance.\n\n"\
 "    Finally, if an optional '-p <prefix>' is defined, this value WILL be\n"\
 "    prepended to the default PKI instance path which is placed in front\n"\
-"    of the specified '-i <instance>' parameter.\n\n" +\
+"    of the specified '-i <instance>' parameter.\n\n" + \
 PKI_VERBOSITY
 PKISPAWN_BEGIN_MESSAGE_2 = "BEGIN spawning subsystem '%s' of "\
                            "instance '%s' . . ."
 PKISPAWN_END_MESSAGE_2 = "END spawning subsystem '%s' of "\
                          "instance '%s'"
-PKISPAWN_EPILOG =\
+PKISPAWN_EPILOG = \
 "REMINDER:\n\n"\
 "    If two or more Apache or Tomcat PKI 'instances' are specified via\n"\
 "    separate configuration files, remember that the following parameters\n"\
@@ -133,7 +133,7 @@ PKISPAWN_EPILOG =\
 "        Tomcat:  'pki_instance_name', 'pki_http_port', 'pki_https_port',\n"\
 "                 'pki_ajp_port', and 'pki_tomcat_server_port'\n\n"\
 "    Finally, if an optional '-p <prefix>' is defined, this value WILL NOT\n"\
-"    be prepended in front of the mandatory '-f <configuration_file>'.\n\n" +\
+"    be prepended in front of the mandatory '-f <configuration_file>'.\n\n" + \
 PKI_VERBOSITY
 
 
@@ -193,7 +193,7 @@ PKIHELPER_IS_A_DIRECTORY_1 = "'%s' is a directory"
 PKIHELPER_IS_A_FILE_1 = "'%s' is a file"
 PKIHELPER_IS_A_SYMLINK_1 = "'%s' is a symlink"
 PKIHELPER_JAR_XF_C_2 = "jar -xf %s -C %s"
-PKIHELPER_KRACONNECTOR_UPDATE_CONTACT =\
+PKIHELPER_KRACONNECTOR_UPDATE_CONTACT = \
     "contacting the CA to update the KRA connector"
 PKIHELPER_KRACONNECTOR_UPDATE_FAILURE = "Failed to update KRA connector on CA"
 PKIHELPER_KRACONNECTOR_UPDATE_FAILURE_2 = "Failed to update KRA connector for %s:%s"
@@ -238,24 +238,24 @@ PKIHELPER_REMOVE_FILTER_SECTION_1 = "removing filter section from '%s'"
 PKIHELPER_RM_F_1 = "rm -f %s"
 PKIHELPER_RM_RF_1 = "rm -rf %s"
 PKIHELPER_RMDIR_1 = "rmdir %s"
-PKIHELPER_SECURITY_DOMAIN_CONTACT_1 =\
+PKIHELPER_SECURITY_DOMAIN_CONTACT_1 = \
     "contacting the security domain master to update security domain '%s'"
-PKIHELPER_SECURITY_DOMAIN_GET_TOKEN_FAILURE_2 =\
+PKIHELPER_SECURITY_DOMAIN_GET_TOKEN_FAILURE_2 = \
     "Failed to get installation token from security domain '%s:%s'"
-PKIHELPER_SECURITY_DOMAIN_UNDEFINED =\
+PKIHELPER_SECURITY_DOMAIN_UNDEFINED = \
     "No security domain defined.\n"\
     "If this is an unconfigured instance, then that is OK.\n"\
     "Otherwise, manually delete the entry from the security domain master."
-PKIHELPER_SECURITY_DOMAIN_UNREACHABLE_1 =\
+PKIHELPER_SECURITY_DOMAIN_UNREACHABLE_1 = \
     "security domain '%s' may be offline or unreachable!"
-PKIHELPER_SECURITY_DOMAIN_UNREGISTERED_2 =\
+PKIHELPER_SECURITY_DOMAIN_UNREGISTERED_2 = \
     "this '%s' entry may not be registered with security domain '%s'!"
-PKIHELPER_SECURITY_DOMAIN_UPDATE_FAILURE_2 =\
+PKIHELPER_SECURITY_DOMAIN_UPDATE_FAILURE_2 = \
     "this '%s' entry will NOT be deleted from security domain '%s'!"
-PKIHELPER_SECURITY_DOMAIN_UPDATE_FAILURE_3 =\
+PKIHELPER_SECURITY_DOMAIN_UPDATE_FAILURE_3 = \
     "updateDomainXML FAILED to delete this '%s' entry from "\
     "security domain '%s': '%s'"
-PKIHELPER_SECURITY_DOMAIN_UPDATE_SUCCESS_2 =\
+PKIHELPER_SECURITY_DOMAIN_UPDATE_SUCCESS_2 = \
     "updateDomainXML SUCCESSFULLY deleted this '%s' entry from "\
     "security domain '%s'"
 PKIHELPER_SELINUX_DISABLED = "Selinux is disabled.  Not checking port contexts"
@@ -274,10 +274,10 @@ PKIHELPER_TOMCAT_INSTANCES_2 = "PKI Tomcat registry '%s' contains '%d' "\
 PKIHELPER_TOUCH_1 = "touch %s"
 PKIHELPER_UID_2 = "UID of '%s' is %s"
 PKIHELPER_UNDEFINED_CA_HOST_PORT = "CA Host or Port is undefined"
-PKIHELPER_UNDEFINED_CLIENT_DATABASE_PASSWORD_2 =\
+PKIHELPER_UNDEFINED_CLIENT_DATABASE_PASSWORD_2 = \
     "Either a value for '%s' MUST be defined in '%s', or "\
     "the randomly generated client pin MUST be used"
-PKIHELPER_UNDEFINED_CONFIGURATION_FILE_ENTRY_2 =\
+PKIHELPER_UNDEFINED_CONFIGURATION_FILE_ENTRY_2 = \
     "A value for '%s' MUST be defined in '%s'"
 PKIHELPER_UNDEFINED_SUBSYSTEM_NICKNAME = "subsystem nickname not defined"
 PKIHELPER_UNDEFINED_TOKEN_PASSWD_1 = "Password for token '%s' not defined"
@@ -301,21 +301,21 @@ PKI_CONFIG_EXTERNAL_CA_LOAD = "loading external CA signing certificate "\
 PKI_CONFIG_EXTERNAL_CA_CHAIN_LOAD = "loading external CA signing certificate "\
                                     "chain from file:"
 PKI_CONFIG_EXTERNAL_CSR_SAVE = "saving CA Signing CSR to file:"
-PKI_CONFIG_JAVA_CONFIGURATION_EXCEPTION =\
+PKI_CONFIG_JAVA_CONFIGURATION_EXCEPTION = \
     "Exception from Java Configuration Servlet:"
 PKI_CONFIG_RESPONSE_ADMIN_CERT = "adminCert:"
 PKI_CONFIG_RESPONSE_STATUS = "status:"
 PKI_CONFIG_NOT_YET_IMPLEMENTED_1 = " %s NOT YET IMPLEMENTED"
-PKI_CHECK_STATUS_MESSAGE = "\tTo check the status of the subsystem: "\
+PKI_CHECK_STATUS_MESSAGE = "    To check the status of the subsystem: "\
 "systemctl status pki-tomcatd\@%s.service"
-PKI_ACCESS_URL = "\tThe URL for the subsystem is https://%s:%s/%s"
-PKI_INSTANCE_RESTART_MESSAGE = "\tTo restart the subsystem: systemctl restart pki-tomcatd\@%s.service"
+PKI_ACCESS_URL = "    The URL for the subsystem is https://%s:%s/%s"
+PKI_INSTANCE_RESTART_MESSAGE = "    To restart the subsystem: systemctl restart pki-tomcatd\@%s.service"
 
-PKI_SPAWN_INFORMATION_HEADER = "\n\t==========================================================================\n"\
-                               "\t                            INSTALLATION SUMMARY\n"\
-                               "\t==========================================================================\n"
+PKI_SPAWN_INFORMATION_HEADER = "\n    ==========================================================================\n"\
+                               "                                INSTALLATION SUMMARY\n"\
+                               "    ==========================================================================\n"
 
-PKI_SPAWN_INFORMATION_FOOTER = "\n\t==========================================================================\n"
+PKI_SPAWN_INFORMATION_FOOTER = "\n    ==========================================================================\n"
 
 
 # PKI Deployment "Scriptlet" Messages
diff --git a/base/server/src/pkispawn b/base/server/src/pkispawn
index 845d764daad6a9c95e1b87df5832a0203e0f5be7..60c7d25701a609dafe9d8a785a3fd533eb791a43 100755
--- a/base/server/src/pkispawn
+++ b/base/server/src/pkispawn
@@ -53,7 +53,7 @@ error was:
 """ % sys.exc_value
     sys.exit(1)
 
-#Handle the Keyboard Interrupt
+# Handle the Keyboard Interrupt
 def interrupt_handler(signal, frame):
     print
     print '\nInstallation canceled.'
@@ -78,7 +78,7 @@ def main(argv):
 
     # Generate a timestamp
     config.pki_timestamp = date('%Y%m%d%H%M%S', time.localtime(ticks))
-    config.pki_certificate_timestamp =\
+    config.pki_certificate_timestamp = \
         date('%Y-%m-%d %H:%M:%S', time.localtime(ticks))
 
     # Obtain the architecture bit-size
@@ -276,19 +276,19 @@ def main(argv):
         else:
             break
 
-    if not os.path.exists(config.PKI_DEPLOYMENT_SOURCE_ROOT +\
+    if not os.path.exists(config.PKI_DEPLOYMENT_SOURCE_ROOT + \
                           "/" + config.pki_subsystem.lower()):
-        print "ERROR:  " + log.PKI_SUBSYSTEM_NOT_INSTALLED_1 %\
+        print "ERROR:  " + log.PKI_SUBSYSTEM_NOT_INSTALLED_1 % \
             config.pki_subsystem.lower()
         sys.exit(1)
 
     # Enable 'pkispawn' logging.
     rv = 0
-    config.pki_log_dir = config.pki_root_prefix +\
+    config.pki_log_dir = config.pki_root_prefix + \
                          config.PKI_DEPLOYMENT_LOG_ROOT
-    config.pki_log_name = "pki" + "-" +\
-                          config.pki_subsystem.lower() +\
-                          "-" + "spawn" + "." +\
+    config.pki_log_name = "pki" + "-" + \
+                          config.pki_subsystem.lower() + \
+                          "-" + "spawn" + "." + \
                           config.pki_timestamp + "." + "log"
     rv = pkilogging.enable_pki_logger(config.pki_log_dir,
                                       config.pki_log_name,
@@ -318,7 +318,7 @@ def main(argv):
     # Combine the various sectional dictionaries into a PKI master dictionary
     parser.compose_pki_master_dictionary()
 
-    config.pki_master_dict['pki_spawn_log'] = config.pki_log_dir + "/" +\
+    config.pki_master_dict['pki_spawn_log'] = config.pki_log_dir + "/" + \
                                               config.pki_log_name
     config.pki_log.debug(log.PKI_DICTIONARY_MASTER,
                          extra=config.PKI_INDENTATION_LEVEL_0)
@@ -367,7 +367,7 @@ def main(argv):
     for pki_scriptlet in pki_subsystem_scriptlets:
         scriptlet = __import__("pki.deployment." +
                                pki_scriptlet,
-                               fromlist = [pki_scriptlet])
+                               fromlist=[pki_scriptlet])
         instance = scriptlet.PkiScriptlet()
         try:
             rv = instance.spawn()
@@ -384,7 +384,10 @@ def main(argv):
     config.pki_log.debug(pkilogging.format(config.pki_master_dict),
                          extra=config.PKI_INDENTATION_LEVEL_0)
 
-    print_install_information()
+    # print installation summary
+    skip_configuration = config.str2bool(config.pki_master_dict['pki_skip_configuration'])
+    if not skip_configuration:
+        print_install_information()
 
     print "Installation complete."
     print
@@ -392,16 +395,17 @@ def main(argv):
 def print_install_information():
 
     print log.PKI_SPAWN_INFORMATION_HEADER
-    print "\tAdmin username: %s" % config.pki_master_dict['pki_admin_uid']
-    print "\tLocation of client database: %s" % config.pki_master_dict['pki_client_database_dir']
-    print "\tClient certificate nickname: %s" % config.pki_master_dict['pki_admin_nickname']
+    print "    Admin username: %s" % config.pki_master_dict['pki_admin_uid']
+    if not config.str2bool(config.pki_master_dict['pki_client_database_purge']):
+        print "    Location of client database: %s" % config.pki_master_dict['pki_client_database_dir']
+    print "    Client certificate nickname: %s" % config.pki_master_dict['pki_admin_nickname']
     print log.PKI_CHECK_STATUS_MESSAGE % config.pki_master_dict['pki_instance_name']
     print log.PKI_INSTANCE_RESTART_MESSAGE % config.pki_master_dict['pki_instance_name']
     print log.PKI_ACCESS_URL % (config.pki_master_dict['pki_hostname'],
                                 config.pki_master_dict['pki_https_port'],
                                 config.pki_subsystem.lower())
     print log.PKI_SPAWN_INFORMATION_FOOTER
-    
+
 def log_error_details():
         type, value, stacktrace = sys.exc_info()
         config.pki_log.debug("Error Type: " + type.__name__, extra=config.PKI_INDENTATION_LEVEL_2)
-- 
1.7.10.2

