From 52d2c8bbcf79731570274304bffdb1e1431e5042 Mon Sep 17 00:00:00 2001 From: Endi Sukma Dewata Date: Thu, 15 Nov 2012 02:40:07 -0500 Subject: Copied str2bool(). --- base/deploy/src/scriptlets/pkihelper.py | 37 ++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/base/deploy/src/scriptlets/pkihelper.py b/base/deploy/src/scriptlets/pkihelper.py index 6cf395e77..5b71ad6b9 100644 --- a/base/deploy/src/scriptlets/pkihelper.py +++ b/base/deploy/src/scriptlets/pkihelper.py @@ -53,6 +53,9 @@ from pkiparser import PKIConfigParser # PKI Deployment Helper Functions +def str2bool(string): + return string.lower() in ("yes", "true", "t", "1") + def pki_copytree(src, dst, symlinks=False, ignore=None): """Recursively copy a directory tree using copy2(). @@ -450,7 +453,7 @@ class configuration_file: extra=PKIConfig.PKI_INDENTATION_LEVEL_2) sys.exit(1) # Verify existence of Admin Password (except for Clones) - if not config.str2bool(master['pki_clone']): + if not str2bool(master['pki_clone']): if not sensitive.has_key('pki_admin_password') or\ not len(sensitive['pki_admin_password']): pkilogging.pki_log.error( @@ -460,7 +463,7 @@ class configuration_file: extra=PKIConfig.PKI_INDENTATION_LEVEL_2) sys.exit(1) # If required, verify existence of Backup Password - if config.str2bool(master['pki_backup_keys']): + if str2bool(master['pki_backup_keys']): if not sensitive.has_key('pki_backup_password') or\ not len(sensitive['pki_backup_password']): pkilogging.pki_log.error( @@ -488,7 +491,7 @@ class configuration_file: extra=PKIConfig.PKI_INDENTATION_LEVEL_2) sys.exit(1) # Verify existence of PKCS #12 Password (ONLY for Clones) - if config.str2bool(master['pki_clone']): + if str2bool(master['pki_clone']): if not sensitive.has_key('pki_clone_pkcs12_password') or\ not len(sensitive['pki_clone_pkcs12_password']): pkilogging.pki_log.error( @@ -499,9 +502,9 @@ class configuration_file: sys.exit(1) # Verify existence of Security Domain Password File # (ONLY for Clones, KRA, OCSP, TKS, or Subordinate CA) - if config.str2bool(master['pki_clone']) or\ + if str2bool(master['pki_clone']) or\ not master['pki_subsystem'] == "CA" or\ - config.str2bool(master['pki_subordinate']): + str2bool(master['pki_subordinate']): if not sensitive.has_key('pki_security_domain_password') or\ not len(sensitive['pki_security_domain_password']): pkilogging.pki_log.error( @@ -526,30 +529,30 @@ class configuration_file: # Silently verify the existence of 'mutually exclusive' data if master['pki_subsystem'] in PKIConfig.PKI_TOMCAT_SUBSYSTEMS: if master['pki_subsystem'] == "CA": - if config.str2bool(master['pki_clone']) and\ - config.str2bool(master['pki_external']) and\ - config.str2bool(master['pki_subordinate']): + if str2bool(master['pki_clone']) and\ + str2bool(master['pki_external']) and\ + str2bool(master['pki_subordinate']): pkilogging.pki_log.error( log.PKIHELPER_MUTUALLY_EXCLUSIVE_CLONE_EXTERNAL_SUB_CA, master['pki_deployment_cfg'], extra=PKIConfig.PKI_INDENTATION_LEVEL_2) sys.exit(1) - elif config.str2bool(master['pki_clone']) and\ - config.str2bool(master['pki_external']): + elif str2bool(master['pki_clone']) and\ + str2bool(master['pki_external']): pkilogging.pki_log.error( log.PKIHELPER_MUTUALLY_EXCLUSIVE_CLONE_EXTERNAL_CA, master['pki_deployment_cfg'], extra=PKIConfig.PKI_INDENTATION_LEVEL_2) sys.exit(1) - elif config.str2bool(master['pki_clone']) and\ - config.str2bool(master['pki_subordinate']): + elif str2bool(master['pki_clone']) and\ + str2bool(master['pki_subordinate']): pkilogging.pki_log.error( log.PKIHELPER_MUTUALLY_EXCLUSIVE_CLONE_SUB_CA, master['pki_deployment_cfg'], extra=PKIConfig.PKI_INDENTATION_LEVEL_2) sys.exit(1) - elif config.str2bool(master['pki_external']) and\ - config.str2bool(master['pki_subordinate']): + elif str2bool(master['pki_external']) and\ + str2bool(master['pki_subordinate']): pkilogging.pki_log.error( log.PKIHELPER_MUTUALLY_EXCLUSIVE_EXTERNAL_SUB_CA, master['pki_deployment_cfg'], @@ -568,7 +571,7 @@ class configuration_file: # 'True' or 'False', etc.) of ALL required "value" parameters. # if master['pki_subsystem'] in PKIConfig.PKI_TOMCAT_SUBSYSTEMS: - if config.str2bool(master['pki_clone']): + if str2bool(master['pki_clone']): # Verify existence of clone parameters if not master.has_key('pki_ds_base_dn') or\ not len(master['pki_ds_base_dn']): @@ -680,7 +683,7 @@ class configuration_file: extra=PKIConfig.PKI_INDENTATION_LEVEL_2) sys.exit(1) elif master['pki_subsystem'] == "CA" and\ - config.str2bool(master['pki_external']): + str2bool(master['pki_external']): if not master.has_key('pki_external_step_two') or\ not len(master['pki_external_step_two']): pkilogging.pki_log.error( @@ -689,7 +692,7 @@ class configuration_file: master['pki_deployment_cfg'], extra=PKIConfig.PKI_INDENTATION_LEVEL_2) sys.exit(1) - if not config.str2bool(master['pki_step_two']): + if not str2bool(master['pki_step_two']): if not master.has_key('pki_external_csr_path') or\ not len(master['pki_external_csr_path']): pkilogging.pki_log.error( -- cgit