<
function-
arg-
def name="dsPath" default="'%s/%s' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME)">
<
function-
arg-
description>
Pathname to installation root
</
function-
arg-
description>
<
function-
arg-
property name="type" value="filepath"/>
<
function-
arg-
def name="version" type="optional">
<
function-
arg-
description>
Display Directory Server version information
</
function-
arg-
description>
<
function-
arg-
property name="type" value="string"/>
<
function-
arg-
def name="templateFile" type="optional">
<
function-
arg-
description>
Path to the template file
</
function-
arg-
description>
<
function-
arg-
property name="type" value="filename"/>
<
function-
arg-
def name="ldifFile" type="optional">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="filename"/>
<
function-
arg-
def name="randomSeed " type="optional">
<
function-
arg-
description>
The seed to use to initialize the random number generator
</
function-
arg-
description>
<
function-
arg-
property name="type" value="integer"/>
<
function-
arg-
def name="Help" type="optional">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="help" value="option"/>
<!-- Build the Command --> dsBinPath='%s/%s' % (dsPath,fileFolder)
STAFCmdParams=' '.join(STAFCmdParamsList)
<
call function="'runCommand'">
{ 'name' : 'Make Ldif Script',
'arguments' : STAFCmdParams,
STAXCode, STAXReason=STAXResult
<
if expr="STAXCode != 0">
<
message level="'error'">
'make-ldif failed (Code=%s,Reason=%s).' % (STAXCode,STAXReason)
<
return>[STAXCode, STAXReason]</
return>
<!-- This function compares two LDIF files using the ldif-diff script --> <
function name="LdifDiffWithScript">
This function compares two LDIF files and reports the differences in LDIF format
<
function-
arg-
def name="location" default="STAF_REMOTE_HOSTNAME">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="hostname"/>
<
function-
arg-
def name="dsPath" default="'%s/%s' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME)">
<
function-
arg-
description>
Pathname to installation root
</
function-
arg-
description>
<
function-
arg-
property name="type" value="filepath"/>
<
function-
arg-
def name="version" type="optional">
<
function-
arg-
description>
Display Directory Server version information
</
function-
arg-
description>
<
function-
arg-
property name="type" value="string"/>
<
function-
arg-
def name="sourceLdif" type="required">
<
function-
arg-
description>
LDIF file to use as the source data
</
function-
arg-
description>
<
function-
arg-
property name="type" value="filepath"/>
<
function-
arg-
def name="targetLdif" type="required">
<
function-
arg-
description>
LDIF file to use as the target data
</
function-
arg-
description>
<
function-
arg-
property name="type" value="filepath"/>
<
function-
arg-
def name="outputLdif" type="required">
<
function-
arg-
description>
File to which the diffs should be written
</
function-
arg-
description>
<
function-
arg-
property name="type" value="filepath"/>
<
function-
arg-
def name="overwriteExisting" type="optional" default="True">
<
function-
arg-
description>
Overwrite existing output file rather than append to it
</
function-
arg-
description>
<
function-
arg-
property name="type" value="option"/>
<
function-
arg-
def name="singleValueChanges" type="optional">
<
function-
arg-
description>
Write each attribute-level change as a separate modification
per attribute value rather than one modification per entry
</
function-
arg-
description>
<
function-
arg-
property name="type" value="option"/>
<
function-
arg-
def name="Help" type="optional">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="help" value="option"/>
<!-- Build the Command --> dsBinPath='%s/%s' % (dsPath,fileFolder)
STAFCmdParams=' '.join(STAFCmdParamsList)
<
process name="'LDIF Diff Script'">
<
location>location</
location>
<
command>STAFCmd</
command>
<
parms>STAFCmdParams</
parms>
<
workdir>dsBinPath</
workdir>
['PATH=/bin:/
usr/
bin:%s' % dsBinPath, 'JAVA_HOME=%s' % JAVA_HOME]
<
stderr mode="'stdout'"/>
<
returnfile>outputLdif</
returnfile>
diffsInfo = STAXReason[1]
if (diffsInfo[0] == 0) and (
diffs.startswith("# No differences were detected between the source and target LDIF files")) :
<
return> diffRC </
return>
<!-- This function modifies an LDIF file using ldifmodify script --> <
function name="LdifModifyWithScript">
This function modifies an LDIF file with the changes contained in another LDIF file
<
function-
arg-
def name="location" default="STAF_REMOTE_HOSTNAME">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="hostname"/>
<
function-
arg-
def name="dsPath" default="'%s/%s' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME)">
<
function-
arg-
description>
Pathname to installation root
</
function-
arg-
description>
<
function-
arg-
property name="type" value="filepath"/>
<
function-
arg-
def name="version" type="optional">
<
function-
arg-
description>
Display Directory Server version information
</
function-
arg-
description>
<
function-
arg-
property name="type" value="string"/>
<
function-
arg-
def name="sourceLdif" type="required">
<
function-
arg-
description>
LDIF file containing the data to be updated
</
function-
arg-
description>
<
function-
arg-
property name="type" value="filepath"/>
<
function-
arg-
def name="targetLdif" type="required">
<
function-
arg-
description>
LDIF file that will contain the updated data
</
function-
arg-
description>
<
function-
arg-
property name="type" value="filepath"/>
<
function-
arg-
def name="changesLdif" type="required">
<
function-
arg-
description>
LDIF file containing the changes to apply
</
function-
arg-
description>
<
function-
arg-
property name="type" value="filepath"/>
<
function-
arg-
def name="Help" type="optional">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="help" value="option"/>
<!-- Build the Command --> dsBinPath='%s/%s' % (dsPath,fileFolder)
STAFCmdParams=' '.join(STAFCmdParamsList)
<
call function="'runCommand'">
{ 'name' : 'LDIF Modify Script',
'arguments' : STAFCmdParams,
<
return>STAXResult</
return>
<
function name="verifyTrees">
This function verifies that the trees in a group of ldap servers are synchronized.
<
function-
arg-
def name="location" default="STAF_REMOTE_HOSTNAME">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="hostname"/>
<
function-
arg-
def name="dsPath" default="'%s/%s' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME)">
<
function-
arg-
description>
Pathname to installation root
</
function-
arg-
description>
<
function-
arg-
property name="type" value="filepath"/>
<
function-
arg-
def name="referenceServer" type="required">
<
function-
arg-
description>
Server that should be taken as reference.
</
function-
arg-
description>
<
function-
arg-
property name="type" value="Server"/>
<
function-
arg-
def name="serverList" type="required">
<
function-
arg-
description>
List of the servers to verify against the referenceServer.
</
function-
arg-
description>
<
function-
arg-
property name="type" value="Server-list"/>
<
function-
arg-
def name="treeSuffix" type="required">
<
function-
arg-
description>
Suffix of the tree to verify.
</
function-
arg-
description>
<
function-
arg-
property name="type" value="DN"/>
'Verify tree %s taking %s as reference.' % (treeSuffix, referenceServerPath)
<!-- Retrieve the tree from the reference server --> <
call function="'ldapSearchWithScript'">
'dsFilter' : 'objectclass=*',
'outputFile' : referenceTree
<!-- If the reference tree could not be retrieved, return an error --> <
return> [1, None] </
return>
<
iterate var="server" in="serverList">
<!-- Retrieve the same tree for every other server in the list --> <
call function="'ldapSearchWithScript'">
'dsFilter' : 'objectclass=*',
'outputFile' : sampleTree
<!-- Compare this tree to the reference one --> <
call function="'LdifDiffWithScript'">
'sourceLdif' : '%s/../%s' % (dsPath, sampleTree),
'targetLdif' : '%s/../%s' % (dsPath, referenceTree),
'outputLdif' : '%s/../%s' % (dsPath, treeDiffs)
<
if expr="len(failedServers) > 0">
<!-- If at least one server failed to successfully compare to the reference tree, ! return an error, along with the list of the servers that failed to do so --> failingServerList = 'List of non-synchronized servers (tree verify FAILED): %s ' %
comma.join(failedServers)
'All servers synchronized (tree verify SUCCEEDED).'
<
call function="'checktestRC'">
'result' : failingServerList,
<
return>[myRC, failedServers]</
return>
<
function name="verifySchemas">
This function verifies that a schema file is synchronized all over a group of servers.
<
function-
arg-
def name="location" default="STAF_REMOTE_HOSTNAME">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="hostname"/>
<
function-
arg-
def name="dsPath" default="'%s/%s' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME)">
<
function-
arg-
description>
Pathname to installation root
</
function-
arg-
description>
<
function-
arg-
property name="type" value="filepath"/>
<
function-
arg-
def name="referenceServer" type="required">
<
function-
arg-
description>
Server that should be taken as reference.
</
function-
arg-
description>
<
function-
arg-
property name="type" value="Server"/>
<
function-
arg-
def name="serverList" type="required">
<
function-
arg-
description>
List of the servers to verify against the referenceServer.
</
function-
arg-
description>
<
function-
arg-
property name="type" value="Server-list"/>
<
function-
arg-
def name="schemaFile" type="required">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="filename"/>
referenceSchema = '%
s/
config/
schema/%s' % (referenceServerPath, schemaFile)
'Verify schema file %s taking %s as reference.' % (schemaFile, referenceServerPath)
<
iterate var="server" in="serverList">
<!-- Copy reference schema file to other server --> <
call function="'copyFile'">
'srcfile' : referenceSchema,
<!-- Compare this schema to the reference one --> <
call function="'LdifDiffWithScript'">
<
if expr="len(failedServers) > 0">
<!-- If at least one server failed to successfully compare to the reference tree, ! return an error, along with the list of the servers that failed to do so --> failingServerList = 'List of non-synchronized servers (schema verify FAILED): %s ' %
comma.join(failedServers)
'All servers synchronized (schema verify SUCCEEDED).'
<
call function="'checktestRC'">
'result' : failingServerList ,
<
return>[myRC, failedServers]</
return>
<
function name="deleteTrees">
This function deletes a (sub)tree from a list of servers.
<
function-
arg-
def name="serverList" type="required">
<
function-
arg-
description>
List of the servers (instances of "Server" class) where the tree will be deleted.
</
function-
arg-
description>
<
function-
arg-
property name="type" value="Server-list"/>
<
function-
arg-
def name="treeSuffix" type="required">
<
function-
arg-
description>
Suffix of the tree to delete.
</
function-
arg-
description>
<
function-
arg-
property name="type" value="DN"/>
<
function-
arg-
def name="startDS" type="optional" default="True">
<
function-
arg-
description>
Need to start the Directory Servers before deleting.
</
function-
arg-
description>
<
function-
arg-
property name="type" value="boolean"/>
<!-- Start the servers in the list --> <
call function="'startServers'">
<!-- Delete the tree in every server in the list --> <
paralleliterate var="server" in="serverList">
<!-- Delete suffix and subtree --> <
call function="'ldapDeleteWithScript'">
<!-- Stop the servers in the list --> <
call function="'stopServers'">
<
function name="startServers">
This function starts a list of servers.
<
function-
arg-
def name="serverList" type="required">
<
function-
arg-
description>
List of the servers (instances of "Server" class) to be started.
</
function-
arg-
description>
<
function-
arg-
property name="type" value="Server-list"/>
<!-- Start the servers in the list --> <
paralleliterate var="server" in="serverList">
<
call function="'StartDsWithScript'">
<!--- Check that DS started --> <
call function="'isAlive'">
'noOfMilliSeconds' : 2000
<
function name="stopServers">
This function stops a list of servers.
<
function-
arg-
def name="serverList" type="required">
<
function-
arg-
description>
List of the servers (instances of "Server" class) to be stopped.
</
function-
arg-
description>
<
function-
arg-
property name="type" value="Server-list"/>
<!-- Stop the servers in the list --> <
paralleliterate var="server" in="serverList">
<
call function="'StopDsWithScript'">
<
function name="CLI_rebuild-index">
This wraps the rebuild-index tool to make it easy to use from STAX
<
function-
arg-
def name="location" type="optional" default="STAF_REMOTE_HOSTNAME">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="hostname"/>
<
function-
arg-
def name="dsPath" type="optional" default="'%s/%s' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME)">
<
function-
arg-
description>
Pathname to installation root
</
function-
arg-
description>
<
function-
arg-
property name="type" value="filepath"/>
<
function-
arg-
def name="baseDN" type="required">
<
function-
arg-
description>
Specify a back-end supporting indexing and triggers a rebuild of all
indexes in the scope of the provided baseDN
</
function-
arg-
description>
<
function-
arg-
def name="attributes" type="required">
<
function-
arg-
description>
Specify a list of attributes to trigger index rebuild on
This should be passed on as a python array like
[ 'uid', 'telephonenumber' ]
</
function-
arg-
description>
dsBinPath='%s/%s' % (dsPath,fileFolder)
_args=' -b %s -i %s' % ( baseDN, ' -i '.join(attributes) )
<
call function="'runCommand'">
{ 'name' : 'rebuild index',
<
return>STAXResult</
return>
<
function name="CLI_verify-index">
This wraps the verify-index tool to make it easy to use from STAX
<
function-
arg-
def name="baseDN" type="required">
<
function-
arg-
description>
Specify a back-end supporting indexing and triggers a verification of all
indexes in the scope of the provided baseDN
</
function-
arg-
description>
<
function-
arg-
def name="attributes" type="required">
<
function-
arg-
description>
Specify a list of attributes to trigger index verification on
This should be passed as a python array like
[ 'uid','telephonenumber' ]
</
function-
arg-
description>
<
function-
arg-
def name="clean" type="optional">
<
function-
arg-
description>
Specify a list of attributes to trigger index verification on
</
function-
arg-
description>
dsBinPath='%s/%s' % (dsPath,fileFolder)
_args=' -b %s -i %s' % ( baseDN, ' -i '.join(attributes) )
<
call function="'runCommand'">
{ 'name' : 'verify index',
<
return>STAXResult</
return>