BPM, Workflow, and Case

BPM, Workflow, and Case

Come for answers. Stay for best practices. All we’re missing is you.

 View Only

Bulk Snapshot Deployment using Jython

  • 1.  Bulk Snapshot Deployment using Jython

    Posted 12 hours ago
    Edited by Muhammad Haris Khan 11 hours ago

    In IBM BAW, we can deploy multiple snapshots (at once) using a Jython script and a command prompt. The idea is to place all the snapshots in one folder and then execute the command to deploy all the snapshots in the folder. Follow the steps outlined below:

    1. Create a file deployBPMProcesses.py (with the code below) in any directory where BAW is installed
    2. Open the CMD (command prompt), change the directory to {BAW_Installation_Path}/profiles/{NodeProfileDirectory}/bin
    3. Example: E:/IBM/WebSphere/AppServer/profiles/Node1Profile/bin
    4. Use the command wsadmin.bat -lang jython -conntype SOAP -port {PortOfSOAPConnector} -host {HostOfBAWServer} -user {AdminUserName} -password {AdminUserPassword} -f {PathTo_deployBPMProcesses.py_File} {PathToDirectoryWhereSnapshotsArePlaced}
    5. Example: wsadmin.bat -lang jython -conntype SOAP -port 8881 -host wf1vbawap1u.dmn.nm1 -user bawadmin -password baw@Admin123 -f D:/Backup/Bulk_Deployment.py D:/Backup/deployments/snapshots
    6. In the above command, the last value (D:/Backup/deployments/snapshots) is a command line argument which is passed to line number 12 (sys.argv[0]) of the code below.

    The file name for the code below is deployBPMProcesses.py:

    # ==============================================================
    # Script: deployBPMProcesses.py
    # Purpose: Bulk deploy IBM BPM snapshots using wsadmin and AdminTask 
    # Usage: 
    #   wsadmin -lang jython -f deployBPMProcesses.py
    # ==============================================================
    
    # List of offline package files (.twx or .zip) with absolute paths 
    import os, sys
    
    # Directory containing snapshot .zip
    deployDir = sys.argv[0]
    
    print "\n=============================================================="
    print "     Starting Bulk BPM Snapshot Deployment from directory:" "
    print "     " + deployDir
    print "==============================================================\n"
    
    # Get all files ending with .zip or .twx
    snapshots = [f for f in os.listdir (deployDir) if f.endswith(".zip")]
    
    if len(snapshots) == 0:
        print "!!! No snapshot files found in directory: " + deployDir
        sys.exit(1)
    
    for snapshot in snapshots:
        fullPath = os.path.join(deployDir, snapshot)
        try:
            print ">>> Deploying snapshot: " + fullPath
            print AdminTask.BPMInstallOfflinePackage('[-inputFile "' + fullPath + '"]')
        except:
            print "!!! ERROR deploying snapshot: " + snapshot
            # Optionally print stack trace
            type, value, traceback = sys.exc_info()
            print "Exception: %s %s" % (type, value) 
            continue
            
    print "\n==============================================================" 
    print "     Deployment Completed for all Snapshots."
    print "     Please check the command prompt above " 
    print "     output for any possible errors. "
    print "==============================================================\n"
    Following is the example of the command execution and output of the command console:
    Example Output of Command Prompt


    ------------------------------
    Muhammad Haris Khan
    ------------------------------