Home

 

Generating WebSphere admin commands for Jython scripts

You can use the WebSphere administration command assist tool to generate WebSphere administrative, wsadmin, Jython scripting language commands as you interact with the WebSphere Administrative Console. When you perform server operations in the WebSphere Administrative Console, the WebSphere Administration Command assist tool captures and displays the wsadmin commands issued. You can transfer the output from the WebSphere Administration Command view directly to a Jython editor, enabling you to develop Jython scripts based on actual console actions.

To generate wsadmin commands as you interact with the WebSphere Administrative Console, do the following steps:

Enable the command assistance notification option in the WebSphere Administrative Console:

Make sure that the server has started.
Right-click the server WebSphere Application Server v7.0 at localhost (2) and select Administration Æ Run administrative console.
Specify the User ID and the Password if the server is secured and click Log in.
On the left-pane, expand Applications Æ Application Types Æ WebSphere enterprise applications.
Scroll to the right of the Enterprise Applications page and under the Command Assistance section, click View administrative scripting command for last action.
Expand Preferences, select the Enable command assistance notifications (Figure | 2-25). Click Apply and close the window.

Figure 22-25 Administrative Scripting Commands

In the Servers view, right-click the server and select Administration Æ WebSphere administration command assist. The WebSphere Administration Command window opens. The view might open on the top-right, but you can move it to a better place, such as where the Servers and Console views are.

In the Select Server to Monitor pull-down , select WebSphere Application Server v7.0 at localhost (2), to ensure the server is selected.

In the WebSphere Administrative Console select Applications Æ Application Types Æ WebSphere enterprise applications in the left-pane. You should see that the WebSphere Administration Command view is populated with a wsadmin command for Jython.

Note: There might be a few seconds delay before you see the Jython command in the WebSphere Administration Command view.

In the WebSphere Administrative Console, left-pane, select Resources Æ JDBC Æ JDBC Providers. Another command will appear in the WebSphere Administration Command window (Figure | 2-26).

Figure 22-26 WebSphere Administration Command View

Create a Jython script file in the RAD75Jython project and name it CommandAssist.py.

To transfer the wsadmin commands generated in the WebSphere Administration Command view to the Jython script:

Make sure that the Jython editor for CommandAssist.py is open.
In the Jython editor, place the cursor at the bottom of the editor window.
In the WebSphere Administration Command view, use the Shift key and the mouse to select both commands. Right-click the commands and select Insert.

In the editor, two commands are added:

AdminApp.list()

AdminConfig.list(\

'JDBCProvider', AdminConfig.getid( \

'/Cell:KLCHL2YNode01Cell/'))

Add the print method in front of each of the two commands so that we have the following steps:

print AdminApp.list()

print AdminConfig.list(\

'JDBCProvider', AdminConfig.getid( \

'/Cell:KLCHL2YNode01Cell/'))

Save the file.

Right-click CommandAssist.py and select Run As Æ Administrative Script.

In the Script page of the WebSphere Administrative Script Launcher, select the following items:

For Scripting runtime, select WebSphere Application Server v7.0.
For WebSphere profile, select AppSrv01 (or was70profile1).
In the Security section, if administrative security is enabled, enter the required User ID and Password.

Click Apply and then click Run to execute the script. You should see console output similar to that listed here:

WASX7209I: Connected to process "server1" on node KLCHL2YNode01 using SOAP connector; The type of process is: UnManagedProcess

DefaultApplication

IBMUTC

ivtApp

query

"Derby JDBC Provider (XA)(cells/KLCHL2YNode01Cell/nodes/KLCHL2YNode01/servers/

server1|resources.xml#builtin_jdbcprovider)"

"Derby JDBC Provider (XA)(cells/KLCHL2YNode01Cell|resources.xml#

builtin_jdbcprovider)"

"Derby JDBC Provider(cells/KLCHL2YNode01Cell/nodes/KLCHL2YNode01/servers/

server1|resources.xml#JDBCProvider_1182202633563)"

The command assist feature is great when you are learning Jython and allows you to easily create scripts for future use.

ibm.com/redbooks