NOTE: This is not advisable to do in a Production environment since the uninstall part will force delete all process instances (even the running ones).
In using the following set of scripts the following are assumed:
- The installation and profile directory are standardized across the physical machines where the BPM nodes are residing
- It is assumed that the applications are deployed in the AppTarget cluster
- A installableApp directory is created and the EAR files to install are located there
The first script is your shell script for the Linux server. This script will force uninstall existing applications using the bpcTemplates.jacl. Once all the applications specified in your properties file are uninstalled, it will then run the install.py jython script with your wsadmin. You should place this file in the same directory as the two other scripts. Note that I didn't use file checking to verify if the files exist.
Filename: deploy.sh
The second script is the jython script that
Filename: install.py
The last file is the properties file used in the shell script as well as in the jython script. This is where you specify the installableApps directory, the applications to be deployed, the name of the nodes, and the name of the apptarget cluster.
Filename: deployment.properties
Now, finally, you need to execute deploy.sh in your Linux terminal. What we're doing here is just a basic uninstall, install, and start of applications. In some cases, you may wish to modify the endpoint bindings of imports (I guess I can post another blog for this) or remap the security roles per application.
Lastly, I haven't really tested the above scripts. I have a working script that I actually use and but, of course, I can't post it here. If you encounter any problem with the script, just let me know!
Happy Coding!
#!/bin/ksh # --- MODIFY --- # install_root=/opt/IBM/WebSphere/ProcServer profile_root=/opt/IBM/profiles/BPMDmgr deployer_root=/opt/IBM/deployer # --- DO NOT MODIFY --- # wsadmin=$profile_root/bin/wsadmin.sh bpc_templates=$install_root/ProcessChoreographer/admin/bpcTemplates.jacl install_py=$deployer_root/install.py deployment_props=$deployer_root/deployment.properties # NO CHECKING WILL BE PERFORMED IF THE ABOVE FILES EXIST. IT IS ASSUMED THAT THEY DO. # . $deployment_props IFS="," set -A installable_app $installable_apps # UNINSTALL APPS count=${#installable_app[@]} for app in ${installable_app[@]} do echo "INFO: Uninstall enterprise application: $app" if [ $1 ] && [ $2 ] then $wsadmin -f $bpc_templates -uninstall $app -force -username $1 -password $2 else $wsadmin -f $bpc_templates -uninstall $app -force fi done # INSTALL AND START APPS echo "INFO: Install and start application/s: $installable_apps" if [ $1 ] && [ $2 ] then $wsadmin -lang jython -f $install_py $deployment_props -username $1 -password $2 else $wsadmin -lang jython -f $install_py $deployment_props fi # --- END CODE --- #
The second script is the jython script that
wsadmin
will use to install and start the applications. Using the properties file, it will identify what applications to install into which cluster. This script also saves and synchronizes the changes to all the nodes specified in your properties file.Filename: install.py
import java.util as util import java.io as javaio import java.lang.System as javasys import time import sys # LOAD properties file properties = util.Properties() propertiesfis = javaio.FileInputStream(sys.argv[0]) properties.load(propertiesfis) nodeNames=properties.getProperty('node_names').split(',') installableApps=properties.getProperty('installable_apps').split(',') installationDir=properties.getProperty('installableApps_dir') cluster=properties.getProperty('apptarget_cluster') dotExtension='.ear' # Install applications for installableApp in installableApps: print 'Installing ' + installableApp + '...' AdminApp.install(installationDir + installableApp + dotExtension, ['-appname', installableApp, '-cluster', cluster]) #endFor AdminConfig.save() # Synchronize nodes for nodeName in nodeNames: print 'Sync ' + nodeName + ' node...' AdminControl.invoke(nodeName, 'sync') #endFor # --- # You can insert other steps here like import binding and security role re-map # If you do add steps here, make sure you save and synchronize # --- # Start applications lineSeparator = sys.getProperty('line.separator') members = AdminConfig.getid('/ServerCluster:' + cluster +'/ClusterMember:/').split(lineSeparator) for member in members: serverName = AdminConfig.showAttribute(member, 'memberName') appManager = AdminControl.queryNames('process='+serverName+',type=ApplicationManager,mbeanIdentifier=ApplicationManager,*').split(lineSeparator) for mgr in appManager: if (mgr != ''): for installableApp in installableApps: print 'Starting application ' + installableApp + '...' AdminControl.invoke(mgr, 'startApplication', installableApp) #endFor #endIf #endFor #endFor
The last file is the properties file used in the shell script as well as in the jython script. This is where you specify the installableApps directory, the applications to be deployed, the name of the nodes, and the name of the apptarget cluster.
Filename: deployment.properties
# Directory where your apps to be installed are located installableApps_dir=/opt/IBM/installableApps/ # installable_apps=, , ... installable_apps=BalanceInquiryApp,ChargingApp # Node names (List down all federated nodes) node_names=BPMNode01,BPMNode02 # AppTarget cluster apptarget_cluster=SOA.AppTarget # You can add aditional properties like endpoint binding properties or security role mapping
Now, finally, you need to execute deploy.sh in your Linux terminal. What we're doing here is just a basic uninstall, install, and start of applications. In some cases, you may wish to modify the endpoint bindings of imports (I guess I can post another blog for this) or remap the security roles per application.
Lastly, I haven't really tested the above scripts. I have a working script that I actually use and but, of course, I can't post it here. If you encounter any problem with the script, just let me know!
Happy Coding!
No comments:
Post a Comment