summaryrefslogtreecommitdiffstats
path: root/base/deploy/src/pkispawn
diff options
context:
space:
mode:
Diffstat (limited to 'base/deploy/src/pkispawn')
-rwxr-xr-xbase/deploy/src/pkispawn128
1 files changed, 77 insertions, 51 deletions
diff --git a/base/deploy/src/pkispawn b/base/deploy/src/pkispawn
index a48a4753c..2ac21a60a 100755
--- a/base/deploy/src/pkispawn
+++ b/base/deploy/src/pkispawn
@@ -23,15 +23,16 @@
import sys
if not hasattr(sys, "hexversion") or sys.hexversion < 0x020700f0:
print "Python version %s.%s.%s is too old." % sys.version_info[:3]
- print "Please upgrade to at least Python 2.7.0."
+ print "Please upgrade to at least Python 2.7.0."
sys.exit(1)
try:
import argparse
import logging
import os
import pprint
+ from time import strftime as date
from pki.deployment import pkiconfig as config
- from pki.deployment import pkihelper
+ from pki.deployment import pkiparser as parse
from pki.deployment import pkilogging
from pki.deployment import pkimessages as log
except ImportError:
@@ -55,40 +56,49 @@ def main(argv):
# Set the umask
os.umask(config.PKI_DEPLOYMENT_DEFAULT_UMASK)
+ # Generate a timestamp
+ config.pki_timestamp = date('%Y%m%d%H%M%S')
+
# Initialize 'pretty print' for objects
pp = pprint.PrettyPrinter(indent=4)
# Read and process command-line arguments.
- pkihelper.process_command_line_arguments(argv)
+ parse.process_command_line_arguments(argv)
# Enable 'pkispawn' logging.
rv = 0
if not config.pki_update_flag:
- pki_deployment_begin = log.PKISPAWN_BEGIN_MESSAGE_2
- pki_deployment_end = log.PKISPAWN_END_MESSAGE_2
- config.pki_log_dir = config.pki_root_prefix +\
- config.PKISPAWN_LOG_PATH
- config.pki_log_name = config.PKISPAWN_LOG_PREFIX +\
- config.pki_subsystem.lower() +\
- config.PKISPAWN_LOG_SUFFIX
+ if not config.pki_dry_run_flag:
+ config.pki_log_dir = config.pki_root_prefix +\
+ "/var/log"
+ config.pki_log_name = "pki" + "-" +\
+ config.pki_subsystem.lower() +\
+ "-" + "spawn" + "." +\
+ config.pki_timestamp + "." + "log"
+ else:
+ config.pki_log_dir = "/dev"
+ config.pki_log_name = "null"
rv = pkilogging.enable_pki_logger(config.pki_log_dir,
config.pki_log_name,
config.pki_log_level,
config.pki_console_log_level,
- config.PKISPAWN_LOGGER)
+ "pkispawn")
else:
- pki_deployment_begin = log.PKIRESPAWN_BEGIN_MESSAGE_2
- pki_deployment_end = log.PKIRESPAWN_END_MESSAGE_2
- config.pki_log_dir = config.pki_root_prefix +\
- config.PKIRESPAWN_LOG_PATH
- config.pki_log_name = config.PKIRESPAWN_LOG_PREFIX +\
- config.pki_subsystem.lower() +\
- config.PKIRESPAWN_LOG_SUFFIX
+ if not config.pki_dry_run_flag:
+ config.pki_log_dir = config.pki_root_prefix +\
+ "/var/log"
+ config.pki_log_name = "pki" + "-" +\
+ config.pki_subsystem.lower() +\
+ "-" + "respawn" + "." +\
+ config.pki_timestamp + "." + "log"
+ else:
+ config.pki_log_dir = "/dev"
+ config.pki_log_name = "null"
rv = pkilogging.enable_pki_logger(config.pki_log_dir,
config.pki_log_name,
config.pki_log_level,
config.pki_console_log_level,
- config.PKIRESPAWN_LOGGER)
+ "pkirespawn")
if rv != OSError:
config.pki_log = rv
else:
@@ -96,17 +106,24 @@ def main(argv):
sys.exit(1)
# Read the specified PKI configuration file.
- rv = pkihelper.read_pki_configuration_file()
+ rv = parse.read_pki_configuration_file()
if rv != 0:
- config.pki_log.error(PKI_UNABLE_TO_PARSE_1, rv)
+ config.pki_log.error(PKI_UNABLE_TO_PARSE_1, rv,
+ extra=config.PKI_INDENTATION_LEVEL_0)
sys.exit(1)
else:
- config.pki_log.debug(log.PKI_DICTIONARY_COMMON)
- config.pki_log.debug(pp.pformat(config.pki_common_dict))
- config.pki_log.debug(log.PKI_DICTIONARY_WEB_SERVER)
- config.pki_log.debug(pp.pformat(config.pki_web_server_dict))
- config.pki_log.debug(log.PKI_DICTIONARY_SUBSYSTEM)
- config.pki_log.debug(pp.pformat(config.pki_subsystem_dict))
+ config.pki_log.debug(log.PKI_DICTIONARY_COMMON,
+ extra=config.PKI_INDENTATION_LEVEL_0)
+ config.pki_log.debug(pp.pformat(config.pki_common_dict),
+ extra=config.PKI_INDENTATION_LEVEL_0)
+ config.pki_log.debug(log.PKI_DICTIONARY_WEB_SERVER,
+ extra=config.PKI_INDENTATION_LEVEL_0)
+ config.pki_log.debug(pp.pformat(config.pki_web_server_dict),
+ extra=config.PKI_INDENTATION_LEVEL_0)
+ config.pki_log.debug(log.PKI_DICTIONARY_SUBSYSTEM,
+ extra=config.PKI_INDENTATION_LEVEL_0)
+ config.pki_log.debug(pp.pformat(config.pki_subsystem_dict),
+ extra=config.PKI_INDENTATION_LEVEL_0)
# Override PKI configuration file values with 'custom' command-line values.
if not config.pki_instance_name is None:
@@ -121,39 +138,50 @@ def main(argv):
if not config.pki_ajp_port is None:
config.pki_web_server_dict['pki_ajp_port'] =\
config.pki_ajp_port
- config.pki_log.debug(log.PKI_DICTIONARY_COMMON)
- config.pki_log.debug(pp.pformat(config.pki_common_dict))
- config.pki_log.debug(log.PKI_DICTIONARY_WEB_SERVER)
- config.pki_log.debug(pp.pformat(config.pki_web_server_dict))
- config.pki_log.debug(log.PKI_DICTIONARY_SUBSYSTEM)
- config.pki_log.debug(pp.pformat(config.pki_subsystem_dict))
+ config.pki_log.debug(log.PKI_DICTIONARY_COMMON,
+ extra=config.PKI_INDENTATION_LEVEL_0)
+ config.pki_log.debug(pp.pformat(config.pki_common_dict),
+ extra=config.PKI_INDENTATION_LEVEL_0)
+ config.pki_log.debug(log.PKI_DICTIONARY_WEB_SERVER,
+ extra=config.PKI_INDENTATION_LEVEL_0)
+ config.pki_log.debug(pp.pformat(config.pki_web_server_dict),
+ extra=config.PKI_INDENTATION_LEVEL_0)
+ config.pki_log.debug(log.PKI_DICTIONARY_SUBSYSTEM,
+ extra=config.PKI_INDENTATION_LEVEL_0)
+ config.pki_log.debug(pp.pformat(config.pki_subsystem_dict),
+ extra=config.PKI_INDENTATION_LEVEL_0)
# Combine the various sectional dictionaries into a PKI master dictionary
- pkihelper.create_pki_master_dictionary()
- config.pki_log.debug(log.PKI_DICTIONARY_MASTER)
- config.pki_log.debug(pp.pformat(config.pki_master_dict))
+ parse.compose_pki_master_dictionary()
+ if not config.pki_update_flag:
+ config.pki_master_dict['pki_spawn_log'] = config.pki_log_dir + "/" +\
+ config.pki_log_name
+ else:
+ config.pki_master_dict['pki_respawn_log'] = config.pki_log_dir + "/" +\
+ config.pki_log_name
+ config.pki_log.debug(log.PKI_DICTIONARY_MASTER,
+ extra=config.PKI_INDENTATION_LEVEL_0)
+ config.pki_log.debug(pp.pformat(config.pki_master_dict),
+ extra=config.PKI_INDENTATION_LEVEL_0)
# Install and configure the specified PKI subsystem.
- pki_scriptlets_path = config.pki_root_prefix +\
- config.PKISPAWN_PATH +\
+ pki_scriptlets_path = "/usr/share/pki/deployment/spawn" +\
"/" + config.pki_subsystem.lower()
if not os.path.exists(pki_scriptlets_path) or\
not os.path.isdir(pki_scriptlets_path):
config.pki_log.error(log.PKI_DIRECTORY_MISSING_OR_NOT_A_DIRECTORY_1,
- pki_scriptlets_path)
+ pki_scriptlets_path,
+ extra=config.PKI_INDENTATION_LEVEL_0)
sys.exit(1)
pki_subsystem_scriptlets = os.listdir(pki_scriptlets_path)
pki_subsystem_scriptlets.sort()
# Process the various "scriptlets" for the specified PKI subsystem.
rv = 0
- config.pki_log.info(pki_deployment_begin,
- config.pki_subsystem,
- config.pki_master_dict['pki_instance_name'])
for pki_scriptlet in pki_subsystem_scriptlets:
- scriptlet = __import__(config.PKI_DEPLOYMENT_SCRIPTLETS_MODULE +\
- '.' + pki_scriptlet[5:],
- fromlist = [pki_scriptlet[5:]])
+ scriptlet = __import__("pki.deployment" +\
+ "." + pki_scriptlet[4:],
+ fromlist = [pki_scriptlet[4:]])
instance = scriptlet.PkiScriptlet()
if not config.pki_update_flag:
rv = instance.spawn()
@@ -161,14 +189,12 @@ def main(argv):
rv = instance.respawn()
if rv != 0:
sys.exit(1)
- config.pki_log.info(pki_deployment_end,
- config.pki_subsystem,
- config.pki_master_dict['pki_instance_name'])
- config.pki_log.debug(log.PKI_DICTIONARY_MASTER)
- config.pki_log.debug(pp.pformat(config.pki_master_dict))
+ config.pki_log.debug(log.PKI_DICTIONARY_MASTER,
+ extra=config.PKI_INDENTATION_LEVEL_0)
+ config.pki_log.debug(pp.pformat(config.pki_master_dict),
+ extra=config.PKI_INDENTATION_LEVEL_0)
# PKI Deployment Entry Point
if __name__ == "__main__":
main(sys.argv)
-