diff options
Diffstat (limited to 'base/deploy')
-rwxr-xr-x | base/deploy/src/pkidestroy | 9 | ||||
-rwxr-xr-x | base/deploy/src/pkispawn | 9 | ||||
-rw-r--r-- | base/deploy/src/scriptlets/pkihelper.py | 6 | ||||
-rw-r--r-- | base/deploy/src/scriptlets/pkiparser.py | 25 |
4 files changed, 27 insertions, 22 deletions
diff --git a/base/deploy/src/pkidestroy b/base/deploy/src/pkidestroy index 82632fc1a..1597712e1 100755 --- a/base/deploy/src/pkidestroy +++ b/base/deploy/src/pkidestroy @@ -36,7 +36,7 @@ try: import time from time import strftime as date from pki.deployment import pkiconfig as config - from pki.deployment import pkiparser as parse + from pki.deployment.pkiparser import PKIConfigParser from pki.deployment import pkilogging from pki.deployment import pkimessages as log except ImportError: @@ -92,7 +92,8 @@ def main(argv): pp = pprint.PrettyPrinter(indent=4) # Read and process command-line arguments. - parse.process_command_line_arguments(argv) + parser = PKIConfigParser() + parser.process_command_line_arguments(argv) # Enable 'pkidestroy' logging. config.pki_log_dir = config.pki_root_prefix +\ @@ -113,7 +114,7 @@ def main(argv): sys.exit(1) # Read the specified PKI configuration file. - rv = parse.read_pki_configuration_file() + rv = parser.read_pki_configuration_file() if rv != 0: config.pki_log.error(PKI_UNABLE_TO_PARSE_1, rv, extra=config.PKI_INDENTATION_LEVEL_0) @@ -148,7 +149,7 @@ def main(argv): extra=config.PKI_INDENTATION_LEVEL_0) # Combine the various sectional dictionaries into a PKI master dictionary - parse.compose_pki_master_dictionary() + parser.compose_pki_master_dictionary() config.pki_master_dict['pki_destroy_log'] = config.pki_log_dir + "/" +\ config.pki_log_name config.pki_log.debug(log.PKI_DICTIONARY_MASTER, diff --git a/base/deploy/src/pkispawn b/base/deploy/src/pkispawn index 4ea678ef6..3afb8a3c8 100755 --- a/base/deploy/src/pkispawn +++ b/base/deploy/src/pkispawn @@ -36,7 +36,7 @@ try: import time from time import strftime as date from pki.deployment import pkiconfig as config - from pki.deployment import pkiparser as parse + from pki.deployment.pkiparser import PKIConfigParser from pki.deployment import pkilogging from pki.deployment import pkimessages as log except ImportError: @@ -92,7 +92,8 @@ def main(argv): pp = pprint.PrettyPrinter(indent=4) # Read and process command-line arguments. - parse.process_command_line_arguments(argv) + parser = PKIConfigParser() + parser.process_command_line_arguments(argv) if not os.path.exists(config.PKI_DEPLOYMENT_SOURCE_ROOT +\ "/" + config.pki_subsystem.lower()): @@ -133,7 +134,7 @@ def main(argv): sys.exit(1) # Read the specified PKI configuration file. - rv = parse.read_pki_configuration_file() + rv = parser.read_pki_configuration_file() if rv != 0: config.pki_log.error(PKI_UNABLE_TO_PARSE_1, rv, extra=config.PKI_INDENTATION_LEVEL_0) @@ -168,7 +169,7 @@ def main(argv): extra=config.PKI_INDENTATION_LEVEL_0) # Read in the PKI slots configuration file. - parse.compose_pki_slots_dictionary() + parser.compose_pki_slots_dictionary() config.pki_log.debug(log.PKI_DICTIONARY_SLOTS, extra=config.PKI_INDENTATION_LEVEL_0) config.pki_log.debug(pp.pformat(config.pki_slots_dict), diff --git a/base/deploy/src/scriptlets/pkihelper.py b/base/deploy/src/scriptlets/pkihelper.py index b95269431..904e08614 100644 --- a/base/deploy/src/scriptlets/pkihelper.py +++ b/base/deploy/src/scriptlets/pkihelper.py @@ -47,7 +47,7 @@ from pkiconfig import pki_slots_dict as slots from pkiconfig import pki_selinux_config_ports as ports import pkimanifest as manifest import pkimessages as log -from pkiparser import read_simple_configuration_file +from pkiparser import PKIConfigParser # PKI Deployment Helper Functions @@ -2253,7 +2253,7 @@ class security_domain: def deregister(self, critical_failure=False): try: # process this PKI subsystem instance's 'CS.cfg' - cs_cfg = read_simple_configuration_file(master['pki_target_cs_cfg']) + cs_cfg = PKIConfigParser.read_simple_configuration_file(master['pki_target_cs_cfg']) # assign key name/value pairs machinename = cs_cfg.get('service.machineName') @@ -2331,7 +2331,7 @@ class security_domain: if os.path.exists(master['pki_shared_password_conf']) and\ os.path.isfile(master['pki_shared_password_conf']) and\ os.access(master['pki_shared_password_conf'], os.R_OK): - tokens = read_simple_configuration_file( + tokens = PKIConfigParser.read_simple_configuration_file( master['pki_shared_password_conf']) hardware_token = "hardware-" + token_name if tokens.has_key(hardware_token): diff --git a/base/deploy/src/scriptlets/pkiparser.py b/base/deploy/src/scriptlets/pkiparser.py index c70ed84b2..49b4f94bb 100644 --- a/base/deploy/src/scriptlets/pkiparser.py +++ b/base/deploy/src/scriptlets/pkiparser.py @@ -35,8 +35,13 @@ import pkiconfig as config import pkimessages as log +class PKIConfigParser: + + COMMENT_CHAR = '#' + OPTION_CHAR = '=' + # PKI Deployment Helper Functions - def process_command_line_arguments(argv): + def process_command_line_arguments(self, argv): "Read and process command-line options" config.pki_deployment_executable = os.path.basename(argv[0]) description = None @@ -184,21 +189,19 @@ import pkimessages as log # The following code is based heavily upon # "http://www.decalage.info/en/python/configparser" - COMMENT_CHAR = '#' - OPTION_CHAR = '=' - + @staticmethod def read_simple_configuration_file(filename): values = {} f = open(filename) for line in f: # First, remove comments: - if COMMENT_CHAR in line: + if PKIConfigParser.COMMENT_CHAR in line: # split on comment char, keep only the part before - line, comment = line.split(COMMENT_CHAR, 1) + line, comment = line.split(PKIConfigParser.COMMENT_CHAR, 1) # Second, find lines with an name=value: - if OPTION_CHAR in line: + if PKIConfigParser.OPTION_CHAR in line: # split on name char: - name, value = line.split(OPTION_CHAR, 1) + name, value = line.split(PKIConfigParser.OPTION_CHAR, 1) # strip spaces: name = name.strip() value = value.strip() @@ -208,7 +211,7 @@ import pkimessages as log return values - def read_pki_configuration_file(): + def read_pki_configuration_file(self): "Read configuration file sections into dictionaries" rv = 0 try: @@ -246,7 +249,7 @@ import pkimessages as log return rv - def compose_pki_master_dictionary(): + def compose_pki_master_dictionary(self): "Create a single master PKI dictionary from the sectional dictionaries" try: config.pki_master_dict = dict() @@ -2343,7 +2346,7 @@ import pkimessages as log return - def compose_pki_slots_dictionary(): + def compose_pki_slots_dictionary(self): """Read the slots configuration file to create the appropriate PKI slots dictionary""" rv = 0 |