mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

madiot
22.03.2009 26f90c15920220d919f82bae8295b517b61e3079
opendj-sdk/opends/tests/staf-tests/shared/functions/webcontainer.xml
@@ -77,110 +77,515 @@
            '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 -->
        
        <!-- Check if 'tomcatCertificate' file exists -->
        <!-- Check if 'webcontainer Certificate' file exists -->
        <call function="'GetEntry'">
          {
          'location'  : STAXServiceMachine,
          'entry'     : '%s/tomcatCertificate' % TMPDIR,
          'entry'     : '%s/%sCertificate' % (TMPDIR, WC_TYPE),
          'attribute' : 'TYPE'
          }
        </call>
        <!-- 'tomcatCertificate' file does not exist so generate it -->
        <!-- 'WCCertificate' file does not exist so generate it -->
        <if expr="RC == 48">
          <call function="'runCommand'">
            { 'name'      : 'Generate a Certificate',
              'location'  : STAXServiceMachine,
              'command'   : '%s/bin/keytool' % (LOCAL_JAVA_HOME),
              'arguments' : '-genkey -alias tomcat -keyalg rsa \
                             -dname "cn=tomcat,O=Sun Microsystems,C=US" \
                             -keystore "%s/tomcatCertificate" \
                             -storepass "changeit" -keypass "changeit" \
                             -storetype JKS ' % (TMPDIR),
              'path'      : '%s/bin' % (LOCAL_JAVA_HOME),
              'expectedRC': 0
            }
          </call>
          <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/%sCertificate" \
                               -storepass "changeit" -keypass "changeit" \
                               -storetype JKS ' % (WC_TYPE, WC_TYPE, TMPDIR, WC_TYPE),
                'path'      : '%s/bin' % (LOCAL_JAVA_HOME),
                'expectedRC': 0
              }
            </call>
         </sequence>
        </if>
        <!-- copying cert File over -->
        <message>
          'copying %s/%sCertificate to %s/%sCertificate' % (TMPDIR,WC_TYPE,wcPath,WC_TYPE)
        </message>
        <call function="'copyFile'">
          { 'location'   : STAXServiceMachine,
            'srcfile'    : '%s/tomcatCertificate' % (TMPDIR),
            'destfile'   : '%s/%s-%s/conf/tomcatCertificate' % (wcPath, WC_TYPE, WC_VERSION),
            'srcfile'    : '%s/%sCertificate' % (TMPDIR, WC_TYPE),
            'destfile'   : '%s/%sCertificate' % (wcPath, WC_TYPE),
            '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('&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/%s-%s/conf/tomcatCertificate" \
            keystorePass="changeit" /&gt;' % \
            (WC_SSL_PORT, wcPath, WC_TYPE, WC_VERSION)
          content=sslConnectorRegEx.sub(SSL_CONNECTOR, content)
          serverXmlOutput=open('%s/%s-%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-%s-%s_server.xml' % (local.temp, 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 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/%sCertificate" \
                keyAlias="%s" \
                keystorePass="changeit" /&gt;' % \
                (WC_SSL_PORT, wcPath, WC_TYPE, 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>
            <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/%sCertificate:-Djavax.net.ssl.keyStorePassword=changeit" % (wcPath,WC_TYPE),
                            "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(TMPDIR,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(TMPDIR,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(TMPDIR,'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/%sCertificate' % (wcPath,WC_TYPE),
                                      '--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">
@@ -234,16 +639,29 @@
    <sequence>
      
      <message>
        'setup: deploy web application %s to %s/%s-%s/webapps/%s' % (warFilePath, wcPath, WC_TYPE, WC_VERSION, destWarFileName)
        '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/%s-%s/webapps/%s' % (wcPath, WC_TYPE, WC_VERSION, destWarFileName),
        'destfile' : '%s' % destWarFilePath,
        'remotehost' : location}
      </call>
    </sequence>
    
  </function>
@@ -271,13 +689,29 @@
      
      <!-- Build the Command -->
      <script>
        if wcPath:
          wcBinPath='%s/bin' % wcPath
          STAFCmd='%s/shutdown%s' % (wcBinPath, scriptExt)
          STAFCmdEnv=['CATALINA_HOME=%s' % wcPath,'PATH=/bin:/usr/bin',\
                      'JAVA_HOME=%s' % JAVA_HOME]
        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>
@@ -285,12 +719,71 @@
      <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>
@@ -306,7 +799,7 @@
        </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-def  name="wcPath" type="optional" default="'%s' % WC_DIRECTORY">
        <function-arg-description>
          Pathname to installation root
        </function-arg-description>
@@ -318,11 +811,27 @@
      
      <!-- Build the Command -->
      <script>
        if wcPath:
          wcBinPath='%s/bin' % wcPath
          STAFCmd='%s/startup%s' % (wcBinPath, scriptExt)
          STAFCmdEnv=['CATALINA_HOME=%s' % wcPath,'PATH=/bin:/usr/bin', \
                      'JAVA_HOME=%s' % JAVA_HOME]
        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>
@@ -340,6 +849,7 @@
      <call function="'runCommand'">
        { 'location' : location,
        'command'    : STAFCmd,
        'arguments'  : STAFCmdArgs,
        'envCmd'     : STAFCmdEnv,
        'name'       : STAFCmd,
        'path'       : wcBinPath,
@@ -379,10 +889,43 @@
        <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="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>
@@ -396,10 +939,24 @@
          <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>
          <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>