WebLogic Scripting Tool, or WLST, is a command line utility that enables you to fully configure and control WebLogic Server – as much, and more, than you can do through the web-based WebLogic console. You might think of it as the SQL*Plus equivalent for WebLogic but in many respects it’s much more powerful as you have the full Python programming language at your disposal. It allows you to do the simple, but handy, tasks like starting a server and creating data sources, right through to creating clusters and building a complete domain. These commands can then be used to automate WebLogic administration, saving time, ensuing consistency and reducing risk.
This presentation was delivered serveral times around 2010-2012, including this time on the 2012 Nordic ACE Director Tour.
2. Simon Haslam
Consultant/founder of Veriton & co-founder O-box
FMW infra: high availability, security, performance
Chair of UKOUG Middleware SIG
Middleware focus, but interested from hardware upwards
3. What is WLST?
WLST & Management Beans Overview
Language Features
4. WLST Overview
Jython = Python running on JVM
JMX are management APIs for
Java (implemented as Mbeans)
WLST provides front-end to JMX
◦ a little like ‘SQL*Plus for WebLogic’
Since 12c admin functions
possible over RESTful interface
WebLogic
MBeans
Jython
WebLogic
extensions WLST
REST
5. Getting started
Usually connect to Admin Server ‘online’
Run wlst.sh [.cmd] or use Windows short-cut
◦ connect(<username>,<password>,<url>)
6. What is WLST?
WLST & Management Beans Overview
Language Features
7. Management Beans Overview
All WebLogic servers
◦ Runtime WebLogic MBeans
◦ JVM MBeans
Admin Server only
◦ Domain Runtime MBeans
◦ “edit” MBeans
8. System Change Management
edit()
startEdit()
save()
activate() <= prod. mode releases lock
◦ or undo()
Configuration lock held by user (not tool) so WLST startEdit will
show that the domain is being edited in the WLS console
11. Online & Offline
Online – connecting to Admin Server over JMX which
in turn updates config.xml etc
Offline – using WLST libraries that updates config.xml
directly Never connect offline if
the Admin Server is
running!
12. Online vs Offline
Pros & Cons:
◦ Offline can do before domain is running, against shared dir from a different server etc
◦ Online has more features available
If you’re doing a full build you’re probably best doing the base domain
offline to give you enough to start up a secure AdminServer then do the rest
online (IMO!)
You may want to use WLST scripts/libraries after the domain is live too,
hence good to write for online usage
16. Procedures & Libraries
Order is important – procedures/functions must
have been defined before use
Indentation is used to show nesting (not {})
One approach for ‘libraries’ is:
execfile('fmw_utilities.py')
17. Loops
for I in range(1, 100):
print I
...
While I = ‘something’:
print J
...
18. Conditions
if <condition> == <value> :
e.g.
if server == ‘AdminServer’:
print ‘Skipping’
else:
print ‘Doing something’
Not a great example –
you wouldn’t usually
test based on name
19. Parameter Parsing (simple)
Use argv[n]
import sys
# script takes a single parameter for properties file
try:
loadProperties(sys.argv[1]);
except:
sys.exit('ERROR! Usage: '+sys.argv[0]+' <properties-
file>n');
...
20. Parameter Parsing (flexible)
Use getopt
import sys, getopt
def usage():
print "Usage: setup_cluster.py -u adminuser -c
password -t protocol -a adminserver -p port -s start_range
-e number_of_ips_to_check"
23. Passwords / encryption
When you record you’ll get:
setEncrypted('Password', 'Password_456…',
‘…/Script456…Config', ‘…/Script456…Secret')
You probably want something more visible, e.g.
cmo.setPassword( encrypt(APP_PASS,
DOMAIN_BASE+'/'+DOMAIN_NAME) )
cmo.setCustomIdentityKeyStorePassPhraseEncrypted(
encrypt(SSL_IDENTITY_PASS, DOMAIN_BASE+'/'+DOMAIN_NAME) )
24. Invocation
CLASS_PATH, esp some layered products
Slower first time
Maybe write a cleaner wrapper script of your own
(If you’re clever you might embed WLST in Java progs)
25. Tools
Text editors
◦ vi (of course)
◦ Notepad++ has syntax highlighting for .py by default
◦ Sublime Text has syntax highlighting for .py
Recently discovered: WLST plug-in with tab/code completion:
https://github.com/Joelith/sublime-wlst
WLS Console recording function
Oracle Enterprise Pack for Eclipse
◦ Modern IDE supporting WLST project etc