Execute wsadmin Script with UrbanCode Deploy

The WebSphere Application Server wsadmin tool provides the ability to automate configuration tasks for your environment . It supports a full range of product administrative activities such as configure and administer application servers, application deployment, and server runtime operations.

UrbanCode WAS Deploy plugin has a step called:  Execute wsadmin Script

Open the step:

choose the language between JACL and Jython and write your script into the Script Body.

Remove temp.py from Script Path

Below a few examples of jython WAS useful scripts:

  • Map Resource References
AdminApp.edit('${p:appName}', ['-MapResRefToEJB', [[ '.*', '.*', '.*', '.*', 'javax.sql.DataSource', '${p:environment/application_datasource}']]])
AdminConfig.save()
  • Change Web Module Virtual Host
AdminApp.edit('${p:appName}', [' -MapWebModToVH', [[ '.*', '.*', '${p:environment/virtualhost}']]])
AdminConfig.save()
  • Modify Module Starting Weight
deployments = AdminConfig.getid('/Deployment:${p:appName}/')
deploymentObject = AdminConfig.showAttribute(deployments, 'deployedObject')
myModules = AdminConfig.showAttribute(deploymentObject, 'modules')
myModules = myModules[1:len(myModules)-1].split(" ")
for module in myModules:
 tmpStr = AdminConfig.showAttribute(module,'uri')
 if tmpStr == 'name.war':
 AdminConfig.modify(module, [['startingWeight', '6500']])
 if tmpStr == 'name2.war':
 AdminConfig.modify(module, [['startingWeight', '7000']])
AdminConfig.save()
  • Map Resource Environment References
AdminApp.edit('${p:appName}', ['-MapResEnvRefToRes', [[ '.*', '.*', '.*', '.*', 'javax.sql.DataSource', '${p:environment/application_datasource}']]])
AdminConfig.save()
  • Change JSP and JSF options
AdminApp.edit('${p:appName}', '[ ]' )
AdminTask.modifyJSFImplementation('${p:appName}', '[-implName SunRI1.2]') 
AdminConfig.save()

Have a nice day!

Middleware Analyst specialized on IBM UrbanCode Deploy (uDeploy), WebSphere Application Server (WAS), WebSphere MQ (WMQ), *NIX systems at CSE Consorzio Servizi Bancari - Bologna, Italy

Leave a Reply

Your email address will not be published. Required fields are marked *

two × two =