Skip to content

Commit

Permalink
Refactor pkidestroy scriptlets
Browse files Browse the repository at this point in the history
The loop that calls pkidestroy scriptlets has been unrolled and
moved into PKIDeployer.destroy() to allow further refactoring.
  • Loading branch information
edewata committed Nov 2, 2023
1 parent 80ade82 commit 781d1c8
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 29 deletions.
13 changes: 0 additions & 13 deletions base/server/etc/default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,6 @@ sensitive_parameters=
pki_server_pkcs12_password
pki_token_password

# The destroy_scriplets contains a list of scriplets to be executed by pkidestroy.
destroy_scriplets=
initialization
configuration
keygen
subsystem_layout
security_databases
instance_layout
selinux_setup
infrastructure_layout
finalization
fapolicy_setup

pki_instance_name=pki-tomcat
pki_http_port=8080
pki_https_port=8443
Expand Down
54 changes: 54 additions & 0 deletions base/server/python/pki/server/deployment/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4828,3 +4828,57 @@ def spawn(self):
scriptlet.deployer = self
scriptlet.instance = self.instance
scriptlet.spawn(self)

def destroy(self):

print('Uninstalling ' + self.subsystem_name + ' from ' + self.instance.base_dir + '.')

scriptlet = pki.server.deployment.scriptlets.initialization.PkiScriptlet()
scriptlet.deployer = self
scriptlet.instance = self.instance
scriptlet.destroy(self)

scriptlet = pki.server.deployment.scriptlets.configuration.PkiScriptlet()
scriptlet.deployer = self
scriptlet.instance = self.instance
scriptlet.destroy(self)

scriptlet = pki.server.deployment.scriptlets.keygen.PkiScriptlet()
scriptlet.deployer = self
scriptlet.instance = self.instance
scriptlet.destroy(self)

scriptlet = pki.server.deployment.scriptlets.subsystem_layout.PkiScriptlet()
scriptlet.deployer = self
scriptlet.instance = self.instance
scriptlet.destroy(self)

scriptlet = pki.server.deployment.scriptlets.security_databases.PkiScriptlet()
scriptlet.deployer = self
scriptlet.instance = self.instance
scriptlet.destroy(self)

scriptlet = pki.server.deployment.scriptlets.instance_layout.PkiScriptlet()
scriptlet.deployer = self
scriptlet.instance = self.instance
scriptlet.destroy(self)

scriptlet = pki.server.deployment.scriptlets.selinux_setup.PkiScriptlet()
scriptlet.deployer = self
scriptlet.instance = self.instance
scriptlet.destroy(self)

scriptlet = pki.server.deployment.scriptlets.infrastructure_layout.PkiScriptlet()
scriptlet.deployer = self
scriptlet.instance = self.instance
scriptlet.destroy(self)

scriptlet = pki.server.deployment.scriptlets.finalization.PkiScriptlet()
scriptlet.deployer = self
scriptlet.instance = self.instance
scriptlet.destroy(self)

scriptlet = pki.server.deployment.scriptlets.fapolicy_setup.PkiScriptlet()
scriptlet.deployer = self
scriptlet.instance = self.instance
scriptlet.destroy(self)
17 changes: 1 addition & 16 deletions base/server/python/pki/server/pkidestroy.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,23 +227,8 @@ def main(argv):
logger.debug(log.PKI_DICTIONARY_MASTER)
logger.debug(pkilogging.log_format(parser.mdict))

print("Uninstalling " + deployer.subsystem_name + " from " +
deployer.instance.base_dir + ".")

# Process the various "scriptlets" to remove the specified PKI subsystem.
pki_subsystem_scriptlets = parser.mdict['destroy_scriplets'].split()

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.deployer = deployer
scriptlet.instance = deployer.instance
scriptlet.destroy(deployer)
deployer.destroy()

except subprocess.CalledProcessError as e:
log_error_details()
Expand Down

0 comments on commit 781d1c8

Please sign in to comment.