summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2016-04-26 22:32:41 +0200
committerEndi S. Dewata <edewata@redhat.com>2016-04-28 16:30:31 +0200
commit69a52e1179326895632ac0b4639ed8a8523091c9 (patch)
tree2907dafa37ccedb72f8da1f0d37965822ad3f6cb
parent6f9d417ff906360ee2f39a432cd3faccc3f52a2e (diff)
downloadpki-69a52e1179326895632ac0b4639ed8a8523091c9.zip
pki-69a52e1179326895632ac0b4639ed8a8523091c9.tar.gz
pki-69a52e1179326895632ac0b4639ed8a8523091c9.tar.xz
Removed unused variables in deployment scriptlets.
The unused rv instance variables in all deployment scriptlets have been removed. The spawn() and destroy() are now returning None instead of error code. If an error happens during execution the scriptlet will throw an exception which will be caught by pkispawn or pkidestroy and then displayed to the user.
-rw-r--r--base/server/python/pki/server/deployment/scriptlets/configuration.py9
-rw-r--r--base/server/python/pki/server/deployment/scriptlets/finalization.py3
-rw-r--r--base/server/python/pki/server/deployment/scriptlets/infrastructure_layout.py6
-rw-r--r--base/server/python/pki/server/deployment/scriptlets/initialization.py6
-rw-r--r--base/server/python/pki/server/deployment/scriptlets/instance_layout.py6
-rw-r--r--base/server/python/pki/server/deployment/scriptlets/security_databases.py5
-rw-r--r--base/server/python/pki/server/deployment/scriptlets/selinux_setup.py18
-rw-r--r--base/server/python/pki/server/deployment/scriptlets/slot_substitution.py6
-rw-r--r--base/server/python/pki/server/deployment/scriptlets/subsystem_layout.py6
-rw-r--r--base/server/python/pki/server/deployment/scriptlets/webapp_deployment.py7
-rwxr-xr-xbase/server/sbin/pkidestroy43
-rwxr-xr-xbase/server/sbin/pkispawn39
12 files changed, 76 insertions, 78 deletions
diff --git a/base/server/python/pki/server/deployment/scriptlets/configuration.py b/base/server/python/pki/server/deployment/scriptlets/configuration.py
index 5f77ac5..9be9a92 100644
--- a/base/server/python/pki/server/deployment/scriptlets/configuration.py
+++ b/base/server/python/pki/server/deployment/scriptlets/configuration.py
@@ -36,7 +36,6 @@ import pki.util
# PKI Deployment Configuration Scriptlet
class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
- rv = 0
def spawn(self, deployer):
@@ -49,7 +48,8 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
if config.str2bool(deployer.mdict['pki_skip_configuration']):
config.pki_log.info(log.SKIP_CONFIGURATION_SPAWN_1, __name__,
extra=config.PKI_INDENTATION_LEVEL_1)
- return self.rv
+ return
+
config.pki_log.info(log.CONFIGURATION_SPAWN_1, __name__,
extra=config.PKI_INDENTATION_LEVEL_1)
@@ -234,7 +234,7 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
nssdb.close()
if external and step_one:
- return self.rv
+ return
if len(deployer.instance.tomcat_instance_subsystems()) < 2:
@@ -326,8 +326,6 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
deployer.config_client.configure_pki_data(
json.dumps(data, cls=pki.encoder.CustomTypeEncoder))
- return self.rv
-
def destroy(self, deployer):
config.pki_log.info(log.CONFIGURATION_DESTROY_1, __name__,
@@ -336,4 +334,3 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
if deployer.directory.exists(deployer.mdict['pki_client_dir']):
deployer.directory.delete(deployer.mdict['pki_client_dir'])
deployer.symlink.delete(deployer.mdict['pki_systemd_service_link'])
- return self.rv
diff --git a/base/server/python/pki/server/deployment/scriptlets/finalization.py b/base/server/python/pki/server/deployment/scriptlets/finalization.py
index c816acd..8f8cfe0 100644
--- a/base/server/python/pki/server/deployment/scriptlets/finalization.py
+++ b/base/server/python/pki/server/deployment/scriptlets/finalization.py
@@ -29,7 +29,6 @@ from .. import pkiscriptlet
# PKI Deployment Finalization Scriptlet
class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
- rv = 0
def spawn(self, deployer):
@@ -93,7 +92,6 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
deployer.mdict['pki_instance_name'],
extra=config.PKI_INDENTATION_LEVEL_0)
deployer.file.modify(deployer.mdict['pki_spawn_log'], silent=True)
- return self.rv
def destroy(self, deployer):
@@ -112,4 +110,3 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
deployer.mdict['pki_subsystem'],
deployer.mdict['pki_instance_name'],
extra=config.PKI_INDENTATION_LEVEL_0)
- return self.rv
diff --git a/base/server/python/pki/server/deployment/scriptlets/infrastructure_layout.py b/base/server/python/pki/server/deployment/scriptlets/infrastructure_layout.py
index 1334cb0..a04ec15 100644
--- a/base/server/python/pki/server/deployment/scriptlets/infrastructure_layout.py
+++ b/base/server/python/pki/server/deployment/scriptlets/infrastructure_layout.py
@@ -29,14 +29,14 @@ from .. import pkiscriptlet
# PKI Deployment Top-Level Infrastructure Layout Scriptlet
class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
- rv = 0
def spawn(self, deployer):
if config.str2bool(deployer.mdict['pki_skip_installation']):
config.pki_log.info(log.SKIP_ADMIN_DOMAIN_SPAWN_1, __name__,
extra=config.PKI_INDENTATION_LEVEL_1)
- return self.rv
+ return
+
config.pki_log.info(log.ADMIN_DOMAIN_SPAWN_1, __name__,
extra=config.PKI_INDENTATION_LEVEL_1)
# NOTE: It was determined that since the "pkidestroy" command
@@ -100,7 +100,6 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
if deployer.mdict['pki_configuration_path'] != \
config.PKI_DEPLOYMENT_CONFIGURATION_ROOT:
deployer.directory.create(deployer.mdict['pki_configuration_path'])
- return self.rv
def destroy(self, deployer):
@@ -125,4 +124,3 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
deployer.mdict['pki_configuration_path'])
# remove top-level infrastructure registry
deployer.directory.delete(deployer.mdict['pki_registry_path'])
- return self.rv
diff --git a/base/server/python/pki/server/deployment/scriptlets/initialization.py b/base/server/python/pki/server/deployment/scriptlets/initialization.py
index 634136c..0e31543 100644
--- a/base/server/python/pki/server/deployment/scriptlets/initialization.py
+++ b/base/server/python/pki/server/deployment/scriptlets/initialization.py
@@ -28,7 +28,6 @@ from .. import pkiscriptlet
# PKI Deployment Initialization Scriptlet
class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
- rv = 0
def spawn(self, deployer):
@@ -48,7 +47,8 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
if config.str2bool(deployer.mdict['pki_skip_installation']):
config.pki_log.info(log.SKIP_INITIALIZATION_SPAWN_1, __name__,
extra=config.PKI_INDENTATION_LEVEL_1)
- return self.rv
+ return
+
else:
config.pki_log.info(log.INITIALIZATION_SPAWN_1, __name__,
extra=config.PKI_INDENTATION_LEVEL_1)
@@ -76,7 +76,6 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
deployer.configuration_file.verify_selinux_ports()
# If secure DS connection is required, verify parameters
deployer.configuration_file.verify_ds_secure_connection_data()
- return self.rv
def destroy(self, deployer):
@@ -121,4 +120,3 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
deployer.security_domain.deregister(None)
# ALWAYS Stop this Tomcat PKI Process
deployer.systemd.stop()
- return self.rv
diff --git a/base/server/python/pki/server/deployment/scriptlets/instance_layout.py b/base/server/python/pki/server/deployment/scriptlets/instance_layout.py
index eeca2bc..2af86bf 100644
--- a/base/server/python/pki/server/deployment/scriptlets/instance_layout.py
+++ b/base/server/python/pki/server/deployment/scriptlets/instance_layout.py
@@ -30,14 +30,13 @@ from .. import pkiscriptlet
# PKI Deployment Instance Layout Scriptlet
class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
- rv = 0
def spawn(self, deployer):
if config.str2bool(deployer.mdict['pki_skip_installation']):
config.pki_log.info(log.SKIP_INSTANCE_SPAWN_1, __name__,
extra=config.PKI_INDENTATION_LEVEL_1)
- return self.rv
+ return
config.pki_log.info(log.INSTANCE_SPAWN_1, __name__,
extra=config.PKI_INDENTATION_LEVEL_1)
@@ -293,7 +292,6 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
deployer.symlink.create(
deployer.mdict['pki_symkey_jar'],
deployer.mdict['pki_symkey_jar_link'])
- return self.rv
def destroy(self, deployer):
@@ -321,8 +319,6 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
deployer.directory.delete(
deployer.mdict['pki_instance_type_registry_path'])
- return self.rv
-
# Callback only when the /usr/share/pki/server/conf directory
# Is getting copied to the etc tree.
diff --git a/base/server/python/pki/server/deployment/scriptlets/security_databases.py b/base/server/python/pki/server/deployment/scriptlets/security_databases.py
index ed8c0ce..c3ae890 100644
--- a/base/server/python/pki/server/deployment/scriptlets/security_databases.py
+++ b/base/server/python/pki/server/deployment/scriptlets/security_databases.py
@@ -32,14 +32,13 @@ from .. import pkiscriptlet
# PKI Deployment Security Databases Scriptlet
class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
- rv = 0
def spawn(self, deployer):
if config.str2bool(deployer.mdict['pki_skip_installation']):
config.pki_log.info(log.SKIP_SECURITY_DATABASES_SPAWN_1, __name__,
extra=config.PKI_INDENTATION_LEVEL_1)
- return self.rv
+ return
config.pki_log.info(log.SECURITY_DATABASES_SPAWN_1, __name__,
extra=config.PKI_INDENTATION_LEVEL_1)
@@ -158,7 +157,6 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
# Always delete the temporary 'pfile'
deployer.file.delete(deployer.mdict['pki_shared_pfile'])
- return self.rv
def update_external_certs_conf(self, external_path, deployer):
external_certs = pki.server.PKIInstance.read_external_certs(
@@ -182,4 +180,3 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
deployer.file.delete(deployer.mdict['pki_key_database'])
deployer.file.delete(deployer.mdict['pki_secmod_database'])
deployer.file.delete(deployer.mdict['pki_shared_password_conf'])
- return self.rv
diff --git a/base/server/python/pki/server/deployment/scriptlets/selinux_setup.py b/base/server/python/pki/server/deployment/scriptlets/selinux_setup.py
index c559370..9c926d1 100644
--- a/base/server/python/pki/server/deployment/scriptlets/selinux_setup.py
+++ b/base/server/python/pki/server/deployment/scriptlets/selinux_setup.py
@@ -42,7 +42,7 @@ if selinux.is_selinux_enabled():
# PKI Deployment Selinux Setup Scriptlet
class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
- rv = 0
+
suffix = "(/.*)?"
def restore_context(self, mdict):
@@ -56,12 +56,12 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
if config.str2bool(deployer.mdict['pki_skip_installation']):
config.pki_log.info(log.SKIP_SELINUX_SPAWN_1, __name__,
extra=config.PKI_INDENTATION_LEVEL_1)
- return self.rv
+ return
if not selinux.is_selinux_enabled() or seobject is None:
config.pki_log.info(log.SELINUX_DISABLED_SPAWN_1, __name__,
extra=config.PKI_INDENTATION_LEVEL_1)
- return self.rv
+ return
config.pki_log.info(log.SELINUX_SPAWN_1, __name__,
extra=config.PKI_INDENTATION_LEVEL_1)
@@ -74,7 +74,7 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
if len(ports) == 0 and deployer.mdict['pki_instance_name'] == \
config.PKI_DEPLOYMENT_DEFAULT_TOMCAT_INSTANCE_NAME:
self.restore_context(deployer.mdict)
- return self.rv
+ return
# add SELinux contexts when adding the first subsystem
if len(deployer.instance.tomcat_instance_subsystems()) == 1:
@@ -148,21 +148,21 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
else:
raise
- return self.rv
-
def destroy(self, deployer):
if not bool(selinux.is_selinux_enabled()):
config.pki_log.info(log.SELINUX_DISABLED_DESTROY_1, __name__,
extra=config.PKI_INDENTATION_LEVEL_1)
- return self.rv
+ return
+
config.pki_log.info(log.SELINUX_DESTROY_1, __name__,
extra=config.PKI_INDENTATION_LEVEL_1)
# check first if any transactions are required
if (len(ports) == 0 and deployer.mdict['pki_instance_name'] ==
config.PKI_DEPLOYMENT_DEFAULT_TOMCAT_INSTANCE_NAME):
- return self.rv
+ return
+
# A maximum of 10 tries to delete the SELinux contexts
counter = 1
max_tries = 10
@@ -234,5 +234,3 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
"Retrying to remove selinux context ...")
else:
raise
-
- return self.rv
diff --git a/base/server/python/pki/server/deployment/scriptlets/slot_substitution.py b/base/server/python/pki/server/deployment/scriptlets/slot_substitution.py
index bdee48c..5a56f6c 100644
--- a/base/server/python/pki/server/deployment/scriptlets/slot_substitution.py
+++ b/base/server/python/pki/server/deployment/scriptlets/slot_substitution.py
@@ -28,14 +28,14 @@ from .. import pkiscriptlet
# PKI Deployment Slot Substitution Scriptlet
class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
- rv = 0
def spawn(self, deployer):
if config.str2bool(deployer.mdict['pki_skip_installation']):
config.pki_log.info(log.SKIP_SLOT_ASSIGNMENT_SPAWN_1, __name__,
extra=config.PKI_INDENTATION_LEVEL_1)
- return self.rv
+ return
+
config.pki_log.info(log.SLOT_ASSIGNMENT_SPAWN_1, __name__,
extra=config.PKI_INDENTATION_LEVEL_1)
deployer.file.copy_with_slot_substitution(
@@ -84,11 +84,9 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
deployer.file.copy_with_slot_substitution(
deployer.mdict['pki_source_phone_home_xml'],
deployer.mdict['pki_target_phone_home_xml'])
- return self.rv
def destroy(self, deployer):
config.pki_log.info(log.SLOT_ASSIGNMENT_DESTROY_1, __name__,
extra=config.PKI_INDENTATION_LEVEL_1)
config.pki_log.info("NOTHING NEEDS TO BE IMPLEMENTED",
extra=config.PKI_INDENTATION_LEVEL_2)
- return self.rv
diff --git a/base/server/python/pki/server/deployment/scriptlets/subsystem_layout.py b/base/server/python/pki/server/deployment/scriptlets/subsystem_layout.py
index 49899da..2b2246a 100644
--- a/base/server/python/pki/server/deployment/scriptlets/subsystem_layout.py
+++ b/base/server/python/pki/server/deployment/scriptlets/subsystem_layout.py
@@ -28,14 +28,14 @@ from .. import pkiscriptlet
# PKI Deployment Subsystem Layout Scriptlet
class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
- rv = 0
def spawn(self, deployer):
if config.str2bool(deployer.mdict['pki_skip_installation']):
config.pki_log.info(log.SKIP_SUBSYSTEM_SPAWN_1, __name__,
extra=config.PKI_INDENTATION_LEVEL_1)
- return self.rv
+ return
+
config.pki_log.info(log.SUBSYSTEM_SPAWN_1, __name__,
extra=config.PKI_INDENTATION_LEVEL_1)
# establish instance-based subsystem logs
@@ -118,7 +118,6 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
deployer.symlink.create(
deployer.mdict['pki_instance_registry_path'],
deployer.mdict['pki_subsystem_registry_link'])
- return self.rv
def destroy(self, deployer):
@@ -146,4 +145,3 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
# remove instance-based subsystem registry
deployer.directory.delete(
deployer.mdict['pki_subsystem_registry_path'])
- return self.rv
diff --git a/base/server/python/pki/server/deployment/scriptlets/webapp_deployment.py b/base/server/python/pki/server/deployment/scriptlets/webapp_deployment.py
index f9d0ae9..bfa3c32 100644
--- a/base/server/python/pki/server/deployment/scriptlets/webapp_deployment.py
+++ b/base/server/python/pki/server/deployment/scriptlets/webapp_deployment.py
@@ -30,14 +30,13 @@ from .. import pkiscriptlet
# PKI Web Application Deployment Scriptlet
class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
- rv = 0
def spawn(self, deployer):
if config.str2bool(deployer.mdict['pki_skip_installation']):
config.pki_log.info(log.SKIP_WEBAPP_DEPLOYMENT_SPAWN_1,
__name__,
extra=config.PKI_INDENTATION_LEVEL_1)
- return self.rv
+ return
config.pki_log.info(log.WEBAPP_DEPLOYMENT_SPAWN_1, __name__,
extra=config.PKI_INDENTATION_LEVEL_1)
@@ -67,8 +66,6 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
"localhost",
deployer.mdict['pki_subsystem'].lower() + ".xml"))
- return self.rv
-
def destroy(self, deployer):
config.pki_log.info(log.WEBAPP_DEPLOYMENT_DESTROY_1, __name__,
extra=config.PKI_INDENTATION_LEVEL_1)
@@ -80,5 +77,3 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
"Catalina",
"localhost",
deployer.mdict['pki_subsystem'].lower() + ".xml"))
-
- return self.rv
diff --git a/base/server/sbin/pkidestroy b/base/server/sbin/pkidestroy
index d7285c7..404298b 100755
--- a/base/server/sbin/pkidestroy
+++ b/base/server/sbin/pkidestroy
@@ -35,6 +35,7 @@ try:
import struct
import subprocess
import time
+ import traceback
from time import strftime as date
from pki.server.deployment import pkiconfig as config
from pki.server.deployment.pkiparser import PKIConfigParser
@@ -256,15 +257,26 @@ 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)
- rv = 0
- for scriptlet_name in pki_subsystem_scriptlets:
- scriptlet_module = __import__(
- "pki.server.deployment.scriptlets." + scriptlet_name,
- fromlist=[scriptlet_name])
- scriptlet = scriptlet_module.PkiScriptlet()
- rv = scriptlet.destroy(deployer)
- if rv != 0:
- sys.exit(1)
+
+ try:
+ for scriptlet_name in pki_subsystem_scriptlets:
+
+ scriptlet_module = __import__(
+ "pki.server.deployment.scriptlets." + scriptlet_name,
+ fromlist=[scriptlet_name])
+
+ scriptlet = scriptlet_module.PkiScriptlet()
+
+ scriptlet.destroy(deployer)
+
+ # pylint: disable=W0703
+ except Exception as e:
+ log_error_details()
+ print()
+ print("Uninstallation failed: %s" % e)
+ print()
+ sys.exit(1)
+
config.pki_log.debug(log.PKI_DICTIONARY_MASTER,
extra=config.PKI_INDENTATION_LEVEL_0)
config.pki_log.debug(pkilogging.log_format(parser.mdict),
@@ -274,6 +286,19 @@ def main(argv):
print("Uninstallation complete.")
+def log_error_details():
+ e_type, e_value, e_stacktrace = sys.exc_info()
+ config.pki_log.debug(
+ "Error Type: " + e_type.__name__, extra=config.PKI_INDENTATION_LEVEL_2)
+ config.pki_log.debug(
+ "Error Message: " + str(e_value), extra=config.PKI_INDENTATION_LEVEL_2)
+ stacktrace_list = traceback.format_list(traceback.extract_tb(e_stacktrace))
+ e_stacktrace = ""
+ for l in stacktrace_list:
+ e_stacktrace += l
+ config.pki_log.debug(e_stacktrace, extra=config.PKI_INDENTATION_LEVEL_2)
+ del e_type, e_value, e_stacktrace
+
# PKI Deployment Entry Point
if __name__ == "__main__":
signal.signal(signal.SIGINT, interrupt_handler)
diff --git a/base/server/sbin/pkispawn b/base/server/sbin/pkispawn
index caa5e9b..21333e7 100755
--- a/base/server/sbin/pkispawn
+++ b/base/server/sbin/pkispawn
@@ -514,25 +514,26 @@ 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)
- rv = 0
- for scriptlet_name in pki_subsystem_scriptlets:
- scriptlet_module = __import__(
- "pki.server.deployment.scriptlets." + scriptlet_name,
- fromlist=[scriptlet_name])
- scriptlet = scriptlet_module.PkiScriptlet()
- try:
- rv = scriptlet.spawn(deployer)
- # pylint: disable=W0703
- except Exception:
- log_error_details()
- print()
- print("Installation failed.")
- print()
- sys.exit(1)
- if rv != 0:
- print("Nothing here!!!")
- print("Installation failed.")
- sys.exit(1)
+
+ try:
+ for scriptlet_name in pki_subsystem_scriptlets:
+
+ scriptlet_module = __import__(
+ "pki.server.deployment.scriptlets." + scriptlet_name,
+ fromlist=[scriptlet_name])
+
+ scriptlet = scriptlet_module.PkiScriptlet()
+
+ scriptlet.spawn(deployer)
+
+ # pylint: disable=W0703
+ except Exception as e:
+ log_error_details()
+ print()
+ print("Installation failed: %s" % e)
+ print()
+ sys.exit(1)
+
config.pki_log.debug(log.PKI_DICTIONARY_MASTER,
extra=config.PKI_INDENTATION_LEVEL_0)
config.pki_log.debug(pkilogging.log_format(parser.mdict),