Update server config
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 updateServerConfig.py sample demonstrates how to call the FileTransfer MBean from a Jython script to invoke the FileTransfer MBean to retrieve and update the server.xml file for a Liberty collective member server that is managed by a collective controller.
- The FileTransfer MBean operations used:
The updateServerConfig sample script demonstrates how to download and upload server configuration file with the given operation (“get” or “put”). A connection is made to the collective controller located at the given host and port and the request to download or upload the file is passed to the FileTransfer MBean.
The first positional parameter is either “get” or “put”. When the parameter is “get”, the server.xml for the target member server is retrieved into the local file system. When the parameter is “put”, the server.xml is pushed to the server from the local file server. The typical usage of this script is to retrieve the server.xml using “get”, update it using a text editor, and replace it using the “put” parameter.
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:
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 requires 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.
First parameter get or put. --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. --serverHost The host name where the collectiveMember is installed. --serverUsrdir The usr directory where the collective member is installed. --serverName The name of the server which is installed on the host and usr directory described by serverHost and serverUsrdir, and whose server.xml is to be modified.
--help Displays help text. --debug Displays additional details when an error occurs. --localDir The name of a directory on the local machine where the server.xml can be stored. If this parameter is not
supplied, the current directory is used.
Sample use and resulting messages
>> jython updateServerConfig.py get --serverHost=myhost.austin.ibm.com --serverUserdir=C:\Liberty\usr --serverName=member1 --localDir=C:\temp\user\config\member1 --host=localhost --port=9443 --user=admin --password=adminpwd --truststore=C:\Liberty\usr\servers\controller1\resources\security\trust.jks --truststorePassword=controller1 Connecting to the server... Successfully connected to the server "localhost:9443"
>> jython updateServerConfig.py put --serverHost=myhost.austin.ibm.com --serverUserdir=C:\Liberty\usr --serverName=member1 --localDir=C:\temp\user\config\member1 --host=localhost --port=9443 --user=admin --password=adminpwd --truststore=C:\Liberty\usr\servers\controller1\resources\security\trust.jks --truststorePassword=controller1 Connecting to the server... Successfully connected to the server "localhost:9443"
The following additional sample scripts provide shared code which is used by this sample: