Jython script library
The Jython script library provides a set of procedures to automate the most common appserver administration functions. For example, we can use the script library to configure...
- servers
- applications
- mail settings
- resources
- nodes
- business-level applications
- clusters
- authorization groups
We can run each script procedure individually, or combine several procedures to quickly develop new scripts.
The scripting library provides a set of procedures to automate the most common appserver administration functions. There are three ways to use the Jython script library.
- Run scripts from the Jython script library in interactive mode with wsadmin. We can launch wsadmin, and run individual scripts that are included in the script library using the following syntax:
wsadmin>AdminServerManagement.createApplicationServer("myNode", "myServer", "default")- Use a text editor to combine several scripts from the Jython script library, as the following sample displays:
#
# My Custom Jython Script - file.py
#
AdminServerManagement.createApplicationServer("myNode", "Server1", "default")
AdminServerManagement.createApplicationServer("myNode", "Server2", "default")
# Use one of them as the first member of a cluster
AdminClusterManagement.createClusterWithFirstMember("myCluster", "APPLICATION_SERVER", "myNode", "Server1")
# Add a second member to the cluster
AdminClusterManagement.createClusterMember("myCluster", "myNode", "Server3")
# Install an application
AdminApplication.installAppWithClusterOption("DefaultApplication", "..\installableApps\DefaultApplication.ear", "myCluster")
# Start all servers and applications on the node
AdminServerManagement.startAllServers("myNode")Save the custom script and run it from the command line, as the following syntax demonstrates:
bin>wsadmin -language jython -f path/to/your/jython/file.py- Use the Jython scripting library code as sample syntax to write custom scripts. Each script in the script library demonstrates best practices for writing wsadmin scripts. The script library code is located in...
$WAS_HOME/scriptLibraries
Within this directory, the scripts are organized into subdirectories according to functionality, and further organized by version. For example, the $WAS_HOME/scriptLibraries/application/V70 subdirectory contains procedures that perform application management tasks that are applicable to V7.0 and later of WAS ND.