| | |
| | | |
| | | </sequence> |
| | | </function> |
| | | |
| | | <!-- This function compares two LDIF files using the ldif-diff script --> |
| | | <function name="LdifDiffWithScript-old"> |
| | | <function-prolog> |
| | | This function compares two LDIF files and reports the differences in LDIF format |
| | | </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="optional" |
| | | default="'%s/%s' % (DIRECTORY_INSTANCE_BIN,OPENDSNAME)"> |
| | | <function-arg-description> |
| | | Pathname to installation root |
| | | </function-arg-description> |
| | | <function-arg-property name="type" value="filepath"/> |
| | | </function-arg-def> |
| | | |
| | | <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> |
| | | |
| | | <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> |
| | | |
| | | <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> |
| | | |
| | | <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> |
| | | |
| | | <function-arg-def name="ignoreAttrsFile" |
| | | type="optional" |
| | | default="None"> |
| | | <function-arg-description> |
| | | File containing a list of attributes to ignore when computing the |
| | | difference |
| | | </function-arg-description> |
| | | <function-arg-property name="type" value="filepath"/> |
| | | </function-arg-def> |
| | | |
| | | <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> |
| | | |
| | | <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> |
| | | |
| | | <function-arg-def name="Help" type="optional"> |
| | | <function-arg-description> |
| | | Help option |
| | | </function-arg-description> |
| | | <function-arg-property name="help" value="option"/> |
| | | </function-arg-def> |
| | | |
| | | </function-map-args> |
| | | <sequence> |
| | | <!-- Build the Command --> |
| | | <script> |
| | | foldersToCreate = [] |
| | | STAFCmdParamsList=[] |
| | | STAFCmdParams='' |
| | | |
| | | if dsPath: |
| | | dsBinPath='%s/%s' % (dsPath,fileFolder) |
| | | STAFCmd='%s/ldif-diff%s' % (dsBinPath,fileExt) |
| | | |
| | | if version: |
| | | STAFCmdParamsList.append('-V') |
| | | |
| | | if sourceLdif: |
| | | STAFCmdParamsList.append('-s %s' % sourceLdif) |
| | | |
| | | if targetLdif: |
| | | STAFCmdParamsList.append('-t %s' % targetLdif) |
| | | |
| | | if outputLdif: |
| | | foldersToCreate.append(os.path.dirname(outputLdif)) |
| | | STAFCmdParamsList.append('-o %s' % outputLdif) |
| | | |
| | | if ignoreAttrsFile: |
| | | STAFCmdParamsList.append('-a %s' % ignoreAttrsFile) |
| | | |
| | | if overwriteExisting: |
| | | STAFCmdParamsList.append('-O') |
| | | |
| | | if singleValueChanges: |
| | | STAFCmdParamsList.append('-S') |
| | | |
| | | if Help: |
| | | STAFCmdParamsList.append('-H') |
| | | |
| | | STAFCmdParams=' '.join(STAFCmdParamsList) |
| | | </script> |
| | | |
| | | <call function="'createMultiFolders'"> |
| | | { 'location' : location, |
| | | 'folderslist' : foldersToCreate |
| | | } |
| | | </call> |
| | | |
| | | <message> |
| | | '%s %s' % (STAFCmd, STAFCmdParams) |
| | | </message> |
| | | |
| | | <process name="'LDIF Diff Script'"> |
| | | <location>location</location> |
| | | <command>STAFCmd</command> |
| | | <parms>STAFCmdParams</parms> |
| | | <workdir>dsBinPath</workdir> |
| | | <envs> |
| | | ['PATH=/bin:/usr/bin:%s' % dsBinPath, 'JAVA_HOME=%s' % JAVA_HOME] |
| | | </envs> |
| | | <console use="'same'"/> |
| | | <stderr mode="'stdout'"/> |
| | | <returnstdout/> |
| | | </process> |
| | | |
| | | <script> |
| | | STAXCode=RC |
| | | </script> |
| | | <if expr="STAXCode == 0"> |
| | | <sequence> |
| | | <!-- Check the size of the diff file, and avoid reading its |
| | | content with getFile if the file is too big to prevent |
| | | the staf process from running out of memory --> |
| | | <call function="'GetEntry'"> |
| | | { |
| | | 'location' : location, |
| | | 'entry' : outputLdif, |
| | | 'attribute' : 'SIZE' |
| | | } |
| | | </call> |
| | | <script> |
| | | # GetEntry returns: STAXResult = [cmdRC, cmdResult] |
| | | if RC == 0: |
| | | diffsFileSize = int(STAXResult[1]['lowerSize']) |
| | | msg = 'File: %s Size (bytes): %s' % (outputLdif, diffsFileSize) |
| | | else: |
| | | diffsFileSize = MAX_READABLE_SIZE |
| | | msg = 'Could not retrieve the size of file %s' % outputLdif |
| | | </script> |
| | | <message log="1"> 'LdifDiffWithScript: %s' % msg </message> |
| | | <if expr="diffsFileSize < MAX_READABLE_SIZE"> |
| | | <sequence> |
| | | <call function="'getFile'"> |
| | | { 'location' : location, |
| | | 'filename' : outputLdif |
| | | } |
| | | </call> |
| | | <script> |
| | | # getFile returns: STAXResult = [cmdRC, cmdResult] |
| | | diffsFileContent = STAXResult[1] |
| | | |
| | | if diffsFileContent.startswith("# No differences were detected between the source and target LDIF files") : |
| | | diffRC = 0 |
| | | else: |
| | | diffRC = 1 |
| | | </script> |
| | | </sequence> |
| | | <else> |
| | | <script> |
| | | # diffs file to big to be read |
| | | diffsFileContent = 'File too big to be read.' |
| | | |
| | | # if the diff file is too big, it means that there ARE |
| | | # actually some diffs, so we may deduce diffRC = 1 |
| | | diffRC = 1 |
| | | </script> |
| | | </else> |
| | | </if> |
| | | </sequence> |
| | | <else> |
| | | <sequence> |
| | | <message log="1" level="'Error'"> |
| | | 'LdifDiffWithScript: command run FAILED.' |
| | | </message> |
| | | <return> -1 </return> |
| | | </sequence> |
| | | </else> |
| | | </if> |
| | | |
| | | <if expr="diffRC == 0"> |
| | | <message log="1"> |
| | | 'NO DIFFERENCES were detected between the source and the target \ |
| | | LDIF files.' |
| | | </message> |
| | | <else> |
| | | <message log="1" level="'Error'"> |
| | | 'Source and target LDIF files are DIFFERENT: \n\n%s' % \ |
| | | diffsFileContent |
| | | </message> |
| | | </else> |
| | | </if> |
| | | |
| | | <return> diffRC </return> |
| | | </sequence> |
| | | </function> |
| | | |
| | | <!-- This function modifies an LDIF file using ldifmodify script --> |
| | | <function name="LdifModifyWithScript"> |