Jython script library
Find usage information for each Jython script in the script library. 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") # Using 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. For example, the app_server_root/scriptLibraries/application/V70 subdirectory 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.
When we issue a Jython command in a wsadmin script that invokes a WAS MBean operation, and the MBean method returns a string that includes some NLS translated characters such as the French accent character, Jython automatically converts the string to a python unicode string, and returns the converted string to wsadmin. If we include the Jython print output command in the script that invokes the MBean method, the NLS translated characters are included in the string that the MBean method returns to wsadmin instead of the python unicode values. To avoid the displaying of NLS translated characters, use a variable for the MBean return (for example, output = AdminControl.invoke(mbean)) and then use print output. Use the Jython print command to convert strings that contain NLS translated characters correctly.
Subtopics
- Application administration scripts
- Application deployment configuration scripts
- Application export scripts
- Application installation and uninstallation scripts
- Application query scripts
- Application update scripts
- Authorization group configuration scripts
- Business-level application configuration scripts
- Cluster administration scripts
- Cluster configuration scripts
- Cluster query scripts
- J2C configuration scripts
- J2C query scripts
- JDBC configuration scripts
- JDBC query scripts
- JMS configuration scripts
- JMS query scripts
- Node administration scripts
- Node group configuration scripts
- Resource configuration scripts
- Server administration scripts
- Server configuration scripts
- Server query scripts
- Server settings configuration scripts
- Utility scripts