DPBuddy Examples

You can view detailed examples using the the links below or just browse simple examples of DPBuddy’s usage directly on this page. For a complete set of sample files and to be able to run the samples, download DPBuddy and use the files located under the “samples” directory in the distribution.

DataPower Configuration Import

Import a zip file and save the domain’s configuration.

CLI:

dpbuddy import -file dpconfigs/WSProxy.zip -save

Ant:

<dp:import file="${wsproxy.zip.file}" save="true" />

Create a checkpoint before importing the file, perform the import, validate that all services are up and running, rollback to the checkpoint on failure. For the objects that are in the “down” state, DPBuddy will pull and display log entries containing errors.

CLI:

dpbuddy import -file dpconfigs/WSProxy.zip -checkpoint before-import -assertObjectsUp -rollbackOnError

Ant:

<dp:buddyImport file="${wsproxy.zip.file}" checkpoint="before-import" assertObjectsUp="true" rollbackOnError="true"/>

Quiesce the domain before importing the file, perform the import, validate that all services are up and running, un-quiesce the domain.

CLI:

dpbuddy import -file dpconfigs/WSProxy.zip -quiesce -assertObjectsUp  -unquiesce

Ant:

<dp:buddyImport file="${wsproxy.zip.file}" quiesce="true" assertObjectsUp="true" unquiesce="true"/>

Resolve template variables before the import, update domain comments after the import.

CLI:

dpbuddy import -file dpconfigs/WSProxy.zip -resolveVars -domainComments "release-1.0.1"

Ant:

<dp:buddyImport file="${wsproxy.zip.file}" resolveVars="true" domainComments="release-1.0.1"/>

More import examples.

Change the HTTP handler’s port during import:

<dp:import file="${wsproxy.zip.file}" >
    <transform>
        <setText xpath="//*[@name='TestHTTPHandler']/LocalPort" 
            value="${ws.port}" />
    </transform>
</dp:import>

More configuration transformation examples.

Verify that the ports are actually open on the device. This will also display a report containing the list of all active services.

CLI:

dpbuddy assertOpenPorts -ports="9090, 5550" -domain default

Ant:

<dp:assertOpenPorts ports="9090, 5550" domain="default" />

More state/status verification examples.

Working with Files

Upload all files matched by nested filesets to DataPower and create the necessary directories. “cleanDirectories” forces deletion of existing directories. “flushCache” clears documents/stylesheet cache after the upload:

dpbuddy copy -toDir wsdlDir -includes "dpfiles/**/*.wsdl" -cleanDirectories -flushCache

“dp:copy” Ant task provides more flexibility. “dpFileset” supports all the attributes and nested elements of the regular Ant fileset. “dpFileset” also supports the nested “transform” element which makes changes to the uploaded files on the fly.

<dp:copy cleanDirectories="true" toDir="${dp.wsdl.dir}" >
    <!-- Note how "doDir" can be overridden at the fileset level -->
    <dpFileset toDir="/xsd" dir="${dpfiles.home}" excludes="**/*.wsdl" />
    <dpFileset dir="${dpfiles.home}" includes="**/PersonService.wsdl">
        <transform> 
            <setText xpath="${location.xpath}" value="${person.service.backend.url}" />
        </transform>
    </dpFileset>
    <dpFileset dir="/invalidDir" includes="**/PersonService.wsdl" 
        errorOnMissingDir="false" matchRequired="false"/>
</dp:copy>

Download files from the “wsdl” directory on DataPower to the “download” folder.

CLI:

dpbuddy download -include "local:/wsdl/.*" -toDir download -flatten -cleanToDir

Ant:

<dp:download include="local:/wsdl/.*" toDir="download"
    flatten="true" cleanToDir="true" />

Delete all xsd files from the “local” file system on DataPower if such files exist:

CLI:

dpbuddy delete -include "local:/.*\.xsd" -matchRequired false

Ant:

<dp:delete include="local:/.*\.xsd" matchRequired="false"/>

More file management examples.

DataPower Configuration Export

Export all XML firewalls and WS proxy objects. This command will also automatically remove the Base64-encoded files embedded inside the configuration file. Additionally, it will format the resulting file using proper indentation:

dpbuddy export -file services.xml -persisted -classPattern "(WSGatew.*|.*Firewall.*)"

“dp:export” Ant task supports on-the-fly transformation of the exported objects. For example, we can remove the default user agents and XML managers from the exported configuration:

<dp:export file="Services.xml">
    <exportObject class="(XMLFirewall.*|WSGatew.*)"/>
    <transform>
        <dpExclude class="(HTTPUserAgent|XMLManager)" name="default"/>
    </transform>
</dp:export>

More configuration export examples.

Modification and Deletion of DataPower Configuration

Add or modify a load-balancing group member:

<dp:modifyConfig save="true">
    <configuration>
        <LoadBalancerGroup name="${lbg.name}">
            <LBGroupMembers>
                <Server>${server.name}</Server>
                <Weight>1</Weight>
                <MappedPort>0</MappedPort>
                <Activity/>
                <HealthPort>0</HealthPort>
                <LBMemberState>enabled</LBMemberState>
            </LBGroupMembers>
        </LoadBalancerGroup>
    </configuration>
</dp:modifyConfig>

More configuration modification examples.

Delete all WS proxy objects whose names begin with “test”.

CLI:

dpbuddy delConfig -quiet -classPattern WSGateway -namePattern "test.*"

Ant:

<dp:delConfig quiet="true">
    <object class="WSGateway" name="test.*" />
</dp:delConfig>

Quiescence

Quiesce all WS proxy objects.

CLI:

dpbuddy quiesce -classPattern WSGateway

Ant:

<dp:quiesce>
    <object class="WSGateway" />
</dp:quiesce>

More quiescence examples.

Backup

Perform secure backup and download the resulting files to a local folder called “backups”.

CLI:

dpbuddy secureBackup -cert crypto-backup-test -toDir testfiles/sbackup  -appendTimestamp -dpDir "temporary:/secure-backup"

Ant:

<dp:secureBackup cert="crypto-backup-test" toDir="./backups" 
    includeISCSI="false" includeRAID="false"  appendTimestamp="true" 
    dpDir="temporary:/secure-backup"/>

More backup examples.

Miscellaneous Tasks

Flush the stylesheet and document caches.

CLI:

dpbuddy flushStylesheetCache
dpbuddy flushDocumentCache -xmlManager "def.*"
dpbuddy flushXMLCache

Ant:

<!-- Flush stylesheets for all XML managers -->
<dp:flushStylesheetCache/>
<!-- Flush documents for the default XML manager -->
<dp:flushDocumentCache xmlManager="def.*"/>
<!-- Flush both documents and stylesheets for all XML managers -->
<dp:flushXMLCache/>

More cache-related examples.

Create a checkpoint and save the configuration.

CLI:

dpbuddy checkpoint -name release-1.0.1  -save

Ant:

<dp:checkpoint name="release-1.0.1" save="true"/>

Rollback to the last checkpoint.

CLI:

dpbuddy rollback

Ant:

<dp:rollback/>

More checkpoint-related examples.

Reset the domain.

CLI:

dpbuddy resetDomain

Ant:

<dp:resetDomain/>

Continuously tail the DataPower log (as in “tail -f”), stop in case of errors.

CLI:

dpbuddy tail -f -failPatterns "\|[E|W]\|"

Ant:

<dp:tailLog  failPatterns="\|[E]\|" follow="true" />

You can also grep logs residing on DataPower:

dpbuddy tail -f | grep  "\|[E|W]\|"

More log-related examples.

Sync WSRR subscription:

<dp:wsrrSynchronize subscription="testSubscription" />