This is a screen snapshot of recording to generate WLST script.
Once generated, the script can be augmented to suit our needs.
For instance, I created a set of managed servers and added them to a cluster through Admin console.
The generated script (say sample.py) would look like:
startEdit()
cd('/')
cmo.createServer('managed1')
cd('/Servers/managed1')
cmo.setListenAddress('')
cmo.setListenPort(7003)
cd('/')
cmo.createCluster('testcluster')
cd('/Clusters/testcluster')
cmo.setClusterMessagingMode('unicast')
cmo.setClusterBroadcastChannel('')
cd('/Servers/managed1')
cmo.setCluster(getMBean('/Clusters/testcluster'))
activate()
startEdit()
cd('/')
cmo.createServer('managed2')
cd('/Servers/managed2')
cmo.setListenAddress('')
cmo.setListenPort(7005)
cmo.setCluster(getMBean('/Clusters/testcluster'))
activate()
startEdit()
We can augment the script by adding following actions:
1) Connect to Admin Server
2) Start a change session
3) < Add the generated WLST code >
4) Disconnect from Admin Server
5) Exit WLST
This would look like:
# connect to Admin Server(username being "system" and password "weblogic" and url localhost:7001)
connect(system,weblogic,t3://localhost:7001)
edit()
< Add the generated WLST code >
disconnect()
exit()
Now the script can be called either from shell script or ant.
Here is how you call from shell script.
I learnt this from David's blog.
#!/bin/ksh
Running wlst script through ant is documented at http://e-docs.bea.com/wls/docs100/config_scripting/using_WLST.html#wp1093337
Another posting I found useful was to automate tasks like creating domain by reading a CSV file in WLST.
Check out Bala's blog for this and other WLST related features.
No comments:
Post a Comment