Network Deployment (Distributed operating systems), v8.0 > Scripting the application serving environment (wsadmin) > Use the script library to automate the application serving environment using wsadmin.sh
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:
wsadmin>AdminServerManagement.createApplicationServer("myNode", "myServer", "default")- Use a text editor to combine several scripts from the Jython script library:
# # 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:./wsadmin.sh -language jython -f path/to/myscript.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 WAS_HOME/scriptLibraries directory. Within this directory, the scripts are organized into subdirectories according to functionality, and further organized by version. For example, the WAS_HOME/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 by 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.
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.
Automate server administration using wsadmin.sh
Automate administrative architecture setup using wsadmin.sh library
Automate application configuration
Automate business-level application configuration
Automate data access resource configuration using wsadmin.sh
Automate messaging resource configuration
Automate authorization group configuration
Automate resource configuration
Display script library help information using scripting
Related
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