Wednesday, November 7, 2012

wlst script for stopping the composites

Often it will be handy if we have a wlst script to stop and start the deployed composites. This will be useful if we have many composites to be switched off and on frequently

Keep the server details and the list of composites to be stopped in a properties file in a local directory - deploydirectory

CompositeList.properties
==================================



url=t3://localhost:7001
host=localhost
port=8001
username=weblogic
password=weblogic1


COMPOSITES=default/SampleCursorRef/1.0,default/AgToAGPollingTest/1.0,default/ReloadProcess/1.0


=================== end of compositeList.properties==============

Create a wlst script as follows

ShutdownComposite.py
====================

from java.io import FileInputStream

propInputStream = FileInputStream("D:\\tech\\wlst\\compositeList.properties")
configProps = Properties()
configProps.load(propInputStream)

url = configProps.get("url")
print 'url=', url
host = configProps.get("host")
print 'host=', host
port = configProps.get("port")
print 'port=', port
username = configProps.get("username")
print 'username=', username
password = configProps.get("password")
print 'password = ', password


print '========================'

COMPOSITES = configProps.get("COMPOSITES")
print 'COMPOSITES = ', COMPOSITES

compositeList=COMPOSITES.split(',')
print compositeList[1]
count = 0
for i in compositeList:
   compositeProps = compositeList[count].split("/")
   partition = compositeProps[0]
   compoisteName = compositeProps[1]
   version = compositeProps[2]
   print 'partition ..',partition
   print 'compoisteName ..',compoisteName
   print 'version ..',version
   print '========================'

   print 'trying to stop ',compoisteName
   try:
sca_stopComposite(host, port, username, password, compoisteName, version)
   except NameError, e:
print 'EXCEPTION OCCURED'
print "Please check there is: ", sys.exc_info()[0], sys.exc_info()[1]
   else:
print 'Stopped ',compoisteName
   count = count+1



============== end of StopComposites.py===============

open command prompt and start the wlst as follows


D:\Oracle\Middleware\Oracle_SOA1\common\bin>wlst.cmd

Run the script from wlst prompt as follows
execfile('D:\\tech\wlst\\ShutdownComposite.py')


Result
==============

========================
trying to stop  ReloadProcess
host = localhost
port = 8001
user = weblogic
partition = default
compositeName = ReloadProcess
revision = 1.0
label =  None
compositeDN =default/ReloadProcess!1.0
Connecting to: service:jmx:t3://localhost:8001/jndi/weblogic.management.mbeanservers.runtime
Composite (default/ReloadProcess!1.0) is successfully stopped.
Stopped  ReloadProcess





No comments:

Post a Comment