<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<!DOCTYPE stax SYSTEM "../../../../shared/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
|
!
|
! Copyright 2008 Sun Microsystems, Inc.
|
! -->
|
<stax>
|
|
<function name="SetUpDsWithScript" scope="local">
|
<function-prolog>
|
This function sets up a Directory Server using a script
|
</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="dsPath" type="required">
|
<function-arg-description>
|
Pathname to installation root
|
</function-arg-description>
|
<function-arg-property name="type" value="filepath"/>
|
</function-arg-def>
|
<function-arg-def name="dsPort" type="optional">
|
<function-arg-description>
|
Directory server port number
|
</function-arg-description>
|
<function-arg-property name="type" value="Port number"/>
|
</function-arg-def>
|
<function-arg-def name="dsSslPort" type="optional">
|
<function-arg-description>
|
Directory server secure port number
|
</function-arg-description>
|
<function-arg-property name="type" value="Port number"/>
|
</function-arg-def>
|
<function-arg-def name="dsJmxPort" type="optional">
|
<function-arg-description>
|
Directory server JMX port number
|
</function-arg-description>
|
<function-arg-property name="type" value="Port number"/>
|
</function-arg-def>
|
<function-arg-def name="dsBaseDN" type="optional">
|
<function-arg-description>
|
Base DN (only single base DN supported).
|
</function-arg-description>
|
<function-arg-property name="type" value="DN"/>
|
</function-arg-def>
|
<function-arg-def name="dsBindDN" type="optional">
|
<function-arg-description>
|
Bind DN
|
</function-arg-description>
|
<function-arg-property name="type" value="DN"/>
|
</function-arg-def>
|
<function-arg-def name="dsBindPwd" type="optional">
|
<function-arg-description>
|
Bind password
|
</function-arg-description>
|
<function-arg-property name="type" value="string"/>
|
</function-arg-def>
|
<function-arg-def name="dsBindPwdFile" type="optional">
|
<function-arg-description>
|
Bind password file
|
</function-arg-description>
|
<function-arg-property name="type" value="filename"/>
|
</function-arg-def>
|
<function-arg-def name="dsEnableWindowsService" type="optional">
|
<function-arg-description>
|
Enable as a Windows Service
|
</function-arg-description>
|
<function-arg-property name="type" value="boolean"/>
|
</function-arg-def>
|
<function-arg-def name="dsDoNotStart" type="optional">
|
<function-arg-description>
|
Do not start server after setup
|
</function-arg-description>
|
<function-arg-property name="type" value="boolean"/>
|
</function-arg-def>
|
<function-arg-def name="dsHelp" type="optional">
|
<function-arg-description>
|
Help option
|
</function-arg-description>
|
<function-arg-property name="help" value="option"/>
|
</function-arg-def>
|
<function-arg-def name="dsEnableStartTLS" type="optional"
|
default="'false'">
|
<function-arg-description>
|
Enable startTLS, must use dsCertifiacte parameter
|
</function-arg-description>
|
<function-arg-property name="type" value="boolean"/>
|
</function-arg-def>
|
<function-arg-def name="dsCertificate" type="optional">
|
<function-arg-description>
|
certificate mode: generateSelfSigned
|
</function-arg-description>
|
<function-arg-property name="type" value="string"/>
|
</function-arg-def>
|
|
<function-arg-def name="fileFd" type="required">
|
<function-arg-description>
|
output file descriptor
|
</function-arg-description>
|
</function-arg-def>
|
</function-map-args>
|
|
<sequence>
|
|
<!-- Build the Command -->
|
<script>
|
STAFCmdParamsList=[]
|
STAFCmdParams=''
|
|
# define environment variables
|
env = []
|
env.append('PATH=/bin:/usr/bin:%s' % dsPath)
|
env.append('JAVA_HOME=%s' % JAVA_HOME)
|
env.append('OPENDS_JAVA_HOME=%s' % JAVA_HOME)
|
|
if dsPath:
|
STAFCmd='%s/setup' % (dsPath)
|
STAFCmdParamsList.append('--cli')
|
STAFCmdParamsList.append('-n')
|
|
if dsPort:
|
STAFCmdParamsList.append('-p %s' % dsPort)
|
|
if dsSslPort:
|
STAFCmdParamsList.append('-Z %s' % dsSslPort)
|
|
if dsJmxPort:
|
STAFCmdParamsList.append('-x %s' % dsJmxPort)
|
|
if dsBaseDN:
|
STAFCmdParamsList.append('-b "%s"' % dsBaseDN)
|
|
if dsBindDN:
|
STAFCmdParamsList.append('-D "%s"' % dsBindDN)
|
|
if dsBindPwd:
|
STAFCmdParamsList.append('-w "%s"' % dsBindPwd)
|
|
if dsBindPwdFile:
|
STAFCmdParamsList.append('-j "%s"' % dsBindPwdFile)
|
|
if dsEnableWindowsService:
|
STAFCmdParamsList.append('-e')
|
|
if dsDoNotStart:
|
STAFCmdParamsList.append('-O')
|
|
if dsHelp:
|
STAFCmdParamsList.append('-H')
|
|
if dsEnableStartTLS:
|
dsEnableStartTLS = dsEnableStartTLS.lower()
|
if dsEnableStartTLS == 'true':
|
STAFCmdParamsList.append('--enableStartTLS')
|
|
if dsCertificate:
|
dsCertificate = dsCertificate.lower()
|
if dsCertificate == 'generateselfsigned':
|
STAFCmdParamsList.append('--generateSelfSignedCertificate')
|
|
STAFCmdParams=' '.join(STAFCmdParamsList)
|
</script>
|
|
<call function="'runCommand'">
|
{ 'name' : 'SetUpOpenDSWithScript',
|
'location' : location,
|
'command' : STAFCmd,
|
'arguments' : STAFCmdParams,
|
'path' : dsPath,
|
'env' : env,
|
'fileFd' : fileFd
|
}
|
</call>
|
|
<return>STAXResult</return>
|
</sequence>
|
</function>
|
|
|
<!-- This function starts DS using the start-ds script -->
|
<function name="StartDsWithScript" scope="local">
|
<function-prolog>
|
This function starts a Directory Server
|
</function-prolog>
|
<function-map-args>
|
<function-arg-def name="location" type="optional" default="'%s' % STAXServiceMachine">
|
<function-arg-description>
|
Location of target host
|
</function-arg-description>
|
<function-arg-property name="type" value="hostname"/>
|
</function-arg-def>
|
<function-arg-def name="instance" type="optional">
|
<function-arg-description>
|
instance object of the instance
|
</function-arg-description>
|
<function-arg-property name="type" value="option"/>
|
</function-arg-def>
|
<function-arg-def name="dsPath" type="required">
|
<function-arg-description>
|
Pathname to installation root
|
</function-arg-description>
|
<function-arg-property name="type" value="hostname"/>
|
</function-arg-def>
|
<function-arg-def name="dsVersion" type="optional">
|
<function-arg-description>
|
Directory server version
|
</function-arg-description>
|
<function-arg-property name="type" value="option"/>
|
</function-arg-def>
|
<function-arg-def name="dsSystemInfo" type="optional">
|
<function-arg-description>
|
Directory server system info
|
</function-arg-description>
|
<function-arg-property name="type" value="option"/>
|
</function-arg-def>
|
<function-arg-def name="dsNoDetach" type="optional">
|
<function-arg-description>
|
Do not detach directory server from process
|
</function-arg-description>
|
<function-arg-property name="type" value="option"/>
|
</function-arg-def>
|
<function-arg-def name="dsHelp" type="optional">
|
<function-arg-description>
|
Help option
|
</function-arg-description>
|
<function-arg-property name="type" value="option"/>
|
</function-arg-def>
|
<function-arg-def name="dsBuildInfo" type="optional">
|
<function-arg-description>
|
Directory server build information
|
</function-arg-description>
|
<function-arg-property name="type" value="option"/>
|
</function-arg-def>
|
<function-arg-def name="fileFd" type="required">
|
<function-arg-description>
|
output file descriptor
|
</function-arg-description>
|
</function-arg-def>
|
</function-map-args>
|
|
<sequence>
|
|
<!-- Build the Command -->
|
<script>
|
STAFCmdParamsList=[]
|
STAFCmdParams=''
|
|
if dsPath:
|
dsBinPath='%s/bin' % (dsPath)
|
STAFCmd='%s/start-ds' % (dsBinPath)
|
|
if dsVersion:
|
STAFCmdParamsList.append('-V')
|
|
if dsSystemInfo:
|
STAFCmdParamsList.append('-s')
|
|
if dsNoDetach:
|
STAFCmdParamsList.append('-N')
|
|
if dsHelp:
|
STAFCmdParamsList.append('-H')
|
|
if dsBuildInfo:
|
STAFCmdParamsList.append('-F')
|
|
STAFCmdParams=' '.join(STAFCmdParamsList)
|
</script>
|
|
<script>
|
# define environment variables
|
env = []
|
env.append('PATH=/bin:/usr/bin:%s' % dsBinPath)
|
env.append('JAVA_HOME=%s' % JAVA_HOME)
|
env.append('OPENDS_JAVA_HOME=%s' % JAVA_HOME)
|
|
if instance:
|
sys.path.append("%s/phases/parser" % TESTS_DIR )
|
from parser import *
|
tuning = instance.getTuning()
|
if tuning.getJavaArgs() != NOT_DEFINED:
|
env.append('OPENDS_JAVA_ARGS=%s' % tuning.getJavaArgs())
|
name = 'StartDs %s:%s' % (instance.getName(),instance.getLDAPPort())
|
else:
|
name = 'StartDs'
|
</script>
|
<call function="'runCommand'">
|
{ 'name' : name,
|
'location' : location,
|
'command' : STAFCmd,
|
'arguments' : STAFCmdParams,
|
'path' : dsBinPath,
|
'env' : env,
|
'fileFd' : fileFd
|
}
|
</call>
|
|
<return>STAXResult</return>
|
|
</sequence>
|
|
</function>
|
|
<!-- This function stops DS using the stop-ds script -->
|
<function name="StopDsWithScript" scope="local">
|
<function-prolog>
|
This function starts a Directory Server using the script
|
</function-prolog>
|
<function-map-args>
|
<function-arg-def name="location" type="optional" default="'%s' % STAXServiceMachine">
|
<function-arg-description>
|
Location of target host
|
</function-arg-description>
|
<function-arg-property name="type" value="hostname"/>
|
</function-arg-def>
|
<function-arg-def name="dsPath" type="required">
|
<function-arg-description>
|
Pathname to installation root
|
</function-arg-description>
|
<function-arg-property name="type" value="hostname"/>
|
</function-arg-def>
|
<function-arg-def name="dsHost" type="optional">
|
<function-arg-description>
|
Directory server hostname or IP address
|
</function-arg-description>
|
<function-arg-property name="type" value="hostname"/>
|
</function-arg-def>
|
<function-arg-def name="dsPort" type="optional">
|
<function-arg-description>
|
Directory server port number
|
</function-arg-description>
|
<function-arg-property name="type" value="integer"/>
|
</function-arg-def>
|
<function-arg-def name="dsUseSSL" type="optional">
|
<function-arg-description>
|
Use SSL for secure communication with the server
|
</function-arg-description>
|
<function-arg-property name="type" value="option"/>
|
</function-arg-def>
|
<function-arg-def name="dsUseStartTLS" type="optional">
|
<function-arg-description>
|
Use StartTLS for secure communication with the server
|
</function-arg-description>
|
<function-arg-property name="type" value="option"/>
|
</function-arg-def>
|
<function-arg-def name="dsBindDN" type="optional">
|
<function-arg-description>
|
Bind DN
|
</function-arg-description>
|
<function-arg-property name="type" value="DN"/>
|
</function-arg-def>
|
<function-arg-def name="dsBindPwd" type="optional">
|
<function-arg-description>
|
Bind password
|
</function-arg-description>
|
<function-arg-property name="type" value="string"/>
|
</function-arg-def>
|
<function-arg-def name="dsBindPwdFile" type="optional">
|
<function-arg-description>
|
Bind password file
|
</function-arg-description>
|
<function-arg-property name="type" value="filepath"/>
|
</function-arg-def>
|
<function-arg-def name="dsSaslOption" type="optional">
|
<function-arg-description>
|
SASL bind options
|
</function-arg-description>
|
<function-arg-property name="type" value="option"/>
|
</function-arg-def>
|
<function-arg-def name="dsProxyAuthZID" type="optional">
|
<function-arg-description>
|
Use the proxied authorization control with the given authorization ID
|
</function-arg-description>
|
<function-arg-property name="type" value="option"/>
|
</function-arg-def>
|
<function-arg-def name="dsStopReason" type="optional">
|
<function-arg-description>
|
Reason the server is being stopped or restarted
|
</function-arg-description>
|
<function-arg-property name="type" value="string"/>
|
</function-arg-def>
|
<function-arg-def name="dsRestart" type="optional">
|
<function-arg-description>
|
Attempt to automatically restart the server once it has stopped
|
</function-arg-description>
|
<function-arg-property name="type" value="option"/>
|
</function-arg-def>
|
<function-arg-def name="dsStopTime" type="optional">
|
<function-arg-description>
|
Time to begin the shutdown in YYYYMMDDhhmmss format (local time)
|
</function-arg-description>
|
<function-arg-property name="type" value="timestamp"/>
|
</function-arg-def>
|
<function-arg-def name="dsTrustAll" type="optional">
|
<function-arg-description>
|
Trust all server SSL certificates
|
</function-arg-description>
|
<function-arg-property name="type" value="option"/>
|
</function-arg-def>
|
<function-arg-def name="dsKeyStoreFile" type="optional">
|
<function-arg-description>
|
Certificate keystore path
|
</function-arg-description>
|
<function-arg-property name="type" value="filename"/>
|
</function-arg-def>
|
<function-arg-def name="dsKeyStorePwd" type="optional">
|
<function-arg-description>
|
Certificate keystore PIN
|
</function-arg-description>
|
<function-arg-property name="type" value="string"/>
|
</function-arg-def>
|
<function-arg-def name="dsKeyStorePwdFile" type="optional">
|
<function-arg-description>
|
Certificate keystore PIN file
|
</function-arg-description>
|
<function-arg-property name="type" value="filename"/>
|
</function-arg-def>
|
<function-arg-def name="dsTrustStoreFile" type="optional">
|
<function-arg-description>
|
Certificate trust store path
|
</function-arg-description>
|
<function-arg-property name="type" value="filename"/>
|
</function-arg-def>
|
<function-arg-def name="dsTrustStorePwd" type="optional">
|
<function-arg-description>
|
Certificate trust store PIN
|
</function-arg-description>
|
<function-arg-property name="type" value="string"/>
|
</function-arg-def>
|
<function-arg-def name="dsTrustStorePwdFile" type="optional">
|
<function-arg-description>
|
Certificate trust store PIN file
|
</function-arg-description>
|
<function-arg-property name="type" value="filename"/>
|
</function-arg-def>
|
<function-arg-def name="dsHelp" type="optional">
|
<function-arg-description>
|
Help option
|
</function-arg-description>
|
<function-arg-property name="type" value="option"/>
|
</function-arg-def>
|
<function-arg-def name="expectedRC" type="optional" default="0">
|
<function-arg-description>
|
Expected return code value. Default value is 0.
|
Wildcard 'noCheck' to not check the RC
|
</function-arg-description>
|
</function-arg-def>
|
<function-arg-def name="fileFd" type="optional" default="''">
|
<function-arg-description>
|
file descriptor to write message in if needed
|
</function-arg-description>
|
</function-arg-def>
|
|
</function-map-args>
|
|
<sequence>
|
|
<!-- Build the Command -->
|
<script>
|
STAFCmdParamsList=[]
|
STAFCmdParams=''
|
|
if dsPath:
|
dsBinPath='%s/bin' % (dsPath)
|
STAFCmd='%s/stop-ds' % (dsBinPath)
|
|
if dsHost:
|
STAFCmdParamsList.append('-h %s' % dsHost)
|
|
if dsPort:
|
STAFCmdParamsList.append('-p %s' % dsPort)
|
|
if dsUseSSL:
|
STAFCmdParamsList.append('-Z')
|
|
if dsUseStartTLS:
|
STAFCmdParamsList.append('-q')
|
|
if dsBindDN:
|
STAFCmdParamsList.append('-D "%s"' % dsBindDN)
|
|
if dsBindPwd:
|
STAFCmdParamsList.append('-w "%s"' % dsBindPwd)
|
|
if dsBindPwdFile:
|
STAFCmdParamsList.append('-j "%s"' % dsBindPwdFile)
|
|
if dsSaslOption:
|
STAFCmdParamsList.append('-o "%s"' % dsSaslOption)
|
|
if dsProxyAuthZID:
|
STAFCmdParamsList.append('-Y "%s"' % dsProxyAuthZID)
|
|
if dsStopReason:
|
STAFCmdParamsList.append('-r "%s"' % dsStopReason)
|
|
if dsRestart:
|
STAFCmdParamsList.append('-R')
|
|
if dsStopTime:
|
STAFCmdParamsList.append('-t "%s"' % dsStopTime)
|
|
if dsTrustAll:
|
STAFCmdParamsList.append('-X')
|
|
if dsKeyStoreFile:
|
STAFCmdParamsList.append('-K "%s"' % dsKeyStoreFile)
|
|
if dsKeyStorePwd:
|
STAFCmdParamsList.append('-W "%s"' % dsKeyStorePwd)
|
|
if dsKeyStorePwdFile:
|
STAFCmdParamsList.append('-u "%s"' % dsKeyStorePwdFile)
|
|
if dsTrustStoreFile:
|
STAFCmdParamsList.append('-P "%s"' % dsTrustStoreFile)
|
|
if dsTrustStorePwd:
|
STAFCmdParamsList.append('-T "%s"' % dsTrustStorePwd)
|
|
if dsTrustStorePwdFile:
|
STAFCmdParamsList.append('-U "%s"' % dsTrustStorePwdFile)
|
|
if dsHelp:
|
STAFCmdParamsList.append('-H')
|
|
STAFCmdParams=' '.join(STAFCmdParamsList)
|
</script>
|
|
<call function="'runCommand'">
|
{ 'name' : 'StopDsWithScript',
|
'location' : location,
|
'command' : STAFCmd,
|
'arguments' : STAFCmdParams,
|
'path' : dsBinPath,
|
'expectedRC': expectedRC,
|
'fileFd' : fileFd
|
}
|
</call>
|
|
<return>STAXResult</return>
|
</sequence>
|
</function>
|
|
|
|
<function name="makeLdif" scope="local">
|
<function-prolog>
|
This function uses make-ldif to generate ldif file
|
</function-prolog>
|
<function-map-args>
|
<function-arg-def name="location" type="optional" default="'%s' % STAXServiceMachine">
|
<function-arg-description>
|
Location of target host
|
</function-arg-description>
|
</function-arg-def>
|
<function-arg-def name="dsPath" type="required">
|
<function-arg-description>
|
Pathname to installation root
|
</function-arg-description>
|
</function-arg-def>
|
<function-arg-def name="templateFile" type="required">
|
<function-arg-description>
|
template ldif file
|
</function-arg-description>
|
</function-arg-def>
|
<function-arg-def name="ldifFile" type="required">
|
<function-arg-description>
|
ldif file to generate
|
</function-arg-description>
|
</function-arg-def>
|
<function-arg-def name="fileFd" type="required">
|
<function-arg-description>
|
file descriptor to log information
|
</function-arg-description>
|
</function-arg-def>
|
</function-map-args>
|
|
<sequence>
|
|
<!-- Build the Command -->
|
<script>
|
STAFCmdParamsList=[]
|
STAFCmdParams=''
|
|
if dsPath:
|
dsBinPath='%s/bin' % (dsPath)
|
STAFCmd='%s/make-ldif' % (dsBinPath)
|
|
STAFCmdParamsList.append('-t %s' % templateFile)
|
STAFCmdParamsList.append('-o %s' % ldifFile)
|
|
STAFCmdParams=' '.join(STAFCmdParamsList)
|
</script>
|
|
<call function="'runCommand'">
|
{ 'name' : 'MakeLdif',
|
'location' : location,
|
'command' : STAFCmd,
|
'arguments' : STAFCmdParams,
|
'path' : dsBinPath,
|
'fileFd' : fileFd
|
}
|
</call>
|
|
<return>STAXResult</return>
|
</sequence>
|
</function>
|
|
|
<!-- Import Function With Script-->
|
<function name="ImportLdifWithScript" scope="local">
|
<function-prolog>
|
This function performs an offline import of an ldif file using the script
|
</function-prolog>
|
<function-map-args>
|
<function-arg-def name="location" type="optional" default="'%s' % STAXServiceMachine">
|
<function-arg-description>
|
Location of target host
|
</function-arg-description>
|
<function-arg-property name="type" value="hostname"/>
|
</function-arg-def>
|
<function-arg-def name="dsPath" type="required">
|
<function-arg-description>
|
Pathname to installation root
|
</function-arg-description>
|
<function-arg-property name="type" value="hostname"/>
|
</function-arg-def>
|
<function-arg-def name="dsLdifFile" type="required">
|
<function-arg-description>
|
Path to the LDIF file to be imported
|
</function-arg-description>
|
<function-arg-property name="type" value="filename"/>
|
</function-arg-def>
|
<function-arg-def name="dsTemplateFile" type="optional">
|
<function-arg-description>
|
Path to a MakeLDIF template to use to generate the import data
|
</function-arg-description>
|
<function-arg-property name="type" value="filename"/>
|
</function-arg-def>
|
<function-arg-def name="dsAppend" type="optional">
|
<function-arg-description>
|
Append to an existing database rather than overwriting it
|
</function-arg-description>
|
<function-arg-property name="type" value="option"/>
|
</function-arg-def>
|
<function-arg-def name="dsReplaceExisting" type="optional">
|
<function-arg-description>
|
Replace existing entries when appending to the database
|
</function-arg-description>
|
<function-arg-property name="type" value="option"/>
|
</function-arg-def>
|
<function-arg-def name="dsBackEnd" type="optional" default="'%s' % DIRECTORY_INSTANCE_BE">
|
<function-arg-description>
|
Backend ID for the backend to import
|
</function-arg-description>
|
<function-arg-property name="type" value="string"/>
|
</function-arg-def>
|
<function-arg-def name="dsBranchDN" type="optional">
|
<function-arg-description>
|
Base DN of a branch to include in the LDIF import
|
</function-arg-description>
|
<function-arg-property name="type" value="dn"/>
|
</function-arg-def>
|
<function-arg-def name="dsIncludeBranch" type="optional">
|
<function-arg-description>
|
Base DN of a branch to include in the LDIF import
|
</function-arg-description>
|
<function-arg-property name="type" value="dn"/>
|
</function-arg-def>
|
<function-arg-def name="dsExcludeBranch" type="optional">
|
<function-arg-description>
|
Base DN of a branch to exclude from the LDIF import
|
</function-arg-description>
|
<function-arg-property name="type" value="dn"/>
|
</function-arg-def>
|
<function-arg-def name="dsIncludeAttribute" type="optional">
|
<function-arg-description>
|
Attribute to include in the LDIF import
|
</function-arg-description>
|
<function-arg-property name="type" value="attribute"/>
|
</function-arg-def>
|
<function-arg-def name="dsExcludeAttribute" type="optional">
|
<function-arg-description>
|
Attribute to exclude in the LDIF import
|
</function-arg-description>
|
<function-arg-property name="type" value="attribute"/>
|
</function-arg-def>
|
<function-arg-def name="dsIncludeFilter" type="optional">
|
<function-arg-description>
|
Filter to identify entries to include in the LDIF import
|
</function-arg-description>
|
<function-arg-property name="type" value="filter"/>
|
</function-arg-def>
|
<function-arg-def name="dsExcludeFilter" type="optional">
|
<function-arg-description>
|
Filter to identify entries to exclude from the LDIF import
|
</function-arg-description>
|
<function-arg-property name="type" value="filter"/>
|
</function-arg-def>
|
<function-arg-def name="dsRejectFile" type="optional">
|
<function-arg-description>
|
Write rejected entries to the specified file
|
</function-arg-description>
|
<function-arg-property name="type" value="filename"/>
|
</function-arg-def>
|
<function-arg-def name="dsOverWriteRejects" type="optional">
|
<function-arg-description>
|
Overwrite an existing rejects file rather than appending to it
|
</function-arg-description>
|
<function-arg-property name="type" value="option"/>
|
</function-arg-def>
|
<function-arg-def name="dsRandomSeed" type="optional">
|
<function-arg-description>
|
Seed for the MakeLDIF random number generator
|
</function-arg-description>
|
<function-arg-property name="type" value="seed"/>
|
</function-arg-def>
|
<function-arg-def name="dsSkipSchemaValidation" type="optional">
|
<function-arg-description>
|
Skip schema validation during the LDIF import
|
</function-arg-description>
|
<function-arg-property name="type" value="option"/>
|
</function-arg-def>
|
<function-arg-def name="dsIsCompressed" type="optional">
|
<function-arg-description>
|
LDIF file is compressed
|
</function-arg-description>
|
<function-arg-property name="type" value="option"/>
|
</function-arg-def>
|
<function-arg-def name="dsIsEncrypted" type="optional">
|
<function-arg-description>
|
LDIF file is encrypted
|
</function-arg-description>
|
<function-arg-property name="type" value="option"/>
|
</function-arg-def>
|
<function-arg-def name="dsQuiet" type="optional">
|
<function-arg-description>
|
Use quiet mode (no output)
|
</function-arg-description>
|
<function-arg-property name="type" value="option"/>
|
</function-arg-def>
|
<function-arg-def name="dsHelp" type="optional">
|
<function-arg-description>
|
Display usage information
|
</function-arg-description>
|
<function-arg-property name="type" value="option"/>
|
</function-arg-def>
|
<function-arg-def name="fileFd" type="required">
|
<function-arg-description>
|
output file descriptor
|
</function-arg-description>
|
</function-arg-def>
|
</function-map-args>
|
|
<sequence>
|
|
<!-- Build the Command -->
|
<script>
|
STAFCmdParamsList=[]
|
STAFCmdParams=''
|
|
if dsPath:
|
dsBinPath='%s/bin' % (dsPath)
|
STAFCmd='%s/import-ldif' % (dsBinPath)
|
|
if dsLdifFile:
|
STAFCmdParamsList.append('-l %s' % dsLdifFile)
|
|
if dsTemplateFile:
|
STAFCmdParamsList.append('-t %s' % dsTemplateFile)
|
|
if dsAppend:
|
STAFCmdParamsList.append('-a')
|
|
if dsReplaceExisting:
|
STAFCmdParamsList.append('-r')
|
|
if dsBackEnd:
|
STAFCmdParamsList.append('-n %s' % dsBackEnd)
|
|
if dsIncludeBranch:
|
STAFCmdParamsList.append('-b %s' % dsIncludeBranch)
|
|
if dsExcludeBranch:
|
STAFCmdParamsList.append('-B %s' % dsExcludeBranch)
|
|
if dsIncludeAttribute:
|
STAFCmdParamsList.append('-i %s' % dsIncludeAttribute)
|
|
if dsExcludeAttribute:
|
STAFCmdParamsList.append('-e %s' % dsExcludeAttribute)
|
|
if dsIncludeFilter:
|
STAFCmdParamsList.append('-I %s' % dsIncludeFilter)
|
|
if dsExcludeFilter:
|
STAFCmdParamsList.append('-E %s' % dsExcludeFilter)
|
|
if dsRejectFile:
|
STAFCmdParamsList.append('-R %s' % dsRejectFile)
|
|
if dsOverWriteRejects:
|
STAFCmdParamsList.append('-O')
|
|
if dsRandomSeed:
|
STAFCmdParamsList.append('-S %s' % dsRandomSeed)
|
|
if dsSkipSchemaValidation:
|
STAFCmdParamsList.append('-s')
|
|
if dsIsCompressed:
|
STAFCmdParamsList.append('-c')
|
|
if dsIsEncrypted:
|
STAFCmdParamsList.append('-y')
|
|
if dsQuiet:
|
STAFCmdParamsList.append('-q')
|
|
if dsHelp:
|
STAFCmdParamsList.append('-H')
|
|
STAFCmdParams=' '.join(STAFCmdParamsList)
|
</script>
|
|
<call function="'writeStartTagOperation'">
|
{ 'tagName' : 'ImportLdifWithScript',
|
'fileFd' : fileFd }
|
</call>
|
<call function="'writeMessage'">
|
{ 'fileFd' : fileFd,
|
'content' : '%s %s' % (STAFCmd, STAFCmdParams)
|
}
|
</call>
|
|
<process name="'Offline Import Script'">
|
<location>'%s' % location</location>
|
<command>'%s' % STAFCmd</command>
|
<parms>'%s' % STAFCmdParams</parms>
|
<workdir>'%s' % dsBinPath</workdir>
|
<envs>
|
['PATH=/bin:/usr/bin:%s' % dsBinPath]
|
</envs>
|
<stderr mode="'stdout'"/>
|
<returnstdout/>
|
</process>
|
|
<call function="'checkRC'">
|
{ 'returncode' : RC ,
|
'result' : STAXResult,
|
'fileFd' : fileFd }
|
</call>
|
|
<if expr="dsRejectFile">
|
<sequence>
|
<call function="'isEmptyFile'">
|
{ 'location' : location,
|
'fileName' : dsRejectFile }
|
</call>
|
<script>
|
fileEmpty = STAXResult
|
</script>
|
<!-- if rejected file exists, log an error -->
|
<if expr="fileEmpty == FALSE">
|
<sequence>
|
<script>
|
msg = 'ImportLdifWithScript rejected some entries,'
|
msg = '%s check file on %s : %s' % (msg,location,dsRejectFile)
|
</script>
|
<message>'ERROR, %s' % msg</message>
|
<call function="'checkRC'">
|
{
|
'returncode' : 999,
|
'result' : msg,
|
'fileFd' : fileFd
|
}
|
</call>
|
</sequence>
|
</if>
|
</sequence>
|
</if>
|
|
<call function="'writeEndTagOperation'">{'fileFd' : fileFd}</call>
|
|
</sequence>
|
</function>
|
|
|
|
<!-- This function stops DS using the stop-ds script -->
|
<function name="checkOpendsReplication" scope="local">
|
<function-prolog>
|
This function uses dsreplication status to check the replication
|
of the topology
|
</function-prolog>
|
<function-map-args>
|
<function-arg-def name="instance" type="required">
|
<function-arg-description>
|
opends instance object to run the command
|
</function-arg-description>
|
</function-arg-def>
|
<function-arg-def name="instances" type="required">
|
<function-arg-description>
|
list of opends instances objects
|
</function-arg-description>
|
</function-arg-def>
|
<function-arg-def name="suffix" type="required">
|
<function-arg-description>
|
suffix object of the topology
|
</function-arg-description>
|
</function-arg-def>
|
<function-arg-def name="adminDN" type="optional"
|
default="DIRECTORY_INSTANCE_DN">
|
<function-arg-description>
|
Admin Bind DN
|
</function-arg-description>
|
<function-arg-property name="type" value="DN"/>
|
</function-arg-def>
|
<function-arg-def name="adminPwd" type="optional"
|
default="DIRECTORY_INSTANCE_PSWD">
|
<function-arg-description>
|
Admin Bind password
|
</function-arg-description>
|
<function-arg-property name="type" value="string"/>
|
</function-arg-def>
|
<function-arg-def name="expectedRC" type="optional" default="0">
|
<function-arg-description>
|
Expected return code value. Default value is 0.
|
Wildcard 'noCheck' to not check the RC
|
</function-arg-description>
|
</function-arg-def>
|
<function-arg-def name="fileFd" type="optional" default="''">
|
<function-arg-description>
|
file descriptor to write message in if needed
|
</function-arg-description>
|
</function-arg-def>
|
|
</function-map-args>
|
|
<sequence>
|
|
<!-- Build the Command -->
|
<script>
|
STAFCmdParamsList=[]
|
STAFCmdParams=''
|
|
dsBinPath='%s/bin' % (instance.getInstallDir())
|
STAFCmd='%s/dsreplication' % (dsBinPath)
|
|
STAFCmdParamsList.append('status -n')
|
STAFCmdParamsList.append('--trustAll')
|
STAFCmdParamsList.append('-h %s' % instance.getHost())
|
if ( instance.getIsSslEnabled() == 'true' ):
|
port = instance.getLDAPSPort()
|
STAFCmdParamsList.append('--useSSL')
|
else:
|
port = instance.getLDAPPort()
|
|
STAFCmdParamsList.append('-p %s' % port )
|
STAFCmdParamsList.append('-b %s' % suffix.getSuffixDn())
|
STAFCmdParamsList.append('-I "%s"' % adminDN)
|
STAFCmdParamsList.append('-w "%s"' % adminPwd)
|
STAFCmdParams=' '.join(STAFCmdParamsList)
|
</script>
|
|
<call function="'writeStartTagOperation'">
|
{ 'tagName' : 'checkOpendsReplication',
|
'fileFd' : fileFd }
|
</call>
|
|
|
<!--== Run dsreplication status ==-->
|
<call function="'runCommand'">
|
{ 'name' : 'opendsReplicationStatus on %s' % \
|
instance.getHost(),
|
'location' : instance.getHost(),
|
'command' : STAFCmd,
|
'arguments' : STAFCmdParams,
|
'path' : dsBinPath,
|
'fileFd' : fileFd
|
}
|
</call>
|
<script>
|
cmdRC = STAXResult[0]
|
cmdOutput = STAXResult[1]
|
</script>
|
|
|
<!--== Check dsreplication status outputs if command succedded ==-->
|
<if expr="cmdRC == 0">
|
<sequence>
|
<call function="'writeStartTagOperation'">
|
{ 'tagName' : 'checkReplicationResults',
|
'fileFd' : fileFd }
|
</call>
|
|
<script>
|
# transform output string into a list (each element is a line)
|
cmdOutput = cmdOutput.split('\n')
|
list = STAXGlobal([])
|
</script>
|
|
<!--== For each instances, get nb of replicated entries ==-->
|
<iterate in="instances" var="instance">
|
<sequence>
|
<script>
|
|
if ( instance.getIsSslEnabled() == 'true' ):
|
port = instance.getLDAPPort()
|
else:
|
port = instance.getLDAPSPort()
|
|
serverName = '%s:%s' % \
|
(instance.getHost(),port)
|
nbEntries = NOT_DEFINED
|
|
for e in cmdOutput:
|
if e.count(serverName) > 0 :
|
# serverName line is found, extract nb of entries
|
e = e.split(':')
|
nbEntries = e[2].strip()
|
|
list = list.append([serverName,nbEntries])
|
</script>
|
</sequence>
|
</iterate>
|
|
|
<!--== Check that all instances have the same nb of entries ==-->
|
<!--== Build sorted list sList : ==-->
|
<!--== [ [serverName1 serverName2 .., nbEntry1 ] , ... ] ==-->
|
<script>
|
sList = STAXGlobal([])
|
|
while list != []:
|
element1 = list.pop(0)
|
isAlreadyExist = 0
|
j = 0
|
for e in sList:
|
if element1[1] == e[1]:
|
# some serverName already recorded with same
|
# nb of entries, add new serverName to the list
|
sList[j] = ['%s %s' % (e[0],element1[0]) , e[1] ]
|
isAlreadyExist = 1
|
j += 1
|
|
if isAlreadyExist == 0:
|
# new nb of entries, add a new sub list
|
sList = sList.append( [element1[0] ,element1[1]] )
|
|
</script>
|
|
<if expr="len(sList) == 1">
|
<sequence>
|
<script>
|
cmdOutput='All intances have the same number of entries (%s)'%\
|
sList[0][1]
|
cmdRC = 0
|
</script>
|
</sequence>
|
<else>
|
<sequence>
|
<script>
|
cmdOutput='All intances have NOT the same number of entries'
|
cmdRC = 1
|
</script>
|
<iterate in="sList" var="_list">
|
<call function="'writeMessage'">
|
{ 'fileFd' : fileFd,
|
'content' : 'INFO : instances %s have %s entries' % \
|
(_list[0],_list[1])
|
}
|
</call>
|
</iterate>
|
</sequence>
|
</else>
|
</if>
|
<call function="'checkRC'">
|
{ 'returncode' : cmdRC,
|
'result' : cmdOutput,
|
'fileFd' : fileFd }
|
</call>
|
<call function="'writeEndTagOperation'">
|
{'fileFd' : fileFd}
|
</call>
|
|
</sequence>
|
</if>
|
|
<!--== End of function ==-->
|
<call function="'checkRC'">
|
{ 'returncode' : cmdRC,
|
'result' : cmdOutput,
|
'fileFd' : fileFd }
|
</call>
|
<call function="'writeEndTagOperation'">
|
{'fileFd' : fileFd}
|
</call>
|
<return>cmdRC</return>
|
</sequence>
|
</function>
|
|
|
<!-- Backup function -->
|
<function name="backup" scope="local">
|
<function-prolog>
|
This function performs a backup in online or offline mode
|
</function-prolog>
|
<function-map-args>
|
<function-arg-def name="location" type="optional" default="'%s' % STAXServiceMachine">
|
<function-arg-description>
|
Location of target host
|
</function-arg-description>
|
<function-arg-property name="type" value="hostname"/>
|
</function-arg-def>
|
<function-arg-def name="dsPath" type="required">
|
<function-arg-description>
|
Pathname to installation root
|
</function-arg-description>
|
</function-arg-def>
|
<function-arg-def name="dsInstanceHost" type="optional">
|
<function-arg-description>
|
Directory server hostname or IP address
|
</function-arg-description>
|
<function-arg-property name="type" value="hostname"/>
|
</function-arg-def>
|
<function-arg-def name="dsInstancePort" type="optional">
|
<function-arg-description>
|
Directory server port number
|
</function-arg-description>
|
<function-arg-property name="type" value="hostname"/>
|
</function-arg-def>
|
<function-arg-def name="dsInstanceDn" type="optional">
|
<function-arg-description>
|
Bind DN
|
</function-arg-description>
|
<function-arg-property name="type" value="DN"/>
|
</function-arg-def>
|
<function-arg-def name="dsInstancePswd" type="optional">
|
<function-arg-description>
|
Bind password
|
</function-arg-description>
|
</function-arg-def>
|
<function-arg-def name="backEnd" type="optional" default="DIRECTORY_INSTANCE_BE">
|
<function-arg-description>
|
Optional the name of the database backend
|
</function-arg-description>
|
<function-arg-property name="type" value="string"/>
|
</function-arg-def>
|
<function-arg-def name="backupDir" type="required">
|
<function-arg-description>
|
The directory where the backup files will be placed
|
</function-arg-description>
|
<function-arg-property name="type" value="filename"/>
|
</function-arg-def>
|
<function-arg-def name="extraParams" type="optional" default="''">
|
<function-arg-description>
|
Optional extra parameters for specific test cases
|
</function-arg-description>
|
<function-arg-property name="type" value="string"/>
|
</function-arg-def>
|
<function-arg-def name="fileFd" type="required">
|
<function-arg-description>
|
output file descriptor
|
</function-arg-description>
|
</function-arg-def>
|
<function-arg-def name="startTask" type="optional">
|
<function-arg-description>
|
Start time for task
|
</function-arg-description>
|
<function-arg-property name="type" value="integer"/>
|
</function-arg-def>
|
</function-map-args>
|
|
<sequence>
|
|
<!-- Build the Command -->
|
<script>
|
STAFCmdParamsList=[]
|
STAFCmdParams=''
|
|
if dsPath:
|
dsBinPath='%s/bin' % (dsPath)
|
STAFCmd='%s/backup' % (dsBinPath)
|
|
if dsInstanceHost:
|
STAFCmdParamsList.append('-h %s' % dsInstanceHost)
|
|
if dsInstancePort:
|
STAFCmdParamsList.append('-p %s' % dsInstancePort)
|
|
if dsInstanceDn:
|
STAFCmdParamsList.append('-D "%s"' % dsInstanceDn)
|
|
if dsInstancePswd:
|
STAFCmdParamsList.append('-w "%s"' % dsInstancePswd)
|
|
if backupDir:
|
STAFCmdParamsList.append('-d %s' % backupDir)
|
|
if backEnd:
|
STAFCmdParamsList.append('-n %s' % backEnd)
|
|
if extraParams:
|
STAFCmdParamsList.append('%s' % extraParams)
|
|
if startTask:
|
STAFCmdParamsList.append('-t %s' % startTask)
|
|
STAFCmdParams=' '.join(STAFCmdParamsList)
|
</script>
|
|
<call function="'writeStartTagOperation'">
|
{ 'tagName' : 'Backup',
|
'fileFd' : fileFd }
|
</call>
|
<call function="'writeMessage'">
|
{ 'fileFd' : fileFd,
|
'content' : '%s %s' % (STAFCmd, STAFCmdParams)
|
}
|
</call>
|
|
<call function="'runCommand'">
|
{ 'name' : 'Backup Script',
|
'location' : location,
|
'command' : STAFCmd,
|
'arguments' : STAFCmdParams,
|
'path' : dsBinPath,
|
'fileFd' : fileFd
|
}
|
</call>
|
|
<call function="'writeEndTagOperation'">{'fileFd' : fileFd}</call>
|
|
<return>STAXResult</return>
|
</sequence>
|
</function>
|
|
|
</stax>
|