Use the script library to automate the application serving environment using wsadmin.sh
The script library provides Jython script procedures to assist in automating the environment. Use the sample scripts to manage applications, resources, servers, nodes, and clusters. We can also use the script procedures as examples to learn the Jython syntax.
The Jython script library provides a set of procedures to automate the most common application server administration functions. For example, we can use the script library to configure servers, applications, mail settings, resources, nodes, business-level applications, clusters, authorization groups, and more. 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 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. We can launch the wsadmin tool, and run individual scripts 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:
# myscript.py
AdminServerManagement.createApplicationServer("myNode", "Server1", "default")
AdminServerManagement.createApplicationServer("myNode", "Server2", "default")
AdminClusterManagement.createClusterWithFirstMember("myCluster", "APPLICATION_SERVER", "myNode", "Server1")
AdminClusterManagement.createClusterMember("myCluster", "myNode", "Server3")
AdminApplication.installAppWithClusterOption("DefaultApplication", "..\installableApps\DefaultApplication.ear", "myCluster")
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...
app_server_root/scriptLibraries
Within this directory, the scripts are organized into subdirectories according to functionality. For example...
app_server_root/scriptLibraries/application/V70
...contains procedures that perform application management tasks that are applicable to v7.0 and later of the product. The subdirectory V70 in the script library paths does not mean the scripts in that subdirectory are v7.0 scripts.
Each script from the script library directory automatically loads when you launch the wsadmin tool. To automatically load our own Jython scripts (*.py) when the wsadmin tool starts, create a new subdirectory, and save existing automation scripts in...
app_server_root/scriptLibraries
Each script library name must be unique and cannot be duplicated.
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.
To automatically load Jython scripts (*.py) that are not located in app_server_root/scriptLibraries 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 (;):
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:
Tasks
- Manage application servers.
- Manage server and system architecture.
- Manage applications.
- Manage data access resources.
- Manage messaging resources.
- Manage mail resources.
- Manage authorization groups.
- Monitor performance and troubleshoot configurations.
- Get script library help script procedures.
What to do next
Determine which scripts to use to automate the environment, or create custom scripts using assembly tools.
Subtopics
- Automate server administration
- Automate administrative architecture setup using wsadmin.sh library
- Automate application configurations
- Automate business-level application configurations
- Automate data access resource configuration
- Automate messaging resource configurations
- Automate authorization group configurations
- Automate resource configurations
- Display script library help information using scripting
- Save changes to the script library
- Directory conventions
Server settings configuration scripts Server configuration scripts Server query scripts Server administration scripts Cluster configuration scripts Cluster query scripts Cluster administration scripts Node administration scripts Node group configuration scripts Application installation and uninstallation scripts Application query scripts Application update scripts Application export scripts Application deployment configuration scripts Application administration scripts J2C query scripts J2C configuration scripts JMS configuration scripts JMS query scripts JDBC configuration scripts JDBC query scripts Resource configuration scripts Authorization group configuration scripts Business-level application configuration scripts Utility scripts