Network Deployment (Distributed operating systems), v8.0 > Reference
Jython script library
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, you 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.
Run scripts interactively
wsadmin>AdminServerManagement.createApplicationServer("myNode", "myServer", "default")
Execute a script
For example, ...
### 1. Create two appservers
### 2. Use one of them as the first member of a cluster
### 3. Add a second member to the cluster
### 4. Install an application
### 5. Start all servers and applications on the node
### wsadmin.sh -language jython -f /path/to/newsite.py -user wpadmin -password foo
AdminServerManagement.createApplicationServer("myNode", "WebSphere_Portal", "default")
AdminServerManagement.createApplicationServer("myNode", "WebSphere_Portal_2", "default")
AdminClusterManagement.createClusterWithFirstMember("myCluster", "APPLICATION_SERVER", "myNode", "WebSphere_Portal")
AdminClusterManagement.createClusterMember("myCluster", "myNode", "Server3")
AdminApplication.installAppWithClusterOption("DefaultApplication", "..\installableApps\DefaultApplication.ear", "myCluster")
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...
Within this directory, the scripts are organized into subdirectories according to functionality, and further organized by version. For example...
...contains procedures that perform application management tasks that are applicable to v7.0 and later of the product.
Each script from the script library directory automatically loads when you launch wsadmin.sh.
To load Jython scripts (*.py) when wsadmin.sh starts, create a new subdirectory, and save existing automation scripts in...
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...
...set the 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:
./wsadmin.sh -lang jython -javaoption "-Dwsadmin.script.libraries=c:/myJythonScripts"
To load multiple directories, specify each directory in the system property separated by a semicolon (;):
./wsadmin.sh -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:
When you issue a Jython command in a wsadmin script that invokes a WebSphere Application Server 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 you 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.
- Manage application servers
- Manage server and system architecture
- Manage applications
- Manage data access resources
- Manage messaging resources
- Manage mail resources
- Manage authorization groups
- Get script library help