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