To improve reusability the deployment tools have been modified such that the master and slots dictionary objects are created in PKIDeployer at the beginning of the program. The PKIConfigParser has been modified to use the same dictionary objects.
Pushed to master under trivial rule. -- Endi S. Dewata
>From 52cf2bb8c4cc2d60bef779e9874c696296afa30a Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" <edew...@redhat.com> Date: Wed, 21 Dec 2016 04:35:21 +0100 Subject: [PATCH] Refactored master & slots dictionaries creation. To improve reusability the deployment tools have been modified such that the master and slots dictionary objects are created in PKIDeployer at the beginning of the program. The PKIConfigParser has been modified to use the same dictionary objects. --- .../python/pki/server/deployment/pkihelper.py | 27 +++++++++++++++++++--- .../python/pki/server/deployment/pkiparser.py | 9 ++++---- base/server/sbin/pkidestroy | 7 ++++-- base/server/sbin/pkispawn | 7 ++++-- 4 files changed, 39 insertions(+), 11 deletions(-) diff --git a/base/server/python/pki/server/deployment/pkihelper.py b/base/server/python/pki/server/deployment/pkihelper.py index 1a09f4964e98be8010510cefadcd4be8327a1de7..58188657db2546bdca83c766acc16d9f8968603b 100644 --- a/base/server/python/pki/server/deployment/pkihelper.py +++ b/base/server/python/pki/server/deployment/pkihelper.py @@ -4584,12 +4584,33 @@ class SystemCertificateVerifier: class PKIDeployer: """Holds the global dictionaries and the utility objects""" - def __init__(self, pki_mdict, slots_dict=None): + def __init__(self): # Global dictionary variables - self.mdict = pki_mdict - self.slots = slots_dict + self.mdict = {} + self.slots = {} self.manifest_db = [] + self.identity = None + self.namespace = None + self.configuration_file = None + self.instance = None + self.directory = None + self.file = None + self.symlink = None + self.war = None + self.password = None + self.hsm = None + self.certutil = None + self.modutil = None + self.pk12util = None + self.kra_connector = None + self.security_domain = None + self.servercertnick_conf = None + self.systemd = None + self.tps_connector = None + self.config_client = None + + def init(self): # Utility objects self.identity = Identity(self) self.namespace = Namespace(self) diff --git a/base/server/python/pki/server/deployment/pkiparser.py b/base/server/python/pki/server/deployment/pkiparser.py index 6e922cf6cef11aae45881658c1e2a80526bfdbc0..027703bbc4730b5e192b93f73b5c64687e679834 100644 --- a/base/server/python/pki/server/deployment/pkiparser.py +++ b/base/server/python/pki/server/deployment/pkiparser.py @@ -54,7 +54,8 @@ class PKIConfigParser: COMMENT_CHAR = '#' OPTION_CHAR = '=' - def __init__(self, description, epilog): + def __init__(self, description, epilog, deployer=None): + self.deployer = deployer self.pki_config = None # Read and process command-line options @@ -101,8 +102,8 @@ class PKIConfigParser: self.authdb_connection = None # Master and Slot dictionaries - self.mdict = dict() - self.slots_dict = dict() + self.mdict = deployer.mdict + self.slots_dict = deployer.slots # PKI Deployment Helper Functions def process_command_line_arguments(self): @@ -1385,7 +1386,7 @@ class PKIConfigParser: parser.optionxform = str parser.read(config.PKI_DEPLOYMENT_SLOTS_CONFIGURATION_FILE) # Slots configuration file name/value pairs - self.slots_dict = dict(parser.items('Tomcat')) + self.slots_dict.update(dict(parser.items('Tomcat'))) except configparser.ParsingError as err: rv = err return rv diff --git a/base/server/sbin/pkidestroy b/base/server/sbin/pkidestroy index 923b55076b974ffa344f19b2ca8bf8ec4663cfb7..0c62c671c83c8e6c1756345ef61a7069d2f7236a 100755 --- a/base/server/sbin/pkidestroy +++ b/base/server/sbin/pkidestroy @@ -64,6 +64,8 @@ def interrupt_handler(event, frame): def main(argv): """main entry point""" + deployer = util.PKIDeployer() + config.pki_deployment_executable = os.path.basename(argv[0]) # Set the umask @@ -100,7 +102,8 @@ def main(argv): # Read and process command-line arguments. parser = PKIConfigParser( 'PKI Instance Removal', - log.PKIDESTROY_EPILOG) + log.PKIDESTROY_EPILOG, + deployer=deployer) parser.optional.add_argument( '-i', @@ -256,7 +259,7 @@ def main(argv): # Process the various "scriptlets" to remove the specified PKI subsystem. pki_subsystem_scriptlets = parser.mdict['destroy_scriplets'].split() - deployer = util.PKIDeployer(parser.mdict) + deployer.init() try: for scriptlet_name in pki_subsystem_scriptlets: diff --git a/base/server/sbin/pkispawn b/base/server/sbin/pkispawn index c87c49a3d2ebb8901b34cf4ccfcfcc245a32235b..9cddcb2911c46b0f331a0eccabab78420d4ddb10 100755 --- a/base/server/sbin/pkispawn +++ b/base/server/sbin/pkispawn @@ -67,6 +67,8 @@ def interrupt_handler(event, frame): def main(argv): """main entry point""" + deployer = util.PKIDeployer() + config.pki_deployment_executable = os.path.basename(argv[0]) # Set the umask @@ -102,7 +104,8 @@ def main(argv): # Read and process command-line arguments. parser = PKIConfigParser( 'PKI Instance Installation and Configuration', - log.PKISPAWN_EPILOG) + log.PKISPAWN_EPILOG, + deployer=deployer) parser.optional.add_argument( '-f', @@ -514,7 +517,7 @@ def main(argv): # Process the various "scriptlets" to create the specified PKI subsystem. pki_subsystem_scriptlets = parser.mdict['spawn_scriplets'].split() - deployer = util.PKIDeployer(parser.mdict, parser.slots_dict) + deployer.init() try: for scriptlet_name in pki_subsystem_scriptlets: -- 2.5.5
_______________________________________________ Pki-devel mailing list Pki-devel@redhat.com https://www.redhat.com/mailman/listinfo/pki-devel