summaryrefslogtreecommitdiffstats
path: root/base/server/python/pki/server
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2014-10-12 00:16:55 -0400
committerEndi S. Dewata <edewata@redhat.com>2015-01-28 13:40:26 -0500
commit2d574090ba49eec9647b78b44d841a6d6026dccf (patch)
tree2b831ff4ace681b444f9f1b1b83e456130635803 /base/server/python/pki/server
parent8bafe7988740ce078eac8624121459b5357a7501 (diff)
downloadpki-2d574090ba49eec9647b78b44d841a6d6026dccf.tar.gz
pki-2d574090ba49eec9647b78b44d841a6d6026dccf.tar.xz
pki-2d574090ba49eec9647b78b44d841a6d6026dccf.zip
Moved web application deployment locations.
Currently web applications are deployed into Host's appBase (i.e. <instance>/webapps). To allow better control of individual subsystem deployments, the web applications have to be moved out of the appBase so that the autoDeploy can work properly later. This patch moves the common web applications to <instance>/ common/webapps and subsystem web applications to <instance>/ <subsystem>/webapps. An upgrade script has been added to update existing deployments. https://fedorahosted.org/pki/ticket/1183
Diffstat (limited to 'base/server/python/pki/server')
-rw-r--r--base/server/python/pki/server/deployment/pkihelper.py35
-rw-r--r--base/server/python/pki/server/deployment/scriptlets/instance_layout.py34
-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.py51
4 files changed, 89 insertions, 37 deletions
diff --git a/base/server/python/pki/server/deployment/pkihelper.py b/base/server/python/pki/server/deployment/pkihelper.py
index 9d2469dec..02a2c9e32 100644
--- a/base/server/python/pki/server/deployment/pkihelper.py
+++ b/base/server/python/pki/server/deployment/pkihelper.py
@@ -40,6 +40,7 @@ from grp import getgrnam
from pwd import getpwnam
from pwd import getpwuid
import xml.etree.ElementTree as ET
+from lxml import etree
import zipfile
import selinux
if selinux.is_selinux_enabled():
@@ -4173,4 +4174,38 @@ class PKIDeployer:
self.tps_connector = TPSConnector(self)
self.config_client = ConfigClient(self)
+ def deploy_webapp(self, name, doc_base, descriptor):
+ """
+ Deploy a web application into a Tomcat instance.
+
+ This method will copy the specified deployment descriptor into
+ <instance>/conf/Catalina/localhost/<name>.xml and point the docBase
+ to the specified location. The web application will become available
+ under "/<name>" URL path.
+
+ See also: http://tomcat.apache.org/tomcat-7.0-doc/config/context.html
+
+ :param name: Web application name.
+ :type name: str
+ :param doc_base: Path to web application content.
+ :type doc_base: str
+ :param descriptor: Path to deployment descriptor (context.xml).
+ :type descriptor: str
+ """
+ new_descriptor = os.path.join(
+ self.mdict['pki_instance_configuration_path'],
+ "Catalina",
+ "localhost",
+ name + ".xml")
+
+ parser = etree.XMLParser(remove_blank_text=True)
+ document = etree.parse(descriptor, parser)
+
+ context = document.getroot()
+ context.set('docBase', doc_base)
+
+ with open(new_descriptor, 'w') as f:
+ f.write(etree.tostring(document, pretty_print=True))
+ os.chown(new_descriptor, self.mdict['pki_uid'], self.mdict['pki_gid'])
+ os.chmod(new_descriptor, config.PKI_DEPLOYMENT_DEFAULT_FILE_PERMISSIONS)
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 16c3a7f76..7d4ff3054 100644
--- a/base/server/python/pki/server/deployment/scriptlets/instance_layout.py
+++ b/base/server/python/pki/server/deployment/scriptlets/instance_layout.py
@@ -56,6 +56,30 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
deployer.mdict['pki_instance_configuration_path'],
ignore_cb=file_ignore_callback_src_server)
+ # Deploy ROOT web application
+ deployer.deploy_webapp(
+ "ROOT",
+ os.path.join(
+ deployer.mdict['pki_tomcat_common_webapps_path'],
+ "ROOT"),
+ os.path.join(
+ deployer.mdict['pki_source_server_path'],
+ "Catalina",
+ "localhost",
+ "ROOT.xml"))
+
+ # Deploy pki web application
+ deployer.deploy_webapp(
+ "pki",
+ os.path.join(
+ deployer.mdict['pki_tomcat_common_webapps_path'],
+ "pki"),
+ os.path.join(
+ deployer.mdict['pki_source_server_path'],
+ "Catalina",
+ "localhost",
+ "pki.xml"))
+
# establish Tomcat instance base
deployer.directory.create(deployer.mdict['pki_tomcat_common_path'])
deployer.directory.create(
@@ -75,23 +99,23 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
deployer.mdict['pki_instance_lib_log4j_properties'])
deployer.directory.create(deployer.mdict['pki_tomcat_tmpdir_path'])
- # Copy /usr/share/pki/server/webapps to <instance>/webapps
+ # Copy /usr/share/pki/server/webapps to <instance>/common/webapps
deployer.directory.copy(
os.path.join(
config.PKI_DEPLOYMENT_SOURCE_ROOT,
"server",
"webapps"),
- deployer.mdict['pki_tomcat_webapps_path'])
+ deployer.mdict['pki_tomcat_common_webapps_path'])
# If desired and available,
# copy selected server theme
- # to <instance>/webapps/pki
- if config.str2bool(deployer.mdict['pki_theme_enable']) and \
+ # to <instance>/common/webapps/pki
+ if config.str2bool(deployer.mdict['pki_theme_enable']) and\
os.path.exists(deployer.mdict['pki_theme_server_dir']):
deployer.directory.copy(
deployer.mdict['pki_theme_server_dir'],
os.path.join(
- deployer.mdict['pki_tomcat_webapps_path'],
+ deployer.mdict['pki_tomcat_common_webapps_path'],
"pki"),
overwrite_flag=True)
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 324accad0..c3d06c079 100644
--- a/base/server/python/pki/server/deployment/scriptlets/subsystem_layout.py
+++ b/base/server/python/pki/server/deployment/scriptlets/subsystem_layout.py
@@ -103,12 +103,6 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
deployer.file.copy(
deployer.mdict['pki_source_transportcert_profile'],
deployer.mdict['pki_target_transportcert_profile'])
- # establish instance-based Tomcat PKI subsystem registry
- # establish instance-based Tomcat PKI subsystem convenience
- # symbolic links
- deployer.symlink.create(
- deployer.mdict['pki_tomcat_webapps_path'],
- deployer.mdict['pki_subsystem_tomcat_webapps_link'])
# establish instance-based subsystem convenience symbolic links
deployer.symlink.create(
deployer.mdict['pki_instance_database_link'],
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 962de724f..f021a0e9a 100644
--- a/base/server/python/pki/server/deployment/scriptlets/webapp_deployment.py
+++ b/base/server/python/pki/server/deployment/scriptlets/webapp_deployment.py
@@ -44,29 +44,38 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
config.pki_log.info(log.WEBAPP_DEPLOYMENT_SPAWN_1, __name__,
extra=config.PKI_INDENTATION_LEVEL_1)
+ # Create subsystem webapps folder to store custom webapps:
+ # <instance>/<subsystem>/webapps.
+ deployer.directory.create(
+ deployer.mdict['pki_tomcat_subsystem_webapps_path'])
+
+ # set ownerships, permissions, and acls
+ deployer.directory.set_mode(
+ deployer.mdict['pki_tomcat_subsystem_webapps_path'])
+
# For TPS, deploy web application directly from /usr/share/pki.
if deployer.mdict['pki_subsystem'] == "TPS":
- deployer.file.copy(
+ deployer.deploy_webapp(
+ "tps",
os.path.join(
config.PKI_DEPLOYMENT_SOURCE_ROOT,
"tps",
- "conf",
- "Catalina",
- "localhost",
- "tps.xml"),
+ "webapps",
+ "tps"),
os.path.join(
- deployer.mdict['pki_instance_configuration_path'],
+ config.PKI_DEPLOYMENT_SOURCE_ROOT,
+ "tps",
+ "conf",
"Catalina",
"localhost",
"tps.xml"))
+
return self.rv
- # For other subsystems, deploy web application into Tomcat instance.
- deployer.directory.create(
- deployer.mdict['pki_tomcat_webapps_subsystem_path'])
+ # For other subsystems, deploy as custom web application.
# Copy /usr/share/pki/<subsystem>/webapps/<subsystem>
- # to <instance>/webapps/<subsystem>
+ # to <instance>/<subsystem>/webapps/<subsystem>
deployer.directory.copy(
os.path.join(
config.PKI_DEPLOYMENT_SOURCE_ROOT,
@@ -77,7 +86,7 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
overwrite_flag=True)
# Copy /usr/share/pki/server/webapps/pki/admin
- # to <instance>/webapps/<subsystem>/admin
+ # to <instance>/<subsystem>/webapps/<subsystem>/admin
# TODO: common templates should be deployed in common webapp
deployer.directory.copy(
os.path.join(
@@ -131,26 +140,16 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
deployer.mdict['pki_tks_jar'],
deployer.mdict['pki_tks_jar_link'])
- # set ownerships, permissions, and acls
- deployer.directory.set_mode(
- deployer.mdict['pki_tomcat_webapps_subsystem_path'])
-
- # Copy web application context file
- # from /usr/share/pki/<subsystem>/conf/Catalina/localhost/
- # <subsystem>.xml
- # to <instance>/conf/Catalina/localhost/<subsystem>.xml
- deployer.file.copy(
+ # Deploy subsystem web application.
+ deployer.deploy_webapp(
+ deployer.mdict['pki_subsystem'].lower(),
+ deployer.mdict['pki_tomcat_webapps_subsystem_path'],
os.path.join(
config.PKI_DEPLOYMENT_SOURCE_ROOT,
deployer.mdict['pki_subsystem'].lower(),
"conf",
"Catalina",
"localhost",
- deployer.mdict['pki_subsystem'].lower() + ".xml"),
- os.path.join(
- deployer.mdict['pki_instance_configuration_path'],
- "Catalina",
- "localhost",
deployer.mdict['pki_subsystem'].lower() + ".xml"))
return self.rv
@@ -169,7 +168,7 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
deployer.mdict['pki_subsystem'].lower() + ".xml"))
# For subsystems other than TPS, delete
- # <instance>/webapps/<subsystem>.
+ # <instance>/<subsystem>/webapps/<subsystem>.
if deployer.mdict['pki_subsystem'] != "TPS":
deployer.directory.delete(
deployer.mdict['pki_tomcat_webapps_subsystem_path'])