Main

Admin Topics Archives

August 28, 2008

Extend WLST with your own commands

Do you want to add your own commands to the already rich set of WLST commands?

In WebLogic 10.0 and higher, you can add your own commands by building your own *.py file and adding them to WL_HOME/common/wlst/lib folder. Any *.py file added to this folder will be automatically compiled and imported by WLST when started on that machine. So the custom commands built as definitions inside these modules can be used by calling them on the respective module names.

If you have a TestLib.py stored under WL_HOME/common/wlst/lib folder:


TestLib.py
----------
def testCmd():
print 'This is a test command'


And if there is a definition called testCmd() defined in it then you can call it as follows:

wls:/offline>TestLib.testCmd()

What you waiting for? Go and add you command to WLST now.

September 24, 2008

Encrypt the credentials when running WLST in interactive or script mode

One of the common request I hear from administrators is that they want to get away from providing user name and password in plain text when using WLST. WebLogic Server provides a way to encrypt the credentials for server start up. You can create a password file "boot.properties" (called as Boot Identity File) with plain text credentials in a folder named security under the server root directory. This file will be automatically detected during the server start up and the server will encrypt the information in this file for subsequent use. Until WebLogic Server 9.x this file should be placed under the DOMAIN folder. So servers sharing the same file system share the same boot identity file and cannot be configured to use different files.

This boot identity file can also be used by WLST only when started from the domain folder. This is mainly because the domain's password key (SerializedSystemIni.dat) is used to encrypt this file. If you are using WLST from a different location or from a remote machine to connect to the server or if you want to run WLST script you can use a different technique. You can use WLST to generate a User Configuration file which will have encrypted user name and password using storeUserConfig() command. A key file that will be used to encrypt the data will also get generated along with the user config file. The key file is important as it is required to decrypt the values back from the user config file. This is an online WLST command. So you should be connected to a running WebLogic Server or a Node Manager to issue this command.

When you use this command with no arguments the user configuration file for the current user will be generated within the current OS user's home folder.


wls:/testdomain/serverConfig>storeUserConfig()


You can also specify the location and name for the key file and the userconfig file if you want them to be created elsewhere.

wls:/testdomain/serverConfig>storeUserConfig('/usr/home/user1/configfile.secure', '/usr/home/user1/keyfile.secure')


If the files are stored with the default name (osusername-WebLogicConfig.properties & osusername-WebLogicKey.properties) you can simply connect without specifying the username and password in the connect() command.

wls:/offline> connect(url='t3://host:port')


If the files are stored in a different location or with a different name, then they can be passed as an argument to the connect() command.

wls:/offline> connect(userConfigFile='/usr/home/user1/configfile.secure', userKeyFile='/usr/home/user1/keyfile.secure', url='t3://host:port')


No more plain text user name and password in when using WLST. Have a safe and secure scripting!

March 2, 2009

WLST Best Practices

With WLST becoming popular among WebLogic Administrator, there is a unsaid need for the evolution of best practices with respect to WLST scripting. I am being asked to share information about WLST like a 101 post. But I decided to start a series of post which might help WebLogic Administrators with some must follow best practices rather than writing some introductory post which might duplicate the documentation.

For a complete documentation of WLST see here - http://download.oracle.com/docs/cd/E12840_01/wls/docs103/config_scripting/using_WLST.html

I am writing a series of posts in my public blog space @ http://weblogicserver.blogspot.com and I shall update this post to include all the best practices that I publish there.

WLST-BP-1 Define all the variables in the preamble
WLST-BP-2 Check for existing session before you start one
WLST-BP-3 Check for the resource or configuration existence before creating them
WLST-BP-4 Use definitions for Reuse

About Admin Topics

This page contains an archive of all entries posted to Bala's Oracle Fusion Middleware Blog in the Admin Topics category. They are listed from oldest to newest.

Development is the next category.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type and Oracle