Install or uninstall an application to a member server

Download

Install or uninstall an application to a member server sample script for Liberty Collectives

Install or uninstall an application to a member server

Description

In IBM WebSphere Application Server Network Deployment Version 8.5.5, Liberty profile has introduced the Liberty collective feature. Refer to information about collectives in the IBM WebSphere Application Server Version 8.5.5 information center for more specifics.

The manageAppOnServer.py sample demonstrates how to call the RoutingContext MBean and FileTransfer MBean from a Jython script to install or uninstall a simple application to a member server.

  • The RoutingContext MBean operation used:
    • assignServerContext
  • The FileTransfer MBean operation used:
    • uploadFile
    • deleteFile

manageAppOnServer.py script

This sample script demonstrates how to install a simple application to a member server with the given server name, server host and server usr directory. This script can only be used to install or uninstall a WAR application file. A connection is made to the collective controller located at the given host and port and the request to upload or delete the application file is passed to the FileTransfer MBean. The script also adds the application element to, or removes the application element from, the server.xml of the member server. By default, this script installs WAR files into ${server.config.dir}/apps unless the –appDir option is used.

Because this script uses the FileTransfer MBean to upload one or more files, the remoteFileAccess element must be specified in the server.xml of the server that will receive the file(s). Without this you will get a file permission error when using the script. Here is an example of a remoteFileAccess element:

<remoteFileAccess>

<writeDir>${server.config.dir}</writeDir>

</remoteFileAccess>

For further information and examples for remoteFileAccess, please visit the Information Center for “WebSphere Application Server V8.5 Liberty profile” and search for “List of provided MBean,” “remoteFileAccess” or “Configuration elements in the server.xml” information center topics.

File transfer and server commands require remote execution and access (RXA). Before running this sample script, ensure the target system(s) are configured for remote access. For more information on the remote execution and access requirements and setup, refer to Requirements for using Remote Execution and Access (RXA) in the information center.

Running the script pushes the application file to the apps directory of the member server and adds the application element to the member server. The script can be used to install a simple application which does not require more configuration in the server.xml. For applications that require additional configuration of the server.xml, see the transferAppToServer.py and updateClusterConfig.py sample scripts.

Instructions

Required parameters

--install or --uninstall The path to the application WAR file to be installed.
--serverName The name of the member server to install the application.
--serverHost The host name where the collective member is installed.
--serverUsrdir The usr directory where the collective member is installed.
--truststore The path to the truststore to be used when establishing a connection to the collective controller.
--truststorePassword The password for the truststore specified by the --truststore parameter.
--host The host name where the collective controller is running.
--port The https port where the collective controller is listening.
--user The user name to use when connecting to the collective controller.
--password The password to use when connecting to the collective controller.

Optional parameters

--appDir The directory where the application is to be installed. If not specified, it will be installed to the default location, the ${server.config.dir}/apps directory.
--help Displays help text.
--debug Displays additional details when an error occurs.

Sample use and resulting messages

	    
>> jython manageAppOnServer.py --install=c:/Liberty/applications/snoop.war
   --serverHost=host1
   --serverUsrdir=c:/Liberty/usr
   --serverName=member1
   --host=localhost
   --port=9443
   --user=admin
   --password=adminpwd
   --truststore=C:/Liberty/usr/servers/controller1/resources/security/trust.jks
   --truststorePassword=password

Connecting to the server...
Successfully connected to the server "localhost:9443"
Uploading application snoop.war to host1,C:\Liberty\usr,member1
Updating server config for host1,C:\Liberty\usr,member1
Complete
   
	  
	    
>> jython manageAppOnServer.py --uninstall=snoop.war
   --serverHost=host1
   --serverUsrdir=c:/Liberty/usr
   --serverName=member1
   --host=localhost
   --port=9443
   --user=admin
   --password=adminpwd
   --truststore=C:/Liberty/usr/servers/controller1/resources/security/trust.jks
   --truststorePassword=password

Connecting to the server...
Successfully connected to the server "localhost:9443"
Removing application snoop.war from host1,C:\Liberty\usr,member1
Updating server config for host1,C:\Liberty\usr,member1
Complete
   
	  

Notes

The following additional sample scripts provide shared code which is used by this sample:

  • wlp_arguments.py
  • wlp_serverConfig.py