Saving 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.sh. We can launch wsadmin.sh, 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. 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. 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 we 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.
What to do next
Continue administering the environment using the script library.
Related tasks
Automating server administration Automating administrative architecture setup library Automating application configurations Automating business-level application configurations Automating data access resource configuration Automating messaging resource configurations Automating authorization group configurations Automating resource configurations Displaying script library help information
Server settings configuration scripts Server configuration scripts Cluster configuration 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