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:
    #
    # 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")
    
    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. 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.

Procedure

  • Disable the automatic saving of configuration changes.
    Use the following script procedure:
    AdminUtilities.configureAutoSave(“false”)
  • Save changes to the master configuration repository.

    You 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, you 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 your environment using the script library.