WAS v8.5 > Script the application serving environment (wsadmin) > Use the script library to automate the application serving environment using wsadmin.shSaving changes to the script library
The script library provides Jython script procedures to assist in automating the environment. We can save changes to the master configuration repository, disable the automatic saving of configuration changes, or discard configuration changes.
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 wsadmin. We can launch wsadmin, 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:
# # myscript.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 v7.0 and later of the product.
The script library saves configuration changes to the master configuration repository by default when each script procedure completes. We can disable or enable the automatic saving of configuration changes with the AdminUtilities.configureAutoSave() script procedure. We can alternatively save changes to the configuration before leaving the wsadmin process using the AdminConfig.sav() command. We 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.
- Disable the automatic saving of configuration changes.
Use the following script procedure:
AdminUtilities.configureAutoSave(“false”)
- Save changes to the master configuration repository.
We can save changes to the configuration using the save command or enable automatic saving of configuration changes.
- Save changes to the configuration.
Use the save command before leaving the wsadmin process.
AdminConfig.save()
- Enable the automatic saving of configuration changes.
Use the following script procedure to save subsequent changes that script procedures make to the configuration:
AdminUtilities.configureAutoSave(“true”)
- Discard the configuration changes.
Use the reset command to discard the changes:
AdminConfig.reset()
Results
Depending on the steps that you completed, we have disabled or enabled the automatic saving of configuration changes, completed the saving of configuration changes using the save command, or discarded the configuration changes.
Continue administering the environment using the script library.
Related
Automating server administration using wsadmin.sh
Automating administrative architecture setup using wsadmin.sh library
Automating application configuration
Automating business-level application configuration
Automating data access resource configuration using wsadmin.sh
Automating messaging resource configuration
Automating authorization group configuration
Automating resource configuration
Display script library help information using scripting
Reference:
Server settings configuration scripts
Server 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