<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<!DOCTYPE stax SYSTEM "../stax.dtd">
|
<!--
|
! CDDL HEADER START
|
!
|
! The contents of this file are subject to the terms of the
|
! Common Development and Distribution License, Version 1.0 only
|
! (the "License"). You may not use this file except in compliance
|
! with the License.
|
!
|
! You can obtain a copy of the license at
|
! trunk/opends/resource/legal-notices/OpenDS.LICENSE
|
! or https://OpenDS.dev.java.net/OpenDS.LICENSE.
|
! See the License for the specific language governing permissions
|
! and limitations under the License.
|
!
|
! When distributing Covered Code, include this CDDL HEADER in each
|
! file and include the License file at
|
! trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
|
! add the following below this CDDL HEADER, with the fields enclosed
|
! by brackets "[]" replaced with your own identifying information:
|
! Portions Copyright [yyyy] [name of copyright owner]
|
!
|
! CDDL HEADER END
|
!
|
! Portions Copyright 2008 Sun Microsystems, Inc.
|
! -->
|
<stax>
|
|
<function name="createWebcontainer" scope="local">
|
<function-prolog>
|
This function creates a default webcontainer instance
|
</function-prolog>
|
|
<function-map-args>
|
<function-arg-def name="location" type="optional" default="STAF_REMOTE_HOSTNAME">
|
<function-arg-description>
|
Location of target host
|
</function-arg-description>
|
<function-arg-property name="type" value="hostname"/>
|
</function-arg-def>
|
<function-arg-def name="wcPath" type="optional" default="'%s' % WC_DIRECTORY">
|
<function-arg-description>
|
Pathname to installation root
|
</function-arg-description>
|
<function-arg-property name="type" value="filepath"/>
|
</function-arg-def>
|
</function-map-args>
|
|
<try>
|
|
<sequence>
|
|
<script>
|
mylocation=location
|
</script>
|
|
<!-- Copy webcontainer zip archive to remote host -->
|
<message>
|
'Copy webcontainer %s to host %s' % (WC_ZIPNAME,location)
|
</message>
|
<call function="'copyFile'">
|
{ 'location' : STAXServiceMachine,
|
'srcfile' : '%s/%s' % (WC_ZIPPATH,WC_ZIPNAME),
|
'destfile' : '%s/%s' % (wcPath,WC_ZIPNAME),
|
'remotehost' : mylocation
|
}
|
</call>
|
|
<!-- Unzip webcontainer into temporary folder -->
|
<message>
|
'Extract temporary webcontainer zip archive to %s %s.' % (location, wcPath)
|
</message>
|
<call function="'unZipFile'">
|
{ 'location' : mylocation,
|
'zipfile' : '%s/%s' % (wcPath,WC_ZIPNAME),
|
'unzipdir' : '%s' % wcPath }
|
</call>
|
|
<!-- chmod +x all the .sh file in tomcat bin directory -->
|
<stafcmd name="'make tomcat shell scripts executable'">
|
<location>'%s' % mylocation</location>
|
<service>'fs'</service>
|
<request>' LIST DIRECTORY %s/%s-%s/bin EXT sh' % \
|
(wcPath, WC_TYPE, WC_VERSION)</request>
|
</stafcmd>
|
<script>
|
shFilesRC=RC
|
shFilesResult=" ".join(STAFResult)
|
</script>
|
<message>'shFilesResult=%s' % shFilesResult</message>
|
<process name="'chmod +x tomcat\'s shell scripts'">
|
<location>'%s' % mylocation</location>
|
<command mode="'shell'">'chmod +x %s' % shFilesResult</command>
|
<parms/>
|
<workdir>'%s/%s-%s/bin' % (wcPath, WC_TYPE, WC_VERSION)</workdir>
|
<envs>['PATH=/bin:/usr/bin']</envs>
|
<stderr mode="'stdout'"/>
|
<stdout/>
|
<returnstdout/>
|
</process>
|
|
<!-- generate SSL certificate -->
|
<stafcmd>
|
<location>STAXServiceMachine</location>
|
<service>'var'</service>
|
<request>'resolve string {STAF/Config/STAFRoot}'</request>
|
</stafcmd>
|
|
<script>stafRoot=STAFResult</script>
|
|
<call function="'runCommand'">
|
{ 'name' : 'Generate a Certificate',
|
'location' : STAXServiceMachine,
|
'command' : '%s/bin/keytool' % (JAVA_HOME),
|
'arguments' : '-genkey -alias tomcat -keyalg rsa \
|
-dname "cn=tomcat,O=Sun Microsystems,C=US" \
|
-keystore "%s/services/DSML/tomcatCertificate" \
|
-storepass "changeit" -keypass "changeit" \
|
-storetype JKS ' % (stafRoot),
|
'path' : '%s/bin' % (JAVA_HOME),
|
'expectedRC': 0
|
}
|
</call>
|
|
<call function="'copyFile'">
|
{ 'location' : STAXServiceMachine,
|
'srcfile' : '%s/services/DSML/tomcatCertificate' % (stafRoot),
|
'destfile' : '%s/%s-%s/conf/tomcatCertificate' % (wcPath, WC_TYPE, WC_VERSION),
|
'remotehost' : mylocation
|
}
|
</call>
|
<!-- configure webcontainer's PORTs -->
|
<message>
|
'Configure webcontainer ports HTTP %s / HTTPS %s' % (WC_PORT, WC_SSL_PORT)
|
</message>
|
<stafcmd name="'get tomcat configuration file'">
|
<location>'%s' % mylocation</location>
|
<service>'fs'</service>
|
<request>' GET FILE %s/%s-%s/conf/server.xml ' % \
|
(wcPath, WC_TYPE, WC_VERSION)</request>
|
</stafcmd>
|
<script>
|
serverXmlInput=STAFResult
|
import re
|
portRegEx = re.compile('8080')
|
sslPortRegEx = re.compile('8443')
|
content=portRegEx.sub(WC_PORT, serverXmlInput)
|
content=sslPortRegEx.sub(WC_SSL_PORT, content)
|
sslConnectorRegEx = re.compile('<Service name="Catalina">')
|
SSL_CONNECTOR = '<Service name="Catalina">\n \
|
<Connector port="%s" protocole="HTTP/1.1" \
|
SSLEnabled="true" maxThreads="150" scheme="https" secure="true" \
|
clientAuth="false" sslProtocol="SSL" \
|
keystoreFile="%s/%s-%s/conf/tomcatCertificate" \
|
keystorePass="changeit" />' % \
|
(WC_SSL_PORT, wcPath, WC_TYPE, WC_VERSION)
|
content=sslConnectorRegEx.sub(SSL_CONNECTOR, content)
|
serverXmlOutput=open('%s/%s-%s-%s_server.xml' % \
|
(TMPDIR,STAF_REMOTE_HOSTNAME,WC_TYPE,WC_VERSION),'w')
|
serverXmlOutput.write(content)
|
serverXmlOutput.close()
|
</script>
|
<call function="'copyFile'">
|
{'srcfile' : '%s/%s-%s-%s_server.xml' % (TMPDIR, STAF_REMOTE_HOSTNAME, WC_TYPE, WC_VERSION),
|
'destfile' : '%s/%s-%s/conf/server.xml' % (wcPath, WC_TYPE, WC_VERSION),
|
'remotehost' : '%s' % STAF_REMOTE_HOSTNAME
|
}
|
</call>
|
|
<!-- configure webcontainer's SSL environement -->
|
<message>
|
'Configure webcontainer SSL keystore '
|
</message>
|
|
<if expr="RC != 0">
|
<return>RC</return>
|
</if>
|
|
</sequence>
|
|
<catch exception="'TestExceptionResultFailed'" typevar="eType" var="eInfo">
|
<sequence>
|
<message>'caught %s with %s' % (eType,eInfo)</message>
|
<message>
|
'Remove temporary webcontainer zip archive from %s %s' % (location,wcPath)
|
</message>
|
<call function="'deleteFolder'">
|
{ 'location' : location ,
|
'foldername' : '%s' % wcPath }
|
</call>
|
</sequence>
|
</catch>
|
|
</try>
|
|
</function>
|
|
<function name="deployWebApplicationWAR" scope="local">
|
<function-prolog>
|
This function deploys a Web Application War file
|
</function-prolog>
|
|
<function-map-args>
|
<function-arg-def name="location" type="optional" default="STAF_REMOTE_HOSTNAME">
|
<function-arg-description>
|
Location of target host
|
</function-arg-description>
|
<function-arg-property name="type" value="hostname"/>
|
</function-arg-def>
|
<function-arg-def name="wcPath" type="optional" default="'%s' % WC_DIRECTORY">
|
<function-arg-description>
|
Pathname to installation root
|
</function-arg-description>
|
<function-arg-property name="type" value="filepath"/>
|
</function-arg-def>
|
<function-arg-def name="warFilePath" type="required" default="''">
|
<function-arg-description>
|
Web application war file path
|
</function-arg-description>
|
<function-arg-property name="type" value="filepath"/>
|
</function-arg-def>
|
<function-arg-def name="destWarFileName" type="optional" default="'dsml.war'">
|
<function-arg-description>
|
Web application war destination file path
|
</function-arg-description>
|
<function-arg-property name="type" value="filepath"/>
|
</function-arg-def>
|
</function-map-args>
|
<sequence>
|
|
<message>
|
'setup: deploy web application %s to %s/%s-%s/webapps/%s' % (warFilePath, wcPath, WC_TYPE, WC_VERSION, destWarFileName)
|
</message>
|
|
<call function="'copyFile'">
|
{ 'location' : STAXServiceMachine,
|
'srcfile' : '%s' % warFilePath,
|
'destfile' : '%s/%s-%s/webapps/%s' % (wcPath, WC_TYPE, WC_VERSION, destWarFileName),
|
'remotehost' : location}
|
</call>
|
|
</sequence>
|
|
</function>
|
|
<function name="stopWebcontainerWithScript" scope="local">
|
<function-prolog>
|
This function stops a webcontainer
|
</function-prolog>
|
<function-map-args>
|
<function-arg-def name="location" type="optional" default="STAF_REMOTE_HOSTNAME">
|
<function-arg-description>
|
Location of target host
|
</function-arg-description>
|
<function-arg-property name="type" value="hostname"/>
|
</function-arg-def>
|
<function-arg-def name="wcPath" type="optional" default="'%s' % WC_DIRECTORY">
|
<function-arg-description>
|
Pathname to installation root
|
</function-arg-description>
|
<function-arg-property name="type" value="filepath"/>
|
</function-arg-def>
|
</function-map-args>
|
|
<sequence>
|
|
<!-- Build the Command -->
|
<script>
|
if wcPath:
|
wcBinPath='%s/bin' % wcPath
|
STAFCmd='%s/shutdown.sh' % wcBinPath
|
STAFCmdEnv=['CATALINA_HOME=%s' % wcPath,'PATH=/bin:/usr/bin',\
|
'JAVA_HOME=%s' % JAVA_HOME]
|
</script>
|
|
<message>
|
'%s' % STAFCmd
|
</message>
|
|
<call function="'runCommand'">
|
{ 'location' : location,
|
'command' : STAFCmd,
|
'env' : STAFCmdEnv,
|
'name' : STAFCmd,
|
'path' : wcBinPath
|
}
|
</call>
|
<script>
|
stopRC=RC
|
stopResult=STAXResult
|
</script>
|
<call function="'checkRC'">
|
{ 'returncode' : stopRC,
|
'result' : stopResult }
|
</call>
|
<return>stopResult</return>
|
|
</sequence>
|
|
</function>
|
|
<function name="startWebcontainerWithScript" scope="local">
|
<function-prolog>
|
This function start a webcontainer
|
</function-prolog>
|
<function-map-args>
|
<function-arg-def name="location" type="optional" default="STAF_REMOTE_HOSTNAME">
|
<function-arg-description>
|
Location of target host
|
</function-arg-description>
|
<function-arg-property name="type" value="hostname"/>
|
</function-arg-def>
|
<function-arg-def name="wcPath" type="optional" default="'%s/%s-%s' % (WC_DIRECTORY, WC_TYPE, WC_VERSION)">
|
<function-arg-description>
|
Pathname to installation root
|
</function-arg-description>
|
<function-arg-property name="type" value="filepath"/>
|
</function-arg-def>
|
</function-map-args>
|
|
<sequence>
|
|
<!-- Build the Command -->
|
<script>
|
if wcPath:
|
wcBinPath='%s/bin' % wcPath
|
STAFCmd='%s/startup.sh' % wcBinPath
|
STAFCmdEnv=['CATALINA_HOME=%s' % wcPath,'PATH=/bin:/usr/bin', \
|
'JAVA_HOME=%s' % JAVA_HOME]
|
</script>
|
|
<message>
|
'%s' % STAFCmd
|
</message>
|
|
<call function="'runCommand'">
|
{ 'location' : location,
|
'command' : STAFCmd,
|
'env' : STAFCmdEnv,
|
'name' : STAFCmd,
|
'path' : wcBinPath
|
}
|
</call>
|
<script>
|
startRC=RC
|
startResult=STAXResult
|
</script>
|
<call function="'checkRC'">
|
{ 'returncode' : startRC ,
|
'result' : startResult }
|
</call>
|
|
<return>startResult</return>
|
|
</sequence>
|
|
</function>
|
|
<function name="removeWebcontainer" scope="local">
|
<function-prolog>
|
This function removes the webcontainer instance
|
</function-prolog>
|
|
<function-map-args>
|
<function-arg-def name="location" type="optional" default="STAF_REMOTE_HOSTNAME">
|
<function-arg-description>
|
Location of target host
|
</function-arg-description>
|
<function-arg-property name="type" value="hostname"/>
|
</function-arg-def>
|
<function-arg-def name="wcPath" type="optional" default="'%s' % WC_DIRECTORY">
|
<function-arg-description>
|
Pathname to installation root
|
</function-arg-description>
|
<function-arg-property name="type" value="filepath"/>
|
</function-arg-def>
|
</function-map-args>
|
|
<try>
|
|
<sequence>
|
|
<!-- Remove webcontainer directory -->
|
<message>
|
'Remove webcontainer from %s %s.' % (location,wcPath)
|
</message>
|
<call function="'deleteFolder'">
|
{ 'location' : location,
|
'foldername' : '%s/%s-%s' % (wcPath, WC_TYPE, WC_VERSION) }
|
</call>
|
|
<if expr="RC != 0">
|
<return>RC</return>
|
</if>
|
|
</sequence>
|
|
<catch exception="'TestExceptionResultFailed'" typevar="eType" var="eInfo">
|
<sequence>
|
<message>'caught %s with %s' % (eType,eInfo)</message>
|
<message>
|
'Remove temporary webcontainer zip archive from %s %s' % (location,wcPath)
|
</message>
|
<call function="'deleteFolder'">
|
{ 'location' : location ,
|
'foldername' : '%s/%s-%s' % (wcPath, WC_TYPE, WC_VERSION) }
|
</call>
|
</sequence>
|
</catch>
|
|
</try>
|
|
</function>
|
</stax>
|