Saturday, March 27, 2010

How to use

There are several ways to make use of wsadminlib. Here are the basic ideas...

1. Reference

If you are looking for the secrets of how to issue some command, browse wsadminlib and search for it. We try to keep related methods together, so you should find similar functions nearby. If you don't find what you need, search the entire file, case-insensitive.

2. Sample code

If you find something you like, feel free to copy/paste from wsadminlib to your own scripts. wsadminlib is provided as a free sample. And if you find something you don't like, feel free to copy and change it.

3. Call from wsadmin shell

You can call methods in wsadminlib directly from the wsadmin shell. I find this really handy when I am setting up a one-time test. For example, go to a command-prompt, and open a wsadmin connection to your deployment manager.

root@ding6:~# /opt/WAS70/bin/ -lang jython -host ding6 -port 8879
WASX7209I: Connected to process "dmgr" on node dmgr using SOAP connector; The type of process is: DeploymentManager
WASX7031I: For help, enter: "print"


$Id: 104 2010-02-15 19:06:18Z ding $

Call a method. For example, list all the servers which exist. This is handy for debug when running things manually:

Server status
NODE dmgr on ding6 (linux) - Deployment manager
NODE node1 on ding6 (linux)
APPLICATION_SERVER fritzserver stopped
NODE_AGENT nodeagent running
APPLICATION_SERVER server1 stopped
APPLICATION_SERVER sippbx1 stopped

4. Call from your own scripts

I write my own small script files when I need to set up a complex configuration repeatedly, and don't want to keep typing the same commands over and over. These scripts are small, because they call methods in to do all the work. Here is a a simple example of a script which starts a server. Create a python file like this:

root@ding6:/tmp# cat

# Start server1
servername = 'server1'
nodename = 'node1'

Invoke it and watch the progress:

root@ding6:/tmp# /opt/WAS70/bin/ -lang jython -host ding6 -port 8879 -f /tmp/
WASX7209I: Connected to process "dmgr" on node dmgr using SOAP connector; The type of process is: DeploymentManager
$Id: 104 2010-02-15 19:06:18Z ding $
[2010-0329-1341-2800] enableDebugMessages Verbose trace messages are now enabled; future debug messages will now be printed.
[2010-0329-1341-2800] startServer: starting server node1,server1
[2010-0329-1341-2800] startServer: startServer(server1,node1)
[2010-0329-1341-4300] startServer: server node1,server1 not running yet, waiting another 15 secs

Looking at the wsadminlib source code, we see the startServer() method exits silently upon success, and raises a python exception if anything goes wrong. Therefore, the server started successfully. We also see that the method checks every so often to see if the server has started. This provides reassurance that the script is still alive and just waiting for results, especially when you have a mix of fast and slow server machines.