Saving changes to the script library
The script library provides Jython script procedures to assist in automating your environment. You can save changes to the master configuration repository, disable the automatic saving of configuration changes, or discard configuration changes.
About this task
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:
Save the custom script and run it from the command line, as the following syntax demonstrates:# # 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")
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 Version 7.0 and later of the product. The subdirectory V70 in the script library paths does not mean the scripts in that subdirectory are Version 7.0 scripts.
The script library saves configuration changes to the master configuration repository by default when each script procedure completes. You can disable or enable the automatic saving of configuration changes with the AdminUtilities.configureAutoSave() script procedure. You can alternatively save changes to the configuration before leaving the wsadmin process by using the AdminConfig.sav() command. You can discard configuration changes with the AdminConfig.reset() command.
CAUTION:
If
you disable the autosave procedure, call script procedures, then enable
the autosave procedure, automatic saving of script procedures in the
same wsadmin process does not occur until you call another script
procedure.