<?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-2010 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>
<!-- generate SSL certificate -->
<!-- Check if 'webcontainer Certificate' file exists -->
<call function="'GetEntry'">
{
'location' : STAXServiceMachine,
'entry' : '%s/HttpCertificate' % TMPDIR,
'attribute' : 'TYPE'
}
</call>
<!-- 'WCCertificate' file does not exist so generate it -->
<if expr="RC == 48">
<sequence>
<!-- working arround sunwebserver migrate-jks-certs issue 6393534
by, making the alias be 'cn=sunwebserver' -->
<call function="'runCommand'">
{ 'name' : 'Generate a Certificate',
'location' : STAXServiceMachine,
'command' : '%s/bin/keytool' % (LOCAL_JAVA_HOME),
'arguments' : '-genkey -alias %s -keyalg rsa \
-dname "cn=%s,O=Sun Microsystems,C=US" \
-keystore "%s/HttpCertificate" \
-storepass "changeit" -keypass "changeit" \
-storetype JKS ' % (WC_TYPE, WC_TYPE, TMPDIR),
'path' : '%s/bin' % (LOCAL_JAVA_HOME),
'expectedRC': 0
}
</call>
</sequence>
</if>
<!-- copying cert File over -->
<message>
'copying %s/HttpCertificate to %s/HttpCertificate' % (TMPDIR,wcPath)
</message>
<call function="'copyFile'">
{ 'location' : STAXServiceMachine,
'srcfile' : '%s/HttpCertificate' % TMPDIR,
'destfile' : '%s/HttpCertificate' % wcPath,
'remotehost' : mylocation
}
</call>
<if expr="WC_TYPE == 'tomcat'">
<sequence>
<!-- 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/apache-%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/apache-%s-%s/bin' % (wcPath, WC_TYPE, WC_VERSION)</workdir>
<envs>['PATH=/bin:/usr/bin']</envs>
<stderr mode="'stdout'"/>
<stdout/>
<returnstdout/>
</process>
<!-- 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/apache-%s-%s/conf/server.xml ' % \
(wcPath, WC_TYPE, WC_VERSION)</request>
</stafcmd>
<script>
serverXmlInput=STAFResult
import re
# update the HTTP / HTTPS ports
portRegEx = re.compile('8080')
sslPortRegEx = re.compile('8443')
content=portRegEx.sub(WC_PORT, serverXmlInput)
content=sslPortRegEx.sub(WC_SSL_PORT, content)
# enable the SSL port
sslConnectorRegEx = re.compile('&lt;Service name="Catalina"&gt;')
SSL_CONNECTOR = '&lt;Service name="Catalina"&gt;\n \
&lt;Connector port="%s" protocole="HTTP/1.1" \
SSLEnabled="true" maxThreads="150" scheme="https" secure="true" \
clientAuth="false" sslProtocol="SSL" \
keystoreFile="%s/HttpCertificate" \
keyAlias="%s" \
keystorePass="changeit" /&gt;' % \
(WC_SSL_PORT, wcPath, WC_TYPE)
content=sslConnectorRegEx.sub(SSL_CONNECTOR, content)
serverXmlOutput=open('%s/%s-apache-%s-%s_server.xml' % \
(local.temp,STAF_REMOTE_HOSTNAME,WC_TYPE,WC_VERSION),'w')
serverXmlOutput.write(content)
serverXmlOutput.close()
</script>
<call function="'copyFile'">
{'srcfile' : '%s/%s-apache-%s-%s_server.xml' % (local.temp, STAF_REMOTE_HOSTNAME, WC_TYPE, WC_VERSION),
'destfile' : '%s/apache-%s-%s/conf/server.xml' % (wcPath, WC_TYPE, WC_VERSION),
'remotehost' : '%s' % STAF_REMOTE_HOSTNAME
}
</call>
<call function="'copyFile'">
{ 'srcfile' : '%/ext/emma/lib/emma.jar' % TESTS_ROOT,
'destfile' : '%s/apache-%s-%s/lib/emma.jar' % (wcPath, WC_TYPE, WC_VERSION),
'remotehost' : '%s' % STAF_REMOTE_HOSTNAME
}
</call>
<if expr="RC != 0">
<return>RC</return>
</if>
</sequence>
<elseif expr="WC_TYPE == 'glassfish'">
<sequence>
<!-- configure webcontainer's PORTs -->
<message>
'Configure webcontainer ports HTTP %s / HTTPS %s' % (WC_PORT, WC_SSL_PORT)
</message>
<script>
# create a glassfish batch command file
asadminCmds = ["delete-jvm-options -Djavax.net.ssl.keyStore=${com.sun.aas.instanceRoot}/config/keystore.jks",
"create-jvm-options -Djavax.net.ssl.keyStore=%s/HttpCertificate:-Djavax.net.ssl.keyStorePassword=changeit" % wcPath,
"delete-http-listener http-listener-1",
"delete-http-listener http-listener-2",
"create-http-listener -e --enabled=true --listenerport %s --listeneraddress %s --defaultvs server httpListener" % (WC_PORT, STAF_REMOTE_HOSTNAME),
"create-http-listener -e --enabled=true --listenerport %s --listeneraddress %s --defaultvs server httpsListener" % (WC_SSL_PORT, STAF_REMOTE_HOSTNAME),
"create-ssl --type http-listener --certname %s httpsListener" % WC_TYPE
]
asadminBatchFile = open(os.path.join(local.temp,'asadminWebContainerConfig'),'w')
# FIXME - had to resort to workarround that somce create-http-listener didn't work when in the batchfile
# batch only the delete-jvm-options / create-jvm-options, the rest is done one asadmin cmdline at a time
asadminBatchFile.write('\n'.join(asadminCmds[:2]))
asadminBatchFile.write('\n')
asadminBatchFile.flush()
asadminBatchFile.close()
</script>
<call function="'copyFile'">
{'srcfile' : '%s/asadminWebContainerConfig' % (local.temp),
'destfile' : '%s/asadminWebContainerConfig' % (remote.temp),
'remotehost' : '%s' % STAF_REMOTE_HOSTNAME
}
</call>
<if expr="RC != 0">
<return>RC</return>
</if>
<message>'Starting glassfish to enable administration'</message>
<script>
STAFCmd = None
STAFCmdEnv = None
if wcPath:
wcBinPath=os.path.join(wcPath, 'glassfishv3','bin')
STAFCmd='%s/asadmin' % wcBinPath
STAFCmdEnv=['PATH=%s/bin:/bin:/usr/bin' % JAVA_HOME, 'JAVA_HOME=%s' % JAVA_HOME]
</script>
<message>
'%s' % STAFCmd
</message>
<call function="'runCommand'">
{ 'location' : STAF_REMOTE_HOSTNAME,
'command' : STAFCmd,
'envCmd' : STAFCmdEnv,
'arguments' : 'start-domain',
'name' : STAFCmd,
'path' : wcBinPath
}
</call>
<message>'Configuring glassfish ports and certificate'</message>
<script>
if wcPath:
wcBinPath=os.path.join(wcPath, 'glassfishv3','bin')
STAFCmd='%s/asadmin' % wcBinPath
STAFCmdEnv=['PATH=%s/bin:/bin:/usr/bin' % JAVA_HOME, 'JAVA_HOME=%s' % JAVA_HOME]
STAFCmdArgs=' '.join(['multimode',
'--file',
'%s/asadminWebContainerConfig' % (remote.temp)])
</script>
<message>
'%s' % STAFCmd
</message>
<call function="'runCommand'">
{ 'location' : STAF_REMOTE_HOSTNAME,
'command' : STAFCmd,
'arguments' : STAFCmdArgs,
'envCmd' : STAFCmdEnv,
'name' : STAFCmd,
'path' : wcBinPath
}
</call>
<if expr="RC != 0">
<sequence>
<message>
'failed configuring glassfish with STAXResult=[%s]' % STAXResult
</message>
<return>RC</return>
</sequence>
</if>
<iterate var="cfgItem" in="asadminCmds[2:]">
<sequence>
<message> 'configure with cfgItem=%s' % cfgItem </message>
<call function="'runCommand'">
{ 'location' : location,
'command' : STAFCmd,
'arguments' : cfgItem,
'envCmd' : STAFCmdEnv,
'name' : STAFCmd,
'path' : wcBinPath
}
</call>
<if expr="RC != 0">
<sequence>
<message>
'failed configuring glassfish with STAXResult=[%s]' % STAXResult
</message>
<return>RC</return>
</sequence>
</if>
</sequence>
</iterate>
<message>'Stopping glassfish '</message>
<script>
if wcPath:
wcBinPath=os.path.join(wcPath, 'glassfishv3','bin')
STAFCmd='%s/asadmin' % wcBinPath
STAFCmdEnv=['PATH=%s/bin:/bin:/usr/bin' % JAVA_HOME,\
'JAVA_HOME=%s' % JAVA_HOME]
</script>
<message>
'%s' % STAFCmd
</message>
<call function="'runCommand'">
{ 'location' : location,
'command' : STAFCmd,
'arguments' : 'stop-domain',
'envCmd' : STAFCmdEnv,
'name' : STAFCmd,
'path' : wcBinPath
}
</call>
</sequence>
</elseif>
<elseif expr="WC_TYPE == 'sunwebserver'">
<sequence>
<!-- generate a statefile -->
<call function="'GetVar'">
{
'location' : STAF_REMOTE_HOSTNAME,
'type' : 'system',
'variable' : 'STAF/Env/USER'
}
</call>
<script>
wcUser = STAFResult
print 'sunwebserver as user : %s' % wcUser
STAFCmd = os.path.join(wcPath,'setup')
</script>
<call function="'runCommand'">
{ 'location' : STAF_REMOTE_HOSTNAME,
'name' : 'getting SunWebserver ID',
'command' : STAFCmd,
'arguments' : '--id',
'path' : wcPath,
}
</call>
<script>
sunWebserverID = STAXResult[0][1]
stateFileList = [ '[STATE_BEGIN Sun Java System Web Server %s]' % sunWebserverID.strip(),
'defaultInstallDirectory = /sun/webserver7',
'currentInstallDirectory = %s/%s-%s' % (wcPath, WC_TYPE, WC_VERSION),
'UPGRADE = false',
'SELECTED_COMPONENTS = admincli,svrcore,devsupport',
'USE_BUNDLED_JDK = true',
'JDK_LOCATION = ',
'IS_ADMIN_NODE = false',
'STARTUP_ONBOOT = false',
'CREATE_SERVICE = ',
'ADMIN_HOST = %s' % STAF_REMOTE_HOSTNAME,
'ADMIN_SSL_PORT = 8989', #FIXME need to define a new port
'ADMIN_PORT = ',
'ADMIN_UID = %s' % wcUser,
'ADMIN_NAME = admin',
'ADMIN_PASSWD = password',
'NODE_HOST = ',
'NODE_SSL_PORT = ',
'REGISTER_NODE = ',
'WEB_SERVERNAME = %s' % STAF_REMOTE_HOSTNAME,
'WEB_PORT = %s' % WC_PORT,
'WEB_UID = %s ' % wcUser,
'WEB_DOCROOT = ',
'SIXTYFOURBIT_INSTALL = false', # FIXME we could figure out this with a call to java -d 64
'CONFIG_NAME = %s ' % STAF_REMOTE_HOSTNAME,
'SKIP_INSTANCE_CREATION = ',
'START_ADMIN = true',
'[STATE_DONE Sun Java System Web Server %s]' % sunWebserverID.strip(),
]
print 'sunwebserver install statefile %s' % '\n'.join(stateFileList)
silentFilename = 'sunwebserver.statefile'
silentFd = open(os.path.join(local.temp,silentFilename),'w')
silentFd.write('\n'.join(stateFileList))
silentFd.flush()
silentFd.close()
silentFilePath = os.path.join(wcPath, silentFilename)
STAFCmdArgs = '--silent %s' % silentFilePath
</script>
<call function="'copyFile'">
{ 'location' : STAXServiceMachine,
'srcfile' : '%s' % os.path.join(local.temp,silentFilename),
'destfile' : '%s' % silentFilePath,
'remotehost' : STAF_REMOTE_HOSTNAME,
}
</call>
<call function="'runCommand'">
{ 'location' : STAF_REMOTE_HOSTNAME,
'name' : 'Setup SunWebserver silent mode',
'command' : STAFCmd,
'arguments' : STAFCmdArgs,
'path' : wcPath,
}
</call>
<if expr="RC != 0">
<sequence>
<message>'Failed to setup the %s-%s, backing setup log' % (WC_TYPE, WC_VERSION)</message>
<script>
backupType='Setup'
srcDir = os.path.join(wcPath, '%s-%s' % (WC_TYPE, WC_VERSION), 'setup')
destDir = os.path.join(local.temp,'%s%sBackup' % (WC_TYPE, backupType))
</script>
<call function="'runSTAFCommand'">
{ 'name' : 'backup webapps WEB-INF files',
'location' : STAF_REMOTE_HOSTNAME,
'service' : 'FS',
'request' : 'COPY ',
'arguments' : 'DIRECTORY %s TODIRECTORY %s TOMACHINE %s RECURSE' % (srcDir, destDir, STAXServiceMachine)
}
</call>
<if expr="RC != 0">
<sequence>
<message>'Failed to backup %s-%s setup log file' % (WC_TYPE, WC_VERSION)</message>
<return>0</return>
</sequence>
</if>
</sequence>
</if>
<!-- create a wadm passwordfile -->
<script>
wadmPwdFilename = os.path.join(local.temp,'wadmPwd')
wadmPwdFile = open(wadmPwdFilename,'w')
wadmPwdFile.write('wadm_password=password\n')
wadmPwdFile.flush()
wadmPwdFile.close()
wadmDestPwdFilename = os.path.join(wcPath,'wadmPwd')
</script>
<call function="'copyFile'">
{ 'location' : STAXServiceMachine,
'srcfile' : '%s' % wadmPwdFilename,
'destfile' : '%s' % wadmDestPwdFilename,
'remotehost' : location}
</call>
<!-- migrate the JKS keystore -->
<script>
STAFCmd = os.path.join(wcPath,'%s-%s' % (WC_TYPE, WC_VERSION), 'bin', 'wadm')
STAFCmdArgs = ' '.join(['migrate-jks-keycert',
'--user=admin', '--password-file=%s' % wadmDestPwdFilename,
'--host=%s' % STAF_REMOTE_HOSTNAME,
'--config=%s' % STAF_REMOTE_HOSTNAME,
'--keystore=%s/HttpCertificate' % wcPath,
'--key-password=changeit', '--keystore-password=changeit'])
</script>
<call function="'runCommand'">
{ 'location' : STAF_REMOTE_HOSTNAME,
'name' : 'Migrate the keystore',
'command' : STAFCmd,
'arguments' : STAFCmdArgs,
'path' : wcPath,
}
</call>
<script>
STAFCmdArgs = ' '.join(['list-certs',
'--user=admin', '--password-file=%s' % wadmDestPwdFilename,
'--host=%s' % STAF_REMOTE_HOSTNAME,
'--config=%s' % STAF_REMOTE_HOSTNAME])
</script>
<call function="'runCommand'">
{ 'location' : STAF_REMOTE_HOSTNAME,
'name' : 'Migrate the keystore',
'command' : STAFCmd,
'arguments' : STAFCmdArgs,
'path' : wcPath,
}
</call>
<!-- create SSL listener -->
<script>
STAFCmdArgs = ' '.join(['create-http-listener', '--user=admin',
'--password-file=%s' % wadmDestPwdFilename,
'--host=%s' % STAF_REMOTE_HOSTNAME,
'--config=%s' % STAF_REMOTE_HOSTNAME,
'--server-name=%s-%s' % (WC_TYPE,WC_VERSION),
'--description=SSL-listener',
'--listener-port=%s' % WC_SSL_PORT,
'--default-virtual-server-name=%s' % STAF_REMOTE_HOSTNAME,
'ssl-listener-1'])
</script>
<call function="'runCommand'">
{ 'location' : STAF_REMOTE_HOSTNAME,
'name' : 'Create SSL dedicated http-listener',
'command' : STAFCmd,
'arguments' : STAFCmdArgs,
'path' : wcPath,
}
</call>
<script>
# there's a known issue with the keystore migration from JKS see : 6393534
# hence cert alias like following don't work : "CN=sunwebserver,O=Sun Microsystems,C=US"
# yielding 3 aliases in the server.xml as :
# CN=sunwebserver
# O=Sun Microsystems
# C=US
# apparently from the cmdline this works :
# bin/wadm set-ssl-prop --user=admin server-cert-nickname="CN=sunwebserver\,O=Sun Microsystems\,C=US"
#certNickName="cn=%s" % (WC_TYPE)
certNickName=r'"cn=%s\,O=Sun Microsystems\,C=US"' % (WC_TYPE)
print 'certNickName used in set-ssl-prop cmdline = [%s]' % certNickName
STAFCmdArgs = ' '.join(['set-ssl-prop',
'--user=admin', '--password-file=%s' % wadmDestPwdFilename,
'--host=%s' % STAF_REMOTE_HOSTNAME,
'--config=%s' % STAF_REMOTE_HOSTNAME,
'--http-listener=ssl-listener-1',
'enabled=true',
'tls=true',
'client-auth-timeout=60',
'client-auth=false',
'enabled=true',
'ssl2=true',
'max-client-auth-data=1048576',
'tls-rollback-detection=true',
'ssl3=true'
])
STAFCmdArgs = r'%s server-cert-nickname=%s' % (STAFCmdArgs, certNickName)
</script>
<call function="'runCommand'">
{ 'location' : STAF_REMOTE_HOSTNAME,
'name' : 'set the SSL handling for the SSL dedicated http-listener',
'command' : STAFCmd,
'arguments' : STAFCmdArgs,
'path' : wcPath,
}
</call>
<!-- deploy Config -->
<script>
STAFCmd = os.path.join(wcPath,'%s-%s' % (WC_TYPE, WC_VERSION), 'bin', 'wadm')
STAFCmdArgs = ' '.join(['deploy-config',
'--user=admin', '--password-file=%s' % wadmDestPwdFilename,
'--host=%s' % STAF_REMOTE_HOSTNAME,
'--no-prompt',
'--restart',
STAF_REMOTE_HOSTNAME])
</script>
<call function="'runCommand'">
{ 'location' : STAF_REMOTE_HOSTNAME,
'name' : 'deploy config',
'command' : STAFCmd,
'arguments' : STAFCmdArgs,
'path' : wcPath,
}
</call>
<!-- backup the config -->
<message>'backing up the webcontainer config'</message>
<script>
backupType='Config'
if WC_TYPE == 'tomcat':
srcDir = os.path.join(WC_DIRECTORY, 'apache-%s-%s' % (WC_TYPE, WC_VERSION), 'conf')
elif WC_TYPE == 'glassfish':
srcDir = os.path.join(WC_DIRECTORY, 'glassfishv3', 'glassfish', 'domains', 'domain1', 'config')
elif WC_TYPE == 'sunwebserver':
srcDir = os.path.join(wcPath, '%s-%s' % (WC_TYPE, WC_VERSION), 'https-%s' % STAF_REMOTE_HOSTNAME, 'config')
destDir = os.path.join(local.temp,'%s%sBackup' % (WC_TYPE, backupType))
</script>
<call function="'runSTAFCommand'">
{ 'name' : 'backup webcontainers log files',
'location' : STAF_REMOTE_HOSTNAME,
'service' : 'FS',
'request' : 'COPY ',
'arguments' : 'DIRECTORY %s TODIRECTORY %s TOMACHINE %s RECURSE' % (srcDir, destDir, STAXServiceMachine)
}
</call>
<if expr="RC != 0">
<sequence>
<message>'Failed to backup webcontainer log file'</message>
<return>0</return>
</sequence>
</if>
</sequence>
</elseif>
</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 auto deploy webapp directory' % (warFilePath)
</message>
<script>
# create the autodeploy webapp path
destWarFilePath = None
if WC_TYPE == 'tomcat':
destWarFilePath = os.path.join(wcPath, 'apache-%s-%s' % (WC_TYPE, WC_VERSION), 'webapps', destWarFileName)
elif WC_TYPE == 'glassfish':
destWarFilePath = os.path.join(wcPath, 'glassfishv3', 'glassfish',
'domains', 'domain1', 'autodeploy', destWarFileName)
elif WC_TYPE == 'sunwebserver':
destWarFilePath = os.path.join(wcPath, '%s-%s' % (WC_TYPE, WC_VERSION), 'https-%s' % STAF_REMOTE_HOSTNAME, 'auto-deploy', destWarFileName)
</script>
<message>
'autodeploy directory %s' % destWarFilePath
</message>
<call function="'copyFile'">
{ 'location' : STAXServiceMachine,
'srcfile' : '%s' % warFilePath,
'destfile' : '%s' % destWarFilePath,
'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:
if WC_TYPE == 'tomcat':
CATALINA_HOME=os.path.join(wcPath, 'apache-%s-%s' % (WC_TYPE, WC_VERSION) )
wcBinPath = os.path.join('%s' % CATALINA_HOME, 'bin')
STAFCmd='%s/shutdown%s' % (wcBinPath, scriptExt)
STAFCmdEnv=['CATALINA_HOME=%s' % CATALINA_HOME,
'PATH=%s/bin:/bin:/usr/bin' % JAVA_HOME,\
'JAVA_HOME=%s' % JAVA_HOME]
STAFCmdArgs=""
elif WC_TYPE == 'glassfish':
wcBinPath = os.path.join(wcPath, 'glassfishv3', 'bin')
STAFCmd='%s/asadmin' % wcBinPath
STAFCmdEnv=['PATH=%s/bin:/bin:/usr/bin' % JAVA_HOME ,\
'JAVA_HOME=%s' % JAVA_HOME]
STAFCmdArgs="stop-domain"
elif WC_TYPE == 'sunwebserver':
wcBinPath = os.path.join(wcPath, '%s-%s' % (WC_TYPE, WC_VERSION), 'https-%s' % STAF_REMOTE_HOSTNAME, 'bin')
STAFCmd = os.path.join(wcBinPath,'stopserv')
STAFCmdEnv=['PATH=%s/bin:/bin:/usr/bin' % JAVA_HOME ,\
'JAVA_HOME=%s' % JAVA_HOME]
STAFCmdArgs = ""
</script>
<message>
'%s' % STAFCmd
</message>
<call function="'runCommand'">
{ 'location' : location,
'command' : STAFCmd,
'arguments' : STAFCmdArgs,
'envCmd' : STAFCmdEnv,
'name' : STAFCmd,
'path' : wcBinPath
}
</call>
<!-- backup the web.xml -->
<message>'backing up the web.xml'</message>
<script>
backupType='WebappConfig'
if WC_TYPE == 'tomcat':
srcDir = os.path.join(WC_DIRECTORY, 'apache-%s-%s' % (WC_TYPE, WC_VERSION), 'webapps', 'dsml', 'WEB-INF')
elif WC_TYPE == 'glassfish':
srcDir = os.path.join(WC_DIRECTORY, 'glassfishv3', 'glassfish', 'domains',
'domain1', 'applications', 'dsml', 'WEB-INF')
elif WC_TYPE == 'sunwebserver':
srcDir = os.path.join(WC_DIRECTORY, '%s-%s' % (WC_TYPE, WC_VERSION), 'https-%s' % STAF_REMOTE_HOSTNAME,
'generated', STAF_REMOTE_HOSTNAME, 'dsml', 'WEB-INF')
destDir = os.path.join(local.temp,'%s%sBackup' % (WC_TYPE, backupType))
</script>
<call function="'runSTAFCommand'">
{ 'name' : 'backup webapps WEB-INF files',
'location' : STAF_REMOTE_HOSTNAME,
'service' : 'FS',
'request' : 'COPY ',
'arguments' : 'DIRECTORY %s TODIRECTORY %s TOMACHINE %s RECURSE' % (srcDir, destDir, STAXServiceMachine)
}
</call>
<if expr="RC != 0">
<sequence>
<message>'Failed to backup webcontainer log file'</message>
<return>0</return>
</sequence>
</if>
<!-- backup the logs -->
<message>'backing up the webcontainer logs'</message>
<script>
backupType='Logs'
if WC_TYPE == 'tomcat':
srcDir = os.path.join(WC_DIRECTORY, 'apache-%s-%s' % (WC_TYPE, WC_VERSION), 'logs')
elif WC_TYPE == 'glassfish':
srcDir = os.path.join(WC_DIRECTORY, 'glassfishv3', 'glassfish', 'domains', 'domain1', 'logs')
elif WC_TYPE == 'sunwebserver':
srcDir = os.path.join(wcPath, '%s-%s' % (WC_TYPE, WC_VERSION), 'https-%s' % STAF_REMOTE_HOSTNAME, 'logs')
destDir = os.path.join(local.temp,'%s%sBackup' % (WC_TYPE, backupType))
</script>
<call function="'runSTAFCommand'">
{ 'name' : 'backup webcontainers log files',
'location' : STAF_REMOTE_HOSTNAME,
'service' : 'FS',
'request' : 'COPY ',
'arguments' : 'DIRECTORY %s TODIRECTORY %s TOMACHINE %s RECURSE' % (srcDir, destDir, STAXServiceMachine)
}
</call>
<if expr="RC != 0">
<sequence>
<message>'Failed to backup webcontainer log file'</message>
<return>0</return>
</sequence>
</if>
</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' % 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:
if WC_TYPE == 'tomcat':
CATALINA_HOME=os.path.join(wcPath, 'apache-%s-%s' % (WC_TYPE, WC_VERSION) )
wcBinPath = os.path.join('%s' % CATALINA_HOME, 'bin')
STAFCmd='%s/startup%s' % (wcBinPath, scriptExt)
STAFCmdEnv=['CATALINA_HOME=%s' % CATALINA_HOME,
'PATH=%s/bin:/bin:/usr/bin' % JAVA_HOME,\
'JAVA_HOME=%s' % JAVA_HOME]
STAFCmdArgs = ''
elif WC_TYPE == 'glassfish':
wcBinPath = os.path.join(wcPath, 'glassfishv3', 'bin')
STAFCmd='%s/asadmin' % wcBinPath
STAFCmdEnv=['PATH=%s/bin:/bin:/usr/bin' % JAVA_HOME ,\
'JAVA_HOME=%s' % JAVA_HOME]
STAFCmdArgs = 'start-domain'
elif WC_TYPE == 'sunwebserver':
wcBinPath = os.path.join(wcPath, '%s-%s' % (WC_TYPE,WC_VERSION), 'https-%s' % STAF_REMOTE_HOSTNAME, 'bin')
STAFCmd = os.path.join(wcBinPath,'startserv')
STAFCmdEnv=['PATH=%s/bin:/bin:/usr/bin' % JAVA_HOME ,\
'JAVA_HOME=%s' % JAVA_HOME]
STAFCmdArgs = ""
</script>
<message>
'%s' % STAFCmd
</message>
<!-- On Windows 2003, startup command return 1 and 2008 returns 0 -->
<script>
winVersion = is_windows_platform(location)
if winVersion and winVersion.find('2003') != -1:
expectedRC=1
else:
expectedRC=0
</script>
<call function="'runCommand'">
{ 'location' : location,
'command' : STAFCmd,
'arguments' : STAFCmdArgs,
'envCmd' : STAFCmdEnv,
'name' : STAFCmd,
'path' : wcBinPath,
'expectedRC' : expectedRC
}
</call>
</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>
<if expr="WC_TYPE == 'tomcat'">
<call function="'deleteFolder'">
{ 'location' : location,
'foldername' : os.path.join(wcPath,'apache-%s-%s' % (WC_TYPE, WC_VERSION)) }
</call>
<elseif expr="WC_TYPE == 'glassfish'">
<call function="'deleteFolder'">
{ 'location' : location,
'foldername' : os.path.join(wcPath, 'glassfishv3') }
</call>
</elseif>
<elseif expr="WC_TYPE == 'sunwebserver'">
<sequence>
<script>
wcBinPath = os.path.join(wcPath, '%s-%s' % (WC_TYPE, WC_VERSION), 'bin')
STAFCmd = os.path.join(wcBinPath,'uninstall')
STAFCmdArgs = '--silent'
STAFCmdEnv=['PATH=%s/bin:/bin:/usr/bin' % JAVA_HOME, 'JAVA_HOME=%s' % JAVA_HOME]
</script>
<call function="'runCommand'">
{ 'location' : location,
'command' : STAFCmd,
'arguments' : STAFCmdArgs,
'envCmd' : STAFCmdEnv,
'name' : STAFCmd,
'path' : wcBinPath,
'expectedRC' : 0
}
</call>
<call function="'deleteFolder'">
{ 'location' : location,
'foldername' : '%s/%s-%s' % (wcPath, WC_TYPE, WC_VERSION) }
</call>
</sequence>
</elseif>
</if>
<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>
<if expr="WC_TYPE == 'tomcat'">
<call function="'deleteFolder'">
{ 'location' : location,
'foldername' : os.path.join(wcPath,'apache-%s-%s' % (WC_TYPE, WC_VERSION)) }
</call>
<elseif expr="WC_TYPE == 'glassfish'">
<call function="'deleteFolder'">
{ 'location' : location,
'foldername' : os.path.join(wcPath, 'glassfishv3') }
</call>
</elseif>
<elseif expr="WC_TYPE == 'sunwebserver'">
<call function="'deleteFolder'">
{ 'location' : location,
'foldername' : '%s/%s-%s' % (wcPath, WC_TYPE, WC_VERSION) }
</call>
</elseif>
</if>
</sequence>
</catch>
</try>
</function>
</stax>