Record and Play your WebLogic Console Tasks Like a DVR
By james.bayer on Apr 07, 2010
Today on the Oracle internal mailing list for WebLogic Server questions someone asked how to automate the configuration of the thread model for WebLogic Server and they were having trouble with the jython scripting syntax. I’ve previously written about this feature called Work Managers and the associated constraints. However, I did not show how to automate the process of configuring this without the console using WebLogic Scripting Tool – the jython scripting automation environment abbreviated as WLST. I’ve written some very basic introductions to WLST before and there is also an Oracle By Example on the subject, but this is a bit more advanced. Fear not because there is a really easy-to-use feature of the WLS console that lets you “Record” user actions just like a DVR. Using these recordings of the web-based console, you can easily create a script even if you are unfamiliar with the WLST syntax and API. I’m a big fan of both DVR’s and automation as can be evidenced with this old Halloween picture taken during simpler times. Obviously the Cast Away and The Big Labowski references show some age. I was a big Tivo fan-boy back in the day and I still think it’s the best DVR.
I strongly believe that WebLogic Scripting Tool (WLST) is an absolutely essential tool for automating administration tasks in anything beyond a development environment. Even in development environments you can make a case that it makes sense to start the automation for environments downstream. I promise you that once you start using it for any tasks that you do even semi-regularly, you won’t go back to clicking through the console. It’s simply so much more efficient and less error-prone to run a script.
Let’s say you need to create a Work Manager and MaxThreadsConstraint – the easy way to do it is configure it in the WLS console first while capturing the commands with a recording. See the images for the simple steps – click to enlarge.
Record Console Configurations to a File
Review the Recordings and Make Slight Modifications
In order to make the recorded .py file directly callable as a stand-alone script I added calls to the connect() and edit() functions at the beginning and calls to disconnect() and exit() at the end – otherwise the main section of the script was provided by the console recording. Below is the resulting file I saved as d:/temp/wm.py
Run the Script
If you want to test it be sure to delete the Work Manager and MaxThreadConstraint that you had previously created in the console. Do something like the following - set up the environment and tell WLST to execute the script which happens in the first 2 lines, the rest doesn’t require any user input:
Now if you go back and look in the console the changes have been made and we now have a compete script. Of course there is a full MBean reference and you can learn the nuances of jython and WLST, but why not let the WLS console do most of the work for you! Happy scripting.