The script library provides Jython script procedures to
assist in automating your environment. Use the sample scripts to manage
applications, resources, servers, nodes, and clusters. You can also
use the script procedures as examples to learn the Jython syntax.
About this task
New feature: The Jython script library provides
a set of procedures to automate the most common application server
administration functions. For example, you can use the script library
to easily configure servers, applications, mail settings, resources,
nodes, business-level applications, clusters, authorization groups,
and more. You can run each script procedure individually, or combine
several procedures to quickly develop new scripts.
newfeat
The scripting library provides a set of procedures
to automate the most common application server administration functions.
There are three ways to use the Jython script library.
- Run scripts from the Jython script library in interactive mode
with the wsadmin tool. You can launch the wsadmin tool, 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 example in the script library demonstrates
best practices for writing wsadmin scripts. The script library code
is located in the app_server_root/scriptLibraries
directory. Within this directory, the scripts are organized into subdirectories
according to functionality, and further organized by version. For
example, the app_server_root/scriptLibraries/application/V70
subdirectory contains procedures that perform application management
tasks that are applicable to Version 7.0 and later of the product.
Each script
from the script library directory automatically loads when you launch
the wsadmin tool. To automatically load your own Jython scripts (*.py)
when the wsadmin tool starts, create a new subdirectory, and save
existing automation scripts in the
app_server_root/scriptLibraries
directory. Each script library name must be unique and cannot be duplicated.
Avoid trouble: Do not edit the script procedures in the script
library. To customize script library procedures, save the modified
scripts to a new subdirectory to avoid overwriting the library.
gotcha
To
automatically load Jython scripts (*.py) that are not located in the
app_server_root/scriptLibraries
directory when the wsadmin tool starts, set the
wsadmin.script.libraries system
property to the script location. For example, if your script libraries
are saved in the temp directory on a Windows
® operating
system, the following example sets the script path in the wsadmin
command line tool:
bin>wsadmin -lang jython -javaoption "-Dwsadmin.script.libraries=c:/myJythonScripts"
To
load multiple directories, specify each directory in the system property
separated by a semicolon (;), as the following example demonstrates:
bin>wsadmin -lang jython -javaoption "-Dwsadmin.script.libraries=c:/myJythonScripts;c:/AdminScripts;c:/configScripts"
The
script library provides automation scripts for the following application
server administration functions: