Tuesday, February 16, 2010

Migration Notes

The migration tools are used as part of a four-step migration process:
1. Run WASPreUpgrade on the existing WebSphere Application Server configuration.
2. Uninstall the existing version of WebSphere Application Server.
3. Install the new version of WebSphere Application Server.
4. Run WASPostUpgrade on the new version.
In the second step, it is recommended that rather than uninstalling the existing version, it be made dormant. By keeping the existing software installed on the machine, it will be much easier to back out of the migration should unexpected problems arise.

The fully automated migration includes the following steps:
1. Migrate the existing Version 5.x deployment manager to Version 6.0 using the migration
tools.
2. Migrate the HTTP servers and HTTP server plug-ins on all Web tier nodes.
3. Individually migrate the application server nodes using the migration tools.

The WASPreUpgrade and WASPostUpgrade tools effectively move the existing configuration into WebSphere Application Server Version 6.0.

Why to migrate?
Two important things to my understanding.
For new features.
For maintenance support.
-> New Features
Again two views. Developer view and support view.
ex., My developer called me one day, said, struts framework x.xx version is throwing error on the development. I paid a look into the log and search for the errors in the IBM. Found that, that version of JVM donot support this version of struts. So, what to do? Its the developers call to have the latest copy the JVM which can support this version of struts and apps.
This is what is developer initiated migration.
Admin initiated migration -
Admin may initiate the migration too. Some of the app server errors must have been addressed in the new version of the application server and so the need for migration.
-> Support
If the product is end of the support, there is a need to migrate to supported version.

While migrating, one should need to understand inconsistencies and deprecations between the target and source environments.
In considering the incompatibilities and deprecations, we look at these major areas:
* J2EE differences
* J2SE/JDK differences
* Application Server runtime differences
* Programming Model Extension differences
* Third Party Library differences

-> J2EE Differences
Java Code, as we all know, is forward compatible. Meaning that, code compiled in JDK 1.3.0 runs on 1.4.0, but, may throw some deprecation warnings.
Its a good practice for the developers to address those deprecations in the code. So, when one plans to migrate from x version to y version, the development team should plan to revisit their code.

Solaris df,du and ls commands

Solaris df command

New df, du, and ls Options

The df, du, and ls commands have a new h option for displaying disk usage and file or file system sizes that are easy to understand.

The default form of the df command displays file system size in blocks (512 bytes). The df output, in kilobytes, follows:

$ df -k / /usr
Filesystem kbytes used avail capacity Mounted on
/dev/dsk/c0t0d0s0 192056 94788 78063 55% /
/dev/dsk/c0t0d0s6 1982988 829966 1093533 44% /usr

The same file system sizes displayed in powers of 1024 follows:

$ df -h / /usr
Filesystem size used avail capacity Mounted on
/dev/dsk/c0t0d0s0 188M 93M 76M 55% /
/dev/dsk/c0t0d0s6 1.9G 811M 1.0G 44% /usr

The default form of the du command displays disk space in blocks (512 bytes). The du output, in blocks, follows:

% du -s k*
100 kadmin
98 kadmin.local
98 kdb5_util
90 keyserv
10 killall

The same disk space displayed in powers of 1024 follows:

% du -h k*
50K kadmin
49K kadmin.local
49K kdb5_util
45K keyserv
5K killall

The default form of the ls -l command displays file size in bytes. Use the ls -lh command to display file size in powers of 1024:

% ls -lh k
-r-xr-xr-x 1 root bin 49K Nov 30 03:32 kadmin
-r-xr-xr-x 1 root bin 49K Nov 30 03:32 kadmin.local
-r-xr-xr-x 1 root bin 49K Nov 30 03:32 kdb5_util
-r-xr-xr-x 1 root sys 44K Nov 25 04:37 keyserv
-r-xr-xr-x 1 root bin 4.3K Nov 25 04:36 killall

EnableTrace in Plugin-cfg.xml

WebServer Plugin writes a log, by default its named as http-plugin.log, by default placed under PLUGIN_HOME/logs/
Plugin writes Error messages into this log. The attribute which deals with this is
< Log > in the plugin-cfg.xml
Ex.,
< Log LogLevel="Error" Name="/usr/IBM/WebSphere/Plugins/logs/http_plugin.log" / >

According to above line all Error messages will be written into http-plugin.log.

How to enable trace in the plugin-cfg.xml? if that is the question, do like this -

< Log LogLevel="Trace" Name="/usr/IBM/WebSphere/Plugins/logs/http_plugin.log" / >

From the InfoCenter -
Plug-in Problem Determination Steps
The plug-in provides very readable tracing which can be beneficial in helping to figure out the problem. By setting the LogLevel attribute in the config/plugin-cfg.xml file to Trace, you can follow the request processing to see what is going wrong.
Note: If you are using a Veritas File System with large file support enabled, file sizes up to two terabytes are allowed. In this case, if you set the LogLevel attribute in the plugin-cfg.xml file to LogLevel=Trace, then the http_plugin.log file might grow quickly and consume all available space on your file system. Therefore, you should set the value of the LogLevel attribute to ERROR or DEBUG to prevent high CPU utilization.
At a high level, complete these steps.
The plug-in gets a request.
The plug-in checks the routes defined in the plugin-cfg.xml file.
It finds the server group.
It finds the server.
It picks the transport protocol, HTTP or HTTPS.
It sends the request.
It reads the response.
It writes it back to the client.

WebSphere Application Server Important Files

XML Configuration Files
Property files
Log Files

WebSphere stores its configuration to set of XML files. When we use the Admin console to configure WebSphere, certain XML files are updated internally.

CELL-scope

• admin-authz.xml
Contains the roles set for administration of the Admin console.
/appsrv01/config/cells//

• profileRegistry.xml
Contains a list of profiles and profile configuration data

• resources.xml
Defines operating cell scope environmental resources, including JDBC, JMS, JavaMail, URL end point configuration, and so on.

• security.xml
Contains security data , including all user ID and password information.

• virtualhosts.xml
Contains virtual host and Multipurpose Internet Mail Extensions (MIME)-type configurations.

• variables.xml
Contains cell level WebSphere variables

• wimconfig.xml
Contains the federated repository configurations for global security
/config/cells//wim/config/
NODE-scope

• namestore.xml
Provides persistent JNDI namespace binding data

• resources.xml
Defines node scope environmental resources, including JDBC, JMS, JavaMail, URL end point configuration, and so on

• serverindex.xml
Specifies all the ports used by servers on this node

• variables.xml
Contains node level WebSphere variables

SERVER-scope

• resources.xml
Contains the configuration of resources, such as, JDBC, JMS, JavaMail, and URL end points at server scope

• server.xml
Contains application server configuration data

• variables.xml
Contains server level variables

properties files

If the global security is enabled WebSphere Application Server cell, you need to manually enter the username and password every time you run the wsadmin tool. By editing the sas.client.props and the soap.client.props files, you can specify the username and password you have configured for global security so you are not prompted to enter the username and password every time you run administrative scripts.

soap.client.props file
com.ibm.SOAP.securityEnabled=
com.ibm.SOAP.loginUserid=
com.ibm.SOAP.loginPassword=
Optionally, set the following property:
com.ibm.SOAP.loginSource=none

sas.client.props file
com.ibm.CORBA.loginUserid=
com.ibm.CORBA.loginPassword=
Also, set the following property:
com.ibm.CORBA.loginSource=properties

Log Files

JVM logs
native_stderr.log,native_stdout.log
stdout and stderr streams are redirected to log files at application server startup, which contain text written to the stdout and stderr streams by native modules, that is, Linux Modules, and so on. In normal error-free operations, these logs files are typically empty.

startServer.log
It is created in your logs directory when the server starts up. This log is very useful to determine JVM parameters used in the start-up process, the server’s process id, and also the date and time in which the server was started. If there are errors experienced during the start-up (for example, security configuration errors where the application server cannot start), then log information will exist for problem determination.

stopServer.log
when server was stopped via a command line, the log will be written to this. If the server has trouble stopping, then Java stack traces will be written to the log which can be used in determining why a given application server failed to stop.

SystemErr.log
contains Java exceptions and stack traces. An empty SystemErr.log file does not necessarily indicate a successfully running application server JVM. You may need to consult the other logs in this directory.

SystemOut.log
This log file contains messages as generated by the JVM during runtime. Some messages are informational, some are warnings or status updates. Applications can be configured to write to the log and so it is very common for the SystemOut.log to be your first port of call in application debugging.

.pid
contains the process id of the server. In Linux, this is the actual process id assigned to the JVM process.

FFDC logs
FFDC directory contains detailed logs of exceptions found during the runtime of the WebSphere Application Server. Can be found at WAS_ROOT/profiles/logs/ffdc

Was interview stuff

1.What is Websphere and why we prefer IBM product compare to others?
Websphere is middleware product which is best known for its turn key operation in e-business applications. It has run time components and tools which help in creating applications which run on Websphere application server.
IBM Websphere is best choice due to unique and incomparable supports which they provide to their customers to troubleshoot and for smooth operations.


2.Explain the architecture of Websphere?
Websphere is mainly consists of three components:
•Webserver (IBM http server, Sun Webserver etc.)
•Application Server (IBM Application Server etc.)
•Database (DB2, Oracle etc.)


3.What is difference between Webserver and Appserver?
The main responsibility of Webserver is to serve static request while Appserver is used for dynamic request.
Moreover, Webserver handle http requests and also acts like a load balancer while Appserver has large area of works like security, performances, clustering, support for various files (.ear,.war)deployments etc.


4.What is difference between WAS5 and WAS6 Versions?
•In WAS5, we need to install BASE and ND separately while in WAS6, only one file is responsible to install both.
•In WAS5, for every new profile, we need to do separate installation while in WAS6, single installation can create multiple profiles.
•WAS5 supports J2EE1.3 while WAS6 supports J2EE1.4.
•In WAS6, we have concept of Service Integration Bus (SIB) for messaging which was not with any previous versions.
•In WAS6, we have default JMS provider
•Webservers can be managed by admin console in WAS6


5.What is difference between WAS 6.0 & 6.1?
•In WAS6.1, we have cell profile concept which was not in WAS6.0
•WAS6.1 supports JAVA 1.5 while WAS6.0 supports JAVA 1.4
•We have partition profile architecture concept in WAS6.1 that gives more flexibility for backups and updates with no outage
•We have authentication alias concept while creating Data-Source in WAS6.1 which was not in WAS6.0
•WAS6.1 is 64 bit enabled for better performance and support


6.What are the new security features in WAS6.1?
•Administrative security is enabled automatically during installation

•All internal transports are authenticated by default
•Most internal transports are encrypted by default. DCS, which normally runs within a cell, remains unencrypted by default, but encryption can be enabled
•The default encryption keys are eliminated. A cell-specific set of keys is created automatically.
•JNDI is read-only (rather than read/write) by default to all.
•Messaging limits connections to only authenticated users granted the bus connect role by default. All Authenticated no longer has that role by default.


7.What is difference between Ear and War file?
An EAR file is an Enterprise Application Archive which is a general J2EE application. It is a top-level container which contains modules like –EJB modules, Web module, application client module etc.
A WAR file is a Web Application Archive – containing servlets, JSPs and their supporting classes and files. WAR file is mainly used for Web application deployed to a servlet/JSP engine.
EAR file contains the EJB modules of the applications but it can also contain WARs, JARs etc.


8.What is difference between Plug-in module and plugin-cfg.xml file?
Plug-in module is very important part of Webserver configuration which handles the HTTP requests and redirect them to Webserver or Appserver with help of ‘plugin-cfg.xml’ on the basis 0f type of request.


If request is for static content then it get diverts to Webserver and if request is for Dynamic content then it goes to Appserver.


When request arrives to the Webserver, The plug-in module first check the request URI in XML file, if it is there then request get serve by Appserver and if it is not there then it get serve by Webserver itself.


9.Explain JACL & JYTHON scripting?
JACL: JACL is a self-contained implementation of a Tcl interpreter, written entirely in Java. JACL also includes features that facilitate communication between a Java interpreter and a TCL interpreter.
JYTHON: JYTHON is a programming hybrid. It is an implementation of the Python scripting language written in 100% pure Java that runs under any compliant Java Virtual Machine (JVM). Using JYTHON, you can write Python programs that interact with any Java code.


10. What do you mean by federated repository?
Federated repositories enable us to use multiple repositories with Web Sphere Application Server. These repositories, which can be file-based repositories, LDAP repositories, or a sub-tree of an LDAP repository, are defined and theoretically combined under a single realm.
It is required that the user ID, and the distinguished name (DN) for an LDAP repository, be unique in multiple user repositories that are configured under the same federated repository configuration.
In addition, the federated repositories functionality in WebSphere Application Server supports the logical joining of entries across multiple user repositories when the Application Server searches and retrieves entries from the repositories.


11. What is Dynamic URLs?
A dynamic URL is a page address that results from the search of a database-driven web site or the URL of a web site that runs a script. In contrast to static URLs, in which the contents of the web page stay the same unless the changes are hard-coded into the HTML, dynamic URLs are generated from specific queries to a site's database. The dynamic page is basically only a template in which to display the results of the database query. Instead of changing information in the HTML code, the data is changed in the database.
- A dynamic URL is the address - or Uniform Resource Locator (URL) - of a Web page with content that depends on variable parameters that are provided to the server that delivers it.


12. How to install WAS in silent mode?
Copy the responsefile.nd.txt as, for example, responsefile.txt.
cp responsefile.nd.txt responsefile.txt
Open responsefile.txt and edit:
a. Set property -OPT silentInstallLicenseAcceptance to “true”.
b. Uncomment -OPT installLocation=”/opt/IBM/WebSphere/AppServer” and set it to correct value if we are installing into a different location.
c. Comment out the Windows install Location option so we do not have a duplicate entry for installLocation option. If we have a duplicate entry on this option, the installation will fail.
d. Change option -OPT profileType to “standAlone”.
e. If we enable administrative security:
set a value for the option -OPT PROF_adminUserName
set a value for the option -OPT PROF_adminPassword
5. Save our response file.
6. Issue the command. /install -options “responsefile.txt” -silent


13. What is web container?
A web container is run time environment for web applications. It processes servlet, JSP and other types of server side components.
A container that implements the Web component contract of the J2EE architecture. This contract specifies a runtime environment for Web components that includes security, concurrency, life-cycle management, transaction, deployment, and other services. A Web container provides the same services as a JSP container as well as a federated view of the J2EE platform APIs. A Web container is provided by a Web or J2EE server.


14. What happened in background when we use addNode.sh command to federate the Node with DMGR?
For federation, First go to Custom profile bin then run the below command:
./addNode.sh DMGR_HOST DMGR_SOAP_PORT
-Deleting old back up directory
-Backing up the original cell repository
-Creating node agent configuration for new node
-Adding new node configuration to cell : DmgrCell
-Synchronizing configuration between node and cell


15. What is SOAP port (SOAP) means?
SOAP is an XML-based protocol that consists of three parts: an envelope that defines a framework for describing message content and process instructions, a set of encoding rules for expressing instances of application-defined data types, and a convention for representing remote procedure calls and responses.
SOAP is transport protocol-independent and can be used in combination with a variety of protocols. In Web services that are developed and implemented for use with Web Sphere Application Server, SOAP is used in combination with Hypertext Transport Protocol (HTTP), HTTP extension framework, and Java Messaging Service (JMS). SOAP is also operating system independent and not tied to any programming language or component technology.
Soap port we generally use to connect to DMGR. If we are using addNode.sh command to federate the node then also we need this port number.


16. Syntax to deploy application with wsadmin scripting?
$AdminApp install "location_of_ear.ear" {-node nodeName -cell cellName -server serverName}


17. How do you mean by fix pack?
It is recommended from IBM to resolve the issue with any WAS versions. it provides minor new features to enhance performance of previous WAS release.


18. How to take back up of WAS?
From the bin directory of WAS, run the backupConfig.sh command to take back up of the config files and the backed up zip file will be in the current location.


19. What is difference between thread dump and core dump?
Thread Dump: When we trigger a thread dump on a application server,all active thread informations will be dumped into file which is known as thread dump. Here we can get information about thread like active thread, hung thread, dead lock, runnable and inactive thread info.
Command: kill -3 PID
Core/Heap Dump: It’s snap shot of our JVM’s Heap memory, so here we can have all active java objects and their activities which object doing what and how much memory it is occupying....


20. Explain the types of Cluster?
Types of clusters:
vertical cluster - members of cluster must be at same node
horizontal cluster - members of cluster must be at different nodes


21. What is Semaphore?
A semaphore is nothing but a term used in UNIX for a variable which acts as a counter. If two processes trying to access the same file simultaneously then by assigning value to semaphore, we can control the access of file when other process is already using that file.


22. What is Zombie process?
Zombie process or defunct process is a process that has completed execution but still has an entry in the process table. This entry is still needed to allow the process that started the (now zombie) process to read its exit status.




When a process ends, all of the memory and resources associated with it are deallocated so they can be used by other processes. However, the process's entry in the process table remains. The parent can read the child's exit status by executing the wait system call, at which stage the zombie is removed. The wait call may be executed in sequential code, but it is commonly executed in a handler for the SIGCHLD signal, which the parent receives whenever a child has died.


A zombie process doesn't react to signals because it's not really a process at all- it's just what's left over after it died. What's supposed to happen is that its parent process was to issue a "wait()" to collect the information about its exit. If the parent doesn't (programming error or just bad programming), you get a zombie. The zombie will go away if its parent dies- it will be "adopted" by init which will do the wait()- so if you see one hanging about, check its parent; if it is init, it will be gone soon, if not the only recourse is to kill the parent..Which we may or may not want to do.

Websphere Automation Tool ( WASIC)

WASIC is Websphere Application Server Installation and Configuraton Automation Tool.

Overview:-

WASIC is a tool to install, configure and administrate Websphere application server Version 6.1/7.0.

Features of WASIC:

1. Deployment Manager Installation.
2. Node Installation
3. Federate node to Deployment Manager.
4. Creating Profiles.
5. Install Update installers
6. Apply Fix Packs on Base Installation.
7. Changes port of deployment Manager
8. Checks whether ports are already in use.
9. Changes and checks node agent ports.
10.Webserver Installation and configure them with Application Server.
11.Cluster and server creation and configuring servers.
12.Create Cluster.
13.Create server and add the server to cluster.
14.Create Virtual hosts.
15.Max and minimum heap size.
16.Debug argument.
17.Http Transports
18.Boot classpath.
19.Classpath.
20.Create server level variable.
21.JVM arguments.
22.Changes ports of server.
23.JDBC and Data source creation.
24.Create JDBC provider at cluster level scope..
25.Create Data Source at cluster level scope.
26.Create J2c Authentication.
27.Create Connection Pool Setting.
28.Testing Database connection.
29.Cluster Stop and start.
30.Application installation.

Pre-requisites:-


These are the pre-requisites which we need to do before installing this tool.

1. Create one user which will be used as administrator.
2. ssh for this user should work in all UNIX boxes.
3. Directory under which deployment manager, node and webserver are to be installed should be under this user.
4. The Directory under which we will place this tool should be mounted on all UNIX boxes where we will be installing Websphere Application server.
5. Download the Websphere application server and HTTP server binaries.

Description:-

This tools does Base installation of Websphere Application server version 6.1, first it checks whether the WAS base installation is already done on UNIX m/c and if the base installation is not there it will install WAS base binaries. The location under which it will check whether WAS is already installed depends on the value specified in configure.properties file and response file and then it install Update installer and apply fix packs and after installing base binaries, it install deployment manager using manageprofile utility and values specified in property files and using ports defined in ports properties file. It also checks whether the ports are already in use or not if they are in use I will send the list the ports which are already in use and it also changed the SOAP TIME OUT value to 6000 as it is 180 by default which is very less.

It will then install number of Nodes specified in property file and install them on host specified in properties file and install the Base binaries if they are not installed on unix box and it they are installed then it install nodes and federate nodes to deployment manager, changes node agents ports and start node. It also changes Soap time out for nodes.
*It also install node and federate with Deployment Manager for existing environment.

After node installation is completed, then it installs webservers on the host where we want to install it as specified in property files and configure webserver to deployment manager and generate plug-in and propagate the plug-in back to webserver and start the admin and http server. Http server will be listening on the port in property file.



It then create cluster and create server and add server to cluster and configure all these things on server:-
o Create Virtual hosts.
o Max and minimum heap size.
o Web Container Thread Pool Setting
o Debug argument.
o Http Transports
o Boot class path.
o Class path.
o Create server level variable.
o JVM arguments.
o Changes ports of server.

All these values are picked from property files.
• Other things can also be configured depending upon requirement and script can be modified to accommodate those changes.

After configuring cluster and server creation now it create JDBC provider, Data source , J2c Authentication and connection pool setting on cluster level scope.

It then installs the application on cluster which is created and starts the cluster and sends an email out with Deployment manager console login.

So with one script execution it will do a full fledged environment creation taking all possible intervention of manual stuff to be done and script which we will have to execute will be WASIC.sh.

All these steps in environment creation can run as on single step and they can be executed separately as single steps depending upon needs and new feature can be added as per requirement.


NOTE ***** ALL VALUE ARE PULLED FROM PROPERTY FILES, SO EVERYTHING CAN BE VERSION CONTROLLED IN CLEARCASE.


This tool also works under these scenarios also:

1. If we have to just create Deployment manager.
2. If we have create standalones Application server.
3. If we have to add new node to existing environment.
4. If we have to add new cluster in existing environment.
5. If we have to add new server to existing cluster and configure it.
6. If we have to modify existing JDBC, Data source connection settings.
7. For daily to daily application deployments, cluster stop and cluster start.
8. Create new webserver.
9. Create new webserver and add this webserver to existing environment.
10. It will generate plug-in after application installation or any configuration change and propagate the plug-in to webserver.

For all this environment creation to work, all we have to do is copy the existing environment in WASIC configuration and rename it to the new environment what we want to create change the values in properties file and change the name of scripts and run the WASIC.sh with functional area name and environment name.

These all steps can also be integrated as part of Build Forge.

FUTURE ENHANCEMENT:

1. Create a Graphical user interface for WASIC tool.
2. Adding New features for V 7.0 which are installation of admin agent, Job Manager and registering node to admin Agent and job manager
3. Configuring Global Security, LDAP, LTPA, SSO.
4. Configuring SSL configuration, creating self signed certificate, replace an existing self signed certificate, creating certificate authority requests, receiving a certificate issued by a certificate authority, retrieving a signer certificate from a remote ssl port and adding a signer certificate to a keystore.
5. Installations of Websphere Portal Sever and Websphere Process server.
6. This tool can be modified as per requirement and more features can be added.
7. These scripts can be broken into small scripts, so that if we have to change one configuration file of server it will work.
8. The scripts can also be integrated with build Forge

Script to check the status of application and send email notification if application is down

This Script checks the status of application and send email notification if application is down. Define the application URL in url.properties
#!/usr/bin/bash

## Written by Charanjeet Singh ##

PATH=${PATH}:/opt/csw/bin;export PATH

cd /home/charan
date=`date '+%Y%m%d%H%M'`
mdate=`date '+%b-%d(%A)-%Y_%H.%M%p'`
home=/home/charan
logdir=$home/logs/application/$1.app.log$date
emaillist=
if [ $# -ne 1 ] ;
then echo ;
echo "enter env name for the script to execute or pass ALL as argument to check for the status of all envrionment specified in url.properties"
echo
exit 0
fi
echo " Checking application status of $1 Server "
envlist=" DEV SIT UAT "
if [[ $1 == ALL ]]; then
for envvar in $envlist ;
do
PropsPath="/home/ccbuild/charan/url.properties";
URL=`grep "$envvar"= $PropsPath | awk -F= '{print $2}'`
echo " $envvar URL --> $URL "
wget -q -O $logdir $URL
if [ \! -s $logdir ]; then
mailx -s "$envvar Application is DOWN" $emaillist < $logdir rm -rf $logdir fi done fi for env in $envlist ; do if [[ $env == $1 ]]; then PropsPath="/home/charan/url.properties"; URL=`grep "$env"= $PropsPath | awk -F= '{print $2}'` echo " $env URL --> $URL "
wget -q -O $logdir $URL
if [ \! -s $logdir ]; then
mailx -s "$env Application is DOWN" $emaillist < $logdir
rm -rf $logdir
fi
fi
done
rm -rf $logdir

--------------------------------------------------------------

DEV=
SIT=
UAT=

Script to Create Cluster, Server and Configuring them Fully.

This Script does the following Tasks :-
1. Create Cluster and Server and make server Member of cluster.
2. If cluster exits then it creates Server and make it member of cluster.
3. If cluster and server exists and if server is not member of cluster, it makes that server member of cluster.
4. Debug Argument.
5. Http Transports.
6. Ports --> SOAP, DRS, and Bootstrap ports.
7. JVM heap Size.
8. Virtual host.
9. AppServer Classpath
10. AppServer BootClasspath.
11. Generic JVM argument.
12. Cluster Level and Server Level Variables.
13. WebContainer Thread Pool Setting.

import sys,java
from java.util import Properties
from org.python.modules import time
from java.io import FileInputStream

lineSep = java.lang.System.getProperty('line.separator')


def clusterServer(node,cluster,server,http,http1,host,bootstrap,soap,orb,csiv2_multi,csiv2_server,adminhost,adminhost1,dcs,sib,sib1,sib_mq,sib_mq1,sip,sip1,sas,maxHS,minHS,varname1,varvalue1,varname2,varvalue2,varname3,varvalue3,JvmArguments,maxtp,mintp,debug):

global AdminApp
global AdminConfig
global AdminControl

print " ----------------------------------------------------------------------------------------- "

######################################## Getting config ID of cell ################################################

cell = AdminControl.getCell()

cellid = AdminConfig.getid('/Cell:'+ cell)

##################################### checking for existence of node #########################################################


nodeid= AdminConfig.getid('/Cell:'+ cell +'/Node:'+ node)

print " Checking for existence of node --> " + node

if len(nodeid) == 0:

print "Error -- node not found for name --> " + node

else:

print " ----------------------------------------------------------------------------------------- "

print " Node exists --> " + node


print " ----------------------------------------------------------------------------------------- "


###################### Checking for the existence of cluster and creating cluster if it doesnot exist ###########################


Clusterid = AdminConfig.getid('/ServerCluster:'+ cluster +'/')

print " ----------------------------------------------------------------------------------------- "

print " Checking for existence of Cluster --> " + cluster

if len(Clusterid) == 0:

print " ----------------------------------------------------------------------------------------- "

print "Cluster doesnot exists "

print " ----------------------------------------------------------------------------------------- "

print " Creating cluster --> " + cluster

name_attr = ["name", cluster]
desc_attr = ["description", cluster+" cluster"]
pref_attr = ["preferLocal", "true"]
statem_attr = ["stateManagement", [["initialState", "STOP"]]]
attrs = [name_attr, desc_attr, pref_attr, statem_attr]


AdminConfig.create('ServerCluster', cellid, attrs)

AdminConfig.save()

print " ----------------------------------------------------------------------------------------- "

print " Verify that cluster created successfully "

print " ----------------------------------------------------------------------------------------- "

newClusterid = AdminConfig.getid('/ServerCluster:'+ cluster +'/')

if len(newClusterid) > 0:

print " ----------------------------------------------------------------------------------------- "

print " cluster --> " + cluster + " created successfully "

print " ----------------------------------------------------------------------------------------- "

###################### Checking for the existence of Server and creating Server if it doesnot exist ###########################

Serverid = AdminConfig.getid('/Cell:'+ cell +'/Node:'+ node +'/Server:'+ server)

print " Checking for existence of Server :" + server

if len(Serverid) == 0:

print " ----------------------------------------------------------------------------------------- "

print "Server doesnot exists "

print " ----------------------------------------------------------------------------------------- "

print " Creating --> " + server + " and making this server as a member of cluster --> " + cluster

AdminConfig.createClusterMember(newClusterid, nodeid, [['memberName', server ]])

AdminConfig.save()

Serverid = AdminConfig.getid('/Cell:'+ cell +'/Node:'+ node +'/Server:'+ server)

if len(Serverid) > 0:

print " ----------------------------------------------------------------------------------------- "

print " Server --> " + server +" created and added as a member of --> " + cluster


else:

print " ----------------------------------------------------------------------------------------- "

print "Server already exist with this name --> " + server + " , please provide different name in property file "


else:

print " ----------------------------------------------------------------------------------------- "

print " Cluster exist --> "+ cluster + " and making this server as a member of cluster --> " + cluster +""

Serverid = AdminConfig.getid('/Cell:'+ cell +'/Node:'+ node +'/Server:'+ server)

if len(Serverid) == 0:

print " ----------------------------------------------------------------------------------------- "

print "Server doesnot exists "

print " ----------------------------------------------------------------------------------------- "

print " Creating --> " + server + " and making this server as a member of cluster --> " + cluster

AdminConfig.createClusterMember(Clusterid, nodeid, [['memberName', server ]])

AdminConfig.save()

Serverid = AdminConfig.getid('/Cell:'+ cell +'/Node:'+ node +'/Server:'+ server)

if len(Serverid) > 0:

print " ----------------------------------------------------------------------------------------- "

print " Server --> " + server +" created and added as a member of --> " + cluster


else:

print " ----------------------------------------------------------------------------------------- "

print "Server already exist with this name --> " + server + " , please provide different name in property file "

print " ----------------------------------------------------------------------------------------- "


################################# configuring properties for Server , variables and Virtual host ###################################

Clusterid = AdminConfig.getid('/ServerCluster:'+ cluster +'/')

if len(Clusterid) > 0:

Serverid = AdminConfig.getid('/Cell:'+ cell +'/Node:'+ node +'/Server:'+ server)

if len(Serverid) > 0:

print " Following properties will be configured for --> " + server

print " 1. Debug Argument "

print " 2. Http Transports "

print " 3. Ports --> SOAP , DRS , BootStrap ports "

print " 4. JVM heap Size "

print " 5. Virtual host "

print " 6. Classpath "

print " 7. Boot Classpath "

print " 8. Generic JVM argument "

print " 9. Create Server Level Variables "

print " 10. WebContainer Thread Pool Setting"

print " ----------------------------------------------------------------------------------------- "

########################################## configuring JVM debug mode #####################################################

jvm = AdminConfig.list('JavaVirtualMachine', Serverid)

AdminConfig.modify(jvm, [['debugMode', 'false'], ['debugArgs', debug ]])

AdminConfig.save()

print " JVM Debug argument Configured ............."

print " ----------------------------------------------------------------------------------------- "

######################################### Configuring HTTP Transports ######################################################

portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "WC_defaulthost"
portsDict["host"] = host
portsDict["port"] = http
AdminTask.modifyServerPort(server,
["-%s %s" % (key, value) for key, value in portsDict.items()])

portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "WC_defaulthost_secure"
portsDict["host"] = host
portsDict["port"] = http1
AdminTask.modifyServerPort(server,
["-%s %s" % (key, value) for key, value in portsDict.items()])


print " HTTP Transports Configured .............. "

print " ----------------------------------------------------------------------------------------- "


################################################# Configuring Ports ###################################################


######################################################### WAS 6.1 ######################################################

## Bootstrap port

portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "BOOTSTRAP_ADDRESS"
portsDict["host"] = host
portsDict["port"] = bootstrap
AdminTask.modifyServerPort(server,
["-%s %s" % (key, value) for key, value in portsDict.items()])

print " BOOTSTRAP_ADDRESS Configured ........... "

print " ----------------------------------------------------------------------------------------- "

## SOAP Port

portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "SOAP_CONNECTOR_ADDRESS"
portsDict["host"] = host
portsDict["port"] = soap
AdminTask.modifyServerPort(server,
["-%s %s" % (key, value) for key, value in portsDict.items()])

print " Soap Port Configured ...................."

print " ----------------------------------------------------------------------------------------- "


## CSIV2_SSL_MUTUALAUTH_LISTENER_ADDRESS Port

portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "CSIV2_SSL_MUTUALAUTH_LISTENER_ADDRESS"
portsDict["host"] = host
portsDict["port"] = csiv2_multi
AdminTask.modifyServerPort(server,
["-%s %s" % (key, value) for key, value in portsDict.items()])

print " CSIV2_SSL_MUTUALAUTH_LISTENER_ADDRESS Port Configured ......... "

print " ------------------------------------------------------------------------------------------------------------------------ "

## CSIV2_SSL_SERVERAUTH_LISTENER_ADDRESS Port

portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "CSIV2_SSL_SERVERAUTH_LISTENER_ADDRESS"
portsDict["host"] = host
portsDict["port"] = csiv2_server
AdminTask.modifyServerPort(server,
["-%s %s" % (key, value) for key, value in portsDict.items()])

print " CSIV2_SSL_SERVERAUTH_LISTENER_ADDRESS Port Configured .......... "

print " ------------------------------------------------------------------------------------------------------------------------ "

## ORB_LISTENER_ADDRESS Port

portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "ORB_LISTENER_ADDRESS"
portsDict["host"] = host
portsDict["port"] = orb
AdminTask.modifyServerPort(server,
["-%s %s" % (key, value) for key, value in portsDict.items()])

print " ORB_LISTENER_ADDRESS Port Configured .............."

print " ------------------------------------------------------------------------------------------------------------------------ "

## SAS_SSL_SERVERAUTH_LISTENER_ADDRESS Port

portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "SAS_SSL_SERVERAUTH_LISTENER_ADDRESS"
portsDict["host"] = host
portsDict["port"] = sas
AdminTask.modifyServerPort(server,
["-%s %s" % (key, value) for key, value in portsDict.items()])

print " SAS_SSL_SERVERAUTH_LISTENER_ADDRESS Port configured ........ "


print " ------------------------------------------------------------------------------------------------------------------------ "

## WC_adminhost Port

portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "WC_adminhost"
portsDict["host"] = host
portsDict["port"] = adminhost
AdminTask.modifyServerPort(server,
["-%s %s" % (key, value) for key, value in portsDict.items()])


print " WC_adminhost Port Configured ...... "

print " ------------------------------------------------------------------------------------------------------------------------ "

## WC_adminhost_secure Port

portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "WC_adminhost_secure"
portsDict["host"] = host
portsDict["port"] = adminhost1
AdminTask.modifyServerPort(server,
["-%s %s" % (key, value) for key, value in portsDict.items()])


print " WC_adminhost_secure Port Configured ...... "

print " ------------------------------------------------------------------------------------------------------------------------ "

## DCS_UNICAST_ADDRESS Port

portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "DCS_UNICAST_ADDRESS"
portsDict["host"] = host
portsDict["port"] = dcs
portsDict["modifyShared"] = "true"
AdminTask.modifyServerPort(server,
["-%s %s" % (key, value) for key, value in portsDict.items()])


print " DCS_UNICAST_ADDRESS Configured ...... "

print " ------------------------------------------------------------------------------------------------------------------------ "

## SIB_ENDPOINT_ADDRESS Port

portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "SIB_ENDPOINT_ADDRESS"
portsDict["host"] = host
portsDict["port"] = sib
AdminTask.modifyServerPort(server,
["-%s %s" % (key, value) for key, value in portsDict.items()])


print " SIB_ENDPOINT_ADDRESS Port Configured ......... "

print " ------------------------------------------------------------------------------------------------------------------------ "

## SIB_ENDPOINT_SECURE_ADDRESS Port

portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "SIB_ENDPOINT_SECURE_ADDRESS"
portsDict["host"] = host
portsDict["port"] = sib1
AdminTask.modifyServerPort(server,
["-%s %s" % (key, value) for key, value in portsDict.items()])


print " SIB_ENDPOINT_SECURE_ADDRESS Port Configured ......... "

print " ------------------------------------------------------------------------------------------------------------------------ "

## SIB_MQ_ENDPOINT_ADDRESS Port

portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "SIB_MQ_ENDPOINT_ADDRESS"
portsDict["host"] = host
portsDict["port"] = sib_mq
AdminTask.modifyServerPort(server,
["-%s %s" % (key, value) for key, value in portsDict.items()])


print " SIB_MQ_ENDPOINT_ADDRESS Port Configured ......... "

print " ------------------------------------------------------------------------------------------------------------------------ "

## SIB_MQ_ENDPOINT_SECURE_ADDRESS Port

portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "SIB_MQ_ENDPOINT_SECURE_ADDRESS"
portsDict["host"] = host
portsDict["port"] = sib_mq1
AdminTask.modifyServerPort(server,
["-%s %s" % (key, value) for key, value in portsDict.items()])


print " SIB_MQ_ENDPOINT_SECURE_ADDRESS Port Configured ......... "

print " ------------------------------------------------------------------------------------------------------------------------ "

## SIP_DEFAULTHOST Port

portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "SIP_DEFAULTHOST"
portsDict["host"] = host
portsDict["port"] = sip
portsDict["modifyShared"] = "true"
AdminTask.modifyServerPort(server,
["-%s %s" % (key, value) for key, value in portsDict.items()])


print " SIP_DEFAULTHOST Port Configured ......... "

print " ------------------------------------------------------------------------------------------------------------------------ "

## SIP_DEFAULTHOST_SECURE Port

portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "SIP_DEFAULTHOST_SECURE"
portsDict["host"] = host
portsDict["port"] = sip1
portsDict["modifyShared"] = "true"
AdminTask.modifyServerPort(server,
["-%s %s" % (key, value) for key, value in portsDict.items()])


print " SIP_DEFAULTHOST_SECURE Port Configured ......... "

print " ------------------------------------------------------------------------------------------------------------------------ "

print " All Port's Configured ............... "

print " ------------------------------------------------------------------------------------------------------------------------ "


#################################################### configuring JVM heap Size #############################################

AdminConfig.modify(jvm, [['initialHeapSize', minHS ], ['maximumHeapSize', maxHS ]])

AdminConfig.save()

print " JVM heap Size configured ........... "

print " ------------------------------------------------------------------------------------------------------------------------ "

################################################### Configuring WebContainer thread pool Size ################################


tpList=AdminConfig.list('ThreadPool', Serverid).split(lineSep)

for tp in tpList:

tpWebContainer=tp

AdminConfig.show(tpWebContainer)

AdminConfig.modify(tpWebContainer, [['maximumSize', maxtp ]] )

AdminConfig.save()

AdminConfig.modify(tpWebContainer, [['minimumSize', mintp ]] )

AdminConfig.save()


print " WebContainer thread pool Size configured ........... "

print " ----------------------------------------------------------------------------------------------------------------------"

################################################# Creating Virtual Hosts ############################################################

hostname = ["hostname", "*"]

port1 = ["port", http]

port2 = ["port" ,http1 ]

hostAlias1 = [hostname, port1]

hostAlias2 = [ hostname , port2 ]

vh = AdminConfig.getid("/VirtualHost:"+cluster+"/")

if len(vh) == 0 :

vtempl= "default_host(templates/default|virtualhosts.xml#VirtualHost_1)"

parentVhost = AdminConfig.createUsingTemplate('VirtualHost', cellid, [['name', cluster]], vtempl)

AdminConfig.create('HostAlias', parentVhost, hostAlias1 )

AdminConfig.create('HostAlias', parentVhost, hostAlias2 )

AdminConfig.save()

else :

AdminConfig.create('HostAlias', vh, hostAlias1 )

AdminConfig.create('HostAlias', vh, hostAlias2 )

AdminConfig.save()

print " Virtual Host Created .............. "


print " ------------------------------------------------------------------------------------------------------------------------ "


################################################# Creating Variables ###############################################################

############################################ SERVER LEVEL ################################################


varMapserver = AdminConfig.getid('/Cell:'+ cell +'/Node:'+ node +'/Server:'+ server +'/VariableMap:/')

if len(varMapserver) > 0:

AdminConfig.remove(varMapserver)

AdminConfig.save()

varMapserver1 = AdminConfig.create('VariableMap', Serverid, [])

varMapserver2 = AdminConfig.getid('/Cell:'+ cell +'/Node:'+ node +'/Server:'+ server +'/VariableMap:/')

nameattr1 = ['symbolicName', varname1]
valattr1 = ['value', varvalue1]
desc1 = ["description", varname1]
nameattr2 = ['symbolicName', varname2]
valattr2 = ['value', varvalue2]
desc2 = ["description", varname2]
nameattr3 = ['symbolicName', varname3]
valattr3 = ['value', varvalue3 +'/'+ server ]
desc3 = ["description", varname3]
attr1 = [nameattr1, valattr1, desc1]
attr2 = [nameattr2, valattr2, desc2]
attr3 = [nameattr3, valattr3, desc3]
attrs1 = [attr1, attr2, attr3]

entries6 = ['entries', attrs1 ]

AdminConfig.modify(varMapserver2, [entries6] )

AdminConfig.save()

print " Server Level Variables Configured ................ "

print " ------------------------------------------------------------------------------------------------------------------------ "


################################################# Configuring Classpath for AppServer ##############################################


classpath1 = ['classpath', '${'+ varname2 +'}/properties.jar']
classpath2 = ['classpath', '${'+ varname1 +'}/ojdbc14.jar']
classpath3 = ['classpath', '${'+ varname1 +'}/log4j-1.2.4.jar']
classpath4 = ['classpath', '${'+ varname1 +'}/poi-2.5.1-final-20040804.jar']
classpath5 = ['classpath', '${'+ varname1 +'}/jdom.jar']
classpath6 = ['classpath', '${'+ varname1 +'}/idssecl.jar']
classpath7 = ['classpath', '${'+ varname1 +'}/com.ibm.mq.jar']
classpath8 = ['classpath', '${'+ varname1 +'}/com.ibm.mqbind.jar']
classpath9 = ['classpath', '${'+ varname1 +'}/com.ibm.mqjms.jar']
classpath10 = ['classpath', '${'+ varname1 +'}/connector.jar']
classpath11 = ['classpath', '${'+ varname1 +'}/jms.jar']
classpath12 = ['classpath', '${'+ varname1 +'}/jta.jar']
classpath13 = ['classpath', '${'+ varname1 +'}/mqji.jar']
classpath14 = ['classpath', '${'+ varname1 +'}/idsclie.jar']
classpath15 = ['classpath', '${'+ varname2 +'}/'+ server]

AdminConfig.modify(jvm, [classpath1])
AdminConfig.modify(jvm, [classpath2])
AdminConfig.modify(jvm, [classpath3])
AdminConfig.modify(jvm, [classpath4])
AdminConfig.modify(jvm, [classpath5])
AdminConfig.modify(jvm, [classpath6])
AdminConfig.modify(jvm, [classpath7])
AdminConfig.modify(jvm, [classpath8])
AdminConfig.modify(jvm, [classpath9])
AdminConfig.modify(jvm, [classpath10])
AdminConfig.modify(jvm, [classpath11])
AdminConfig.modify(jvm, [classpath12])
AdminConfig.modify(jvm, [classpath13])
AdminConfig.modify(jvm, [classpath14])
AdminConfig.modify(jvm, [classpath15])

AdminConfig.save()

print " Classpath for AppServer Configured ......... "

print " ------------------------------------------------------------------------------------------------------------------------ "

############################################### Configuring Boot Classpath for AppServer ############################################

bootclasspath = ['bootClasspath', '${'+ varname1 +'}/cal141.jar']

AdminConfig.modify(jvm, [bootclasspath])

AdminConfig.save()

print " Boot Classpath for AppServer Configured ............... "

print " ------------------------------------------------------------------------------------------------------------------------ "


############################################# Configuring Generic JVM argument for AppServer ########################################

genericJVMargument = ['genericJvmArguments', JvmArguments]

AdminConfig.modify(jvm, [genericJVMargument])

AdminConfig.save()

print " Generic JVM argument for AppServer Configured ............. "

print " ------------------------------------------------------------------------------------------------------------------------ "


######################################################### Full Resyncronization #########################################################

print " Fully Resyncronizing nodes ........... "

nodelist = AdminTask.listManagedNodes().split(lineSep)

for nodename in nodelist :

####################Identifying the ConfigRepository MBean and assign it to variable######################

repo = AdminControl.completeObjectName('type=ConfigRepository,process=nodeagent,node='+ nodename +',*')

print AdminControl.invoke(repo, 'refreshRepositoryEpoch')

sync = AdminControl.completeObjectName('cell='+ cell +',node='+ nodename +',type=NodeSync,*')

print AdminControl.invoke(sync , 'sync')

print " ----------------------------------------------------------------------------------------- "

print " Full Resyncronization completed "

print " ----------------------------------------------------------------------------------------- "


########################################################## Main Program #############################################################

arglen=len(sys.argv)

num_exp_args=11

if (arglen != num_exp_args):

print "eleven arguments are required. This argument should be a properties file and Server level Variables."

print " ----------------------------------------------------------------------------------------- "

sys.exit(-1)

propFile=sys.argv[0]

properties=Properties();

try:

properties.load(FileInputStream(propFile))

print " ----------------------------------------------------------------------------------------- "

print "Succesfully read property file "+propFile

print " ----------------------------------------------------------------------------------------- "

except:

print "Cannot read property file "+propFile
sys.exit(-1)

print " ----------------------------------------------------------------------------------------- "

node = sys.argv[7]

cluster = sys.argv[8]

server = sys.argv[9]

http = int(properties.getProperty("WC_defaulthost"))

http1 = int(properties.getProperty("WC_defaulthost_secure"))

host = sys.argv[10]

bootstrap = int(properties.getProperty("BOOTSTRAP_ADDRESS"))

soap = int(properties.getProperty("SOAP_CONNECTOR_ADDRESS"))

orb = int(properties.getProperty("ORB_LISTENER_ADDRESS"))

csiv2_multi = int(properties.getProperty("CSIV2_SSL_MUTUALAUTH_LISTENER_ADDRESS"))

csiv2_server = int(properties.getProperty("CSIV2_SSL_SERVERAUTH_LISTENER_ADDRESS"))

adminhost = int(properties.getProperty("WC_adminhost"))

adminhost1 = int(properties.getProperty("WC_adminhost_secure"))

dcs = int(properties.getProperty("DCS_UNICAST_ADDRESS"))

sib = int(properties.getProperty("SIB_ENDPOINT_ADDRESS"))

sib1 = int(properties.getProperty("SIB_ENDPOINT_SECURE_ADDRESS"))

sib_mq = int(properties.getProperty("SIB_MQ_ENDPOINT_ADDRESS"))

sib_mq1 = int(properties.getProperty("SIB_MQ_ENDPOINT_SECURE_ADDRESS"))

sip = int(properties.getProperty("SIP_DEFAULTHOST"))

sip1 = int(properties.getProperty("SIP_DEFAULTHOST_SECURE"))

sas = int(properties.getProperty("SAS_SSL_SERVERAUTH_LISTENER_ADDRESS"))

maxHS = int(properties.getProperty("MAXIMUM_HEAP_SIZE"))

minHS = int(properties.getProperty("MINIMUM_HEAP_SIZE"))

varname1 = sys.argv[1]

varvalue1 = sys.argv[2]

varname2 = sys.argv[3]

varvalue2 = sys.argv[4]

varname3 = sys.argv[5]

varvalue3 = sys.argv[6]

JvmArguments = str(properties.getProperty("GenericJvmArguments"))

maxtp = str(properties.getProperty("MAXIMUM_THREAD_POOL"))

mintp = str(properties.getProperty("MINIMUM_THREAD_POOL"))

debug = str(properties.getProperty("DebugArguments"))

clusterServer(node,cluster,server,http,http1,host,bootstrap,soap,orb,csiv2_multi,csiv2_server,adminhost,adminhost1,dcs,sib,sib1,sib_mq,sib_mq1,sip,sip1,sas,maxHS,minHS,varname1,varvalue1,varname2,varvalue2,varname3,varvalue3,JvmArguments,maxtp,mintp,debug)

############################################################################################################################

Script to configure JDBC, Datasource , J2C Auth, Connection Pool Settting at Cluster level Scope

This Script configure :- 1. JDBC Provider 2. DataSource 3.JAASAuthData 4. Connection Pool Setting


import sys,java
from java.util import Properties
from java.io import FileInputStream
from org.python.modules import time
lineSep = java.lang.System.getProperty('line.separator')

def datasource(cluster,user,password,url,env,jdbc_driver,timeOut,maxConn,minConn,reapTime,unusdTimeout,agedTimeout):

# Declare global variables

global AdminConfig
global AdminControl



## JDBCProvider ##


name = "jdbcOracle"+ env

print " Name of JDBC Provider which will be created ---> " + name

print " ----------------------------------------------------------------------------------------- "

# Gets the name of cell

cell = AdminControl.getCell()

cellid = AdminConfig.getid('/Cell:'+ cell +'/')

print " ----------------------------------------------------------------------------------------- "



# checking for the existence of Cluster


Serverid = AdminConfig.getid('/Cell:'+ cell +'/ServerCluster:'+ cluster +'/')

print " Checking for existence of Server :" + cluster

if len(Serverid) == 0:

print "Cluster doesnot exists "

else:

print "Cluster exist:"+ cluster

print " ----------------------------------------------------------------------------------------- "


## removing old jdbc provider and creating a new jdbc provider

print " Checking for the existence of JDBC Provider :"+ name

s2 = AdminConfig.getid('/Cell:'+ cell +'/ServerCluster:'+ cluster +'/JDBCProvider:'+ name)

if len(s2) > 0:

print " JDBC Provider exists with name :"+ name

print " Removing JDBC Provider with name :"+ name

AdminConfig.remove(s2)

print " JDBC Provider removed "

AdminConfig.save()

print " Saving Configuraion "

print " ----------------------------------------------------------------------------------------- "

## Creating New JDBC Provider ##

print " Creating New JDBC Provider :"+ name

n1 = ["name" , name ]

desc = ["description" , "Oracle JDBC Driver"]

impn = ["implementationClassName" , "oracle.jdbc.pool.OracleConnectionPoolDataSource"]

classpath = ["classpath" , jdbc_driver ]

attrs1 = [n1 , impn , desc , classpath]

jdbc = AdminConfig.create('JDBCProvider' , Serverid , attrs1)

print " New JDBC Provider created :"+ name

AdminConfig.save()

print " Saving Configuraion "

print " ----------------------------------------------------------------------------------------- "

## checking for the existence of JAASAuthData and deleting ##

node = AdminControl.getNode()

alias1 = node +"/"+ env

print " Checking for the existence of JAASAUTHDATA :"+ alias1

jaasAuthDataList = AdminConfig.list("JAASAuthData")

if len(jaasAuthDataList) == 0:

print " Creating New JAASAuthData with Alias name :"+ alias1

sec = AdminConfig.getid('/Cell:'+ cell +'/Security:/')

alias_attr = ["alias" , alias1]

desc_attr = ["description" , "alias"]

userid_attr = ["userId" , user ]

password_attr = ["password" , password]

attrs = [alias_attr , desc_attr , userid_attr , password_attr ]

authdata = AdminConfig.create('JAASAuthData' , sec , attrs)

print " Created new JASSAuthData with Alias name :"+ alias1

AdminConfig.save()

print " Saving Configuraion "

print " ----------------------------------------------------------------------------------------- "

else :

matchFound = 0

jaasAuthDataList = AdminConfig.list("JAASAuthData")

jaasAuthDataList=jaasAuthDataList.split(lineSeparator)

for jaasAuthId in jaasAuthDataList:

getAlias = AdminConfig.showAttribute(jaasAuthId, "alias")

if (cmp(getAlias,alias1) == 0):

print " JAASAuthData exists with name :"+ alias1

print " Removing JAASAuthData with name :"+ alias1

AdminConfig.remove(jaasAuthId)

print " JAASAuthData removed "

AdminConfig.save()

print " Saving Configuraion "

matchFound = 1

break

if (matchFound == 0):

print " No match was found for the given JASSAuthData : "+ alias1

#endIf

print " ----------------------------------------------------------------------------------------- "


## J2C Authentication Entries ##

print " Creating New JAASAuthData with Alias name :"+ alias1

sec = AdminConfig.getid('/Cell:'+ cell +'/Security:/')

alias_attr = ["alias" , alias1]

desc_attr = ["description" , "alias"]

userid_attr = ["userId" , user ]

password_attr = ["password" , password]

attrs = [alias_attr , desc_attr , userid_attr , password_attr ]

authdata = AdminConfig.create('JAASAuthData' , sec , attrs)

print " Created new JASSAuthData with Alias name :"+ alias1

AdminConfig.save()

print " Saving Configuraion "

print " ----------------------------------------------------------------------------------------- "

## DataSource ##

datasource = "DataSource"+ env

print " Name of datasource which will be created on JDBC Provider :"+ name +" is :"+ datasource

ds = AdminConfig.getid('/Cell:'+ cell +'/ServerCluster:'+ cluster +'/JDBCProvider:'+ name)

name1 = ["name" , datasource]

jndi = ["jndiName" , "jdbc/tiers3DS"]

authentication = ["authDataAlias" , alias1]

st_cachesize = ["statementCacheSize" , "150"]

ds_hlpclass = ["datasourceHelperClassname" , "com.ibm.websphere.rsadapter.Oracle10gDataStoreHelper"]

map_configalias_attr=["mappingConfigAlias", "DefaultPrincipalMapping"]

map_attrs=[authentication , map_configalias_attr]

mapping_attr=["mapping", map_attrs]

ds_attr = [name1 , jndi , authentication , st_cachesize , ds_hlpclass ,mapping_attr ]

newds = AdminConfig.create('DataSource' , ds , ds_attr)

print " New DataSource created with name :"+ datasource

AdminConfig.save()

print " Saving Configuraion "

print " ----------------------------------------------------------------------------------------- "

## set the properties for the datasource ##

print " Setting the properties for DataSource :"+ datasource

newds1 = AdminConfig.getid('/Cell:'+ cell +'/ServerCluster:'+ cluster +'/JDBCProvider:'+ name +'/DataSource:'+ datasource)

propSet = AdminConfig.create('J2EEResourcePropertySet' , newds1 , "")

name3 = ["name" , "URL"]

type = ["type" , "java.lang.String"]

required = ["required" , "true"]

value = ["value" , url]

rpAttrs = [name3 , type , required , value]

jrp = AdminConfig.create('J2EEResourceProperty' , propSet , rpAttrs)


print " Properties created for DataSource :"+ datasource

AdminConfig.save()

print " Saving Configuraion "

print " ----------------------------------------------------------------------------------------- "

# Create an associated connection pool for the new DataSource#

print " Creating Connection Pool Setting for DataSource :"+ datasource

timeout = ["connectionTimeout" , timeOut]

maxconn = ["maxConnections" , maxConn]

minconn = ["minConnections" , minConn]

reaptime = ["reapTime" , reapTime]

unusedtimeout = ["unusedTimeout" , unusdTimeout]

agedtimeout = ["agedTimeout" , agedTimeout]

purgepolicy = ["purgePolicy" , "EntirePool"]

connPoolAttrs = [timeout , maxconn , minconn , reaptime , unusedtimeout , agedtimeout , purgepolicy]

AdminConfig.create("ConnectionPool", newds , connPoolAttrs)

print " Connection Pool Setting created for DataSource :"+ datasource

AdminConfig.save()

print " Saving Configuraion "

print " ----------------------------------------------------------------------------------------- "


## Full Syncronization ##

print " Syncronizing configuration with Master Repository "

nodelist = AdminTask.listManagedNodes().split(lineSep)

for nodename in nodelist :

print " Doing Full Resyncronization of node.......... "

####################Identifying the ConfigRepository MBean and assign it to variable######################

repo = AdminControl.completeObjectName('type=ConfigRepository,process=nodeagent,node='+ nodename +',*')

print AdminControl.invoke(repo, 'refreshRepositoryEpoch')

sync = AdminControl.completeObjectName('cell='+ cell +',node='+ nodename +',type=NodeSync,*')

print AdminControl.invoke(sync , 'sync')

#time.sleep(20)

print " ----------------------------------------------------------------------------------------- "

print " Full Resyncronization completed "

print " ----------------------------------------------------------------------------------------- "

#######Restarting Node Agent#########

nodelist = AdminTask.listManagedNodes().split(lineSep)

for nodename in nodelist :

print " Restarting Nodeagent of "+nodename+" node "

na = AdminControl.queryNames('type=NodeAgent,node='+nodename+',*')

AdminControl.invoke(na,'restart','true true')

print " ----------------------------------------------------------------------------------------- "

time.sleep(30)

##########Testing Database Connection################

dsid = AdminConfig.getid('/ServerCluster:'+ cluster +'/JDBCProvider:'+ name +'/DataSource:'+ datasource +'/')

print " Testing Database Connection"

print AdminControl.testConnection(dsid)

print " ----------------------------------------------------------------------------------------- "
####################################################################################################################
####################################################################################################################

#main program starts here

arglen=len(sys.argv)

num_exp_args=2

if (arglen != num_exp_args):

print "Two arguments are required.one of them is property file"

print " ----------------------------------------------------------------------------------------- "

sys.exit(-1)

propFile=sys.argv[0]

properties=Properties();

try:

properties.load(FileInputStream(propFile))

print " ----------------------------------------------------------------------------------------- "

print "Succesfully read property file "+propFile

print " ----------------------------------------------------------------------------------------- "

except:

print "Cannot read property file "+propFile
sys.exit(-1)

print " ----------------------------------------------------------------------------------------- "

cluster = str(properties.getProperty("CLUSTER_NAME"))
env = sys.argv[1]
user = str(properties.getProperty("dbms.userId"))
password = str(properties.getProperty("dbms.password"))
url = str(properties.getProperty("dbms.url"))
jdbc_driver = str(properties.getProperty("JDBC_DRIVER_PATH"))
timeOut = int(properties.getProperty("TIMEOUT"))
maxConn = int(properties.getProperty("MAXCONN"))
minConn = int(properties.getProperty("MINCONN"))
reapTime = int(properties.getProperty("REAPTIME"))
unusdTimeout = int(properties.getProperty("UNUSEDTIMEOUT"))
agedTimeout = int(properties.getProperty("AGEDTIMEOUT"))

datasource(cluster,user,password,url,env,jdbc_driver,timeOut,maxConn,minConn,reapTime,unusdTimeout,agedTimeout)

Script to get the cell name

This Script get the name of the Cell:

import sys,java
from java.util import Properties
from org.python.modules import time
from java.io import FileInputStream

lineSep = java.lang.System.getProperty('line.separator')

global AdminApp
global AdminConfig
global AdminControl


# Getting config ID of cell

cell = AdminControl.getCell()

print " cell="+cell

Cluster Start and Stop Scripts

This Script will start the Cluster on Websphere Application Server:
Script to start Cluster and check for existence of application
Written By Suvash

import sys,java
from java.util import Properties
from java.io import FileInputStream
from org.python.modules import time
lineSep = java.lang.System.getProperty('line.separator')


def startcluster(cluster,appfile):

global AdminApp
global AdminConfig
global AdminControl

cell = AdminControl.getCell()

print " Cell name is --> "+ cell

Cluster = AdminControl.completeObjectName('cell='+ cell +',type=Cluster,name='+ cluster +',*')

state = AdminControl.getAttribute(Cluster, 'state')

if (state == 'websphere.cluster.running'):

print "Cluster --> " + cluster + " is running .......... "

print "Ripple starting cluster ............."

clusterMgr = AdminControl.completeObjectName('cell='+ cell +',type=ClusterMgr,*')

print AdminControl.invoke(clusterMgr, 'retrieveClusters')

Cluster = AdminControl.completeObjectName('cell='+ cell +',type=Cluster,name='+ cluster +',*')

print AdminControl.invoke(Cluster ,'rippleStart')

else:

print "Cluster --> " + cluster + " is stopped "

print "Starting cluster ............... "

clusterMgr = AdminControl.completeObjectName('cell='+ cell +',type=ClusterMgr,*')

AdminControl.invoke(clusterMgr, 'retrieveClusters')

Cluster = AdminControl.completeObjectName('cell='+ cell +',type=Cluster,name='+ cluster +',*')

print AdminControl.invoke(Cluster ,'start')

print " ---------------------------------------------------------------------------------------------- "

application = AdminConfig.getid("/Deployment:"+appfile+"/")

if len(application) > 0:

print " Deployment completed succesfully ........... "


arglen=len(sys.argv)

num_exp_args=1

if (arglen != num_exp_args):

print "One argument is required. This argument should be a properties file."

print " ----------------------------------------------------------------------------------------- "

sys.exit(-1)

propFile=sys.argv[0]

properties=Properties();

try:

properties.load(FileInputStream(propFile))

print " ----------------------------------------------------------------------------------------- "

print "Succesfully read property file "+propFile

print " ----------------------------------------------------------------------------------------- "

except:

print "Cannot read property file "+propFile
sys.exit(-1)

print " ----------------------------------------------------------------------------------------- "


appfile = str(properties.getProperty("APPLICATION_NAME"))

cluster = str(properties.getProperty("CLUSTER_NAME"))

startcluster(cluster,appfile)

This Script will stop Cluster :

Script to stop Cluster
Written By Charanjeet Singh

import sys,java
from java.util import Properties
from java.io import FileInputStream
from org.python.modules import time
lineSep = java.lang.System.getProperty('line.separator')


def stopcluster(cluster):

global AdminApp
global AdminConfig
global AdminControl

cell = AdminControl.getCell()

print " Cell name is --> "+ cell

Serverid = AdminConfig.getid('/Cell:'+ cell +'/ServerCluster:'+ cluster +'/')

memberlist = AdminConfig.showAttribute(Serverid, "members" )

print "test is:"+ memberlist

members = memberlist[1:len(memberlist)-1]

for member in members.split():

node = AdminConfig.showAttribute(member, "nodeName" )

server = AdminConfig.showAttribute(member, "memberName" )

serverId = AdminConfig.getid("/Cell:"+cell+"/Node:"+node+"/Server:"+server+"/")

s1 = AdminControl.completeObjectName('cell='+ cell +',node='+ node +',name='+ server +',type=Server,*')

print " Checking for the running Mbean of server :"+ server

if len(s1) > 0:

print " Server : "+ server +" is running"

print " Stopping Server :"+ server

AdminControl.stopServer(server, node, 'immediate' )

print " Server : "+ server +" stopped"

else :

print "Server : "+ server +" is stopped "

arglen=len(sys.argv)

num_exp_args=1

if (arglen != num_exp_args):

print "One argument is required. This argument should be a properties file."

print " ----------------------------------------------------------------------------------------- "

sys.exit(-1)

propFile=sys.argv[0]

properties=Properties();

try:

properties.load(FileInputStream(propFile))

print " ----------------------------------------------------------------------------------------- "

print "Succesfully read property file "+propFile

print " ----------------------------------------------------------------------------------------- "

except:

print "Cannot read property file "+propFile
sys.exit(-1)

print " ----------------------------------------------------------------------------------------- "



cluster = str(properties.getProperty("CLUSTER_NAME"))

stopcluster(cluster)

Changing Node Agent Port

This Script will change the ports of Node Agent:

WRITTEN BY Suvash
This Script changes node agent ports and picks port value from portsFile.properties

import sys,java
from java.util import Properties
from java.io import FileInputStream
from org.python.modules import time
lineSep = java.lang.System.getProperty('line.separator')

def change_port(bootstrap,orb,csiv2_multi,csiv2_server,dcs,drs,nda,nma1,nma2,sas,soap,host,node):

global AdminApp
global AdminConfig
global AdminControl
global AdminTask

cell = AdminControl.getCell()


portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "BOOTSTRAP_ADDRESS"
portsDict["host"] = host
portsDict["port"] = bootstrap
portsDict["modifyShared"] = "true"
AdminTask.modifyServerPort('nodeagent',
["-%s %s" % (key, value) for key, value in portsDict.items()])

portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "ORB_LISTENER_ADDRESS"
portsDict["host"] = host
portsDict["modifyShared"] = "true"
portsDict["port"] = orb
AdminTask.modifyServerPort('nodeagent',
["-%s %s" % (key, value) for key, value in portsDict.items()])


portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "CSIV2_SSL_SERVERAUTH_LISTENER_ADDRESS"
portsDict["host"] = host
portsDict["modifyShared"] = "true"
portsDict["port"] = csiv2_multi
AdminTask.modifyServerPort('nodeagent',
["-%s %s" % (key, value) for key, value in portsDict.items()])

portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "CSIV2_SSL_MUTUALAUTH_LISTENER_ADDRESS"
portsDict["host"] = host
portsDict["modifyShared"] = "true"
portsDict["port"] = csiv2_server
AdminTask.modifyServerPort('nodeagent',
["-%s %s" % (key, value) for key, value in portsDict.items()])


portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "DCS_UNICAST_ADDRESS"
portsDict["host"] = host
portsDict["modifyShared"] = "true"
portsDict["port"] = dcs
AdminTask.modifyServerPort('nodeagent',
["-%s %s" % (key, value) for key, value in portsDict.items()])

portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "DRS_CLIENT_ADDRESS"
portsDict["host"] = host
portsDict["modifyShared"] = "true"
portsDict["port"] = drs
AdminTask.modifyServerPort('nodeagent',
["-%s %s" % (key, value) for key, value in portsDict.items()])

portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "NODE_DISCOVERY_ADDRESS"
portsDict["host"] = host
portsDict["modifyShared"] = "true"
portsDict["port"] = nda
AdminTask.modifyServerPort('nodeagent',
["-%s %s" % (key, value) for key, value in portsDict.items()])


portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "NODE_IPV6_MULTICAST_DISCOVERY_ADDRESS"
portsDict["host"] = host
portsDict["port"] = nma1
portsDict["modifyShared"] = "true"
AdminTask.modifyServerPort('nodeagent',
["-%s %s" % (key, value) for key, value in portsDict.items()])


portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "NODE_MULTICAST_DISCOVERY_ADDRESS"
portsDict["host"] = host
portsDict["port"] = nma2
portsDict["modifyShared"] = "true"
AdminTask.modifyServerPort('nodeagent',
["-%s %s" % (key, value) for key, value in portsDict.items()])

portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "SAS_SSL_SERVERAUTH_LISTENER_ADDRESS"
portsDict["host"] = host
portsDict["port"] = sas
portsDict["modifyShared"] = "true"
AdminTask.modifyServerPort('nodeagent',
["-%s %s" % (key, value) for key, value in portsDict.items()])

portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "SOAP_CONNECTOR_ADDRESS"
portsDict["host"] = host
portsDict["modifyShared"] = "true"
portsDict["port"] = soap
AdminTask.modifyServerPort('nodeagent',
["-%s %s" % (key, value) for key, value in portsDict.items()])

#--Saving Configuration--#

AdminConfig.save()

## Syncronizing node

nodelist = AdminTask.listManagedNodes().split(lineSep)

for nodename in nodelist :

print " Syncronizing node.......... "

####################Identifying the ConfigRepository MBean and assign it to variable######################

repo = AdminControl.completeObjectName('type=ConfigRepository,process=nodeagent,node='+ nodename +',*')

print AdminControl.invoke(repo, 'refreshRepositoryEpoch')

sync = AdminControl.completeObjectName('cell='+ cell +',node='+ nodename +',type=NodeSync,*')

print AdminControl.invoke(sync , 'sync')

print " ----------------------------------------------------------------------------------------- "

print " Full Resyncronization completed "

print " ----------------------------------------------------------------------------------------- "

if (len(sys.argv)!= 13):

print "you didnt supplied correct number of argument"

else:

bootstrap=sys.argv[0]
orb=sys.argv[1]
csiv2_multi=sys.argv[2]
csiv2_server=sys.argv[3]
dcs=sys.argv[4]
drs=sys.argv[5]
nda=sys.argv[6]
nma1=sys.argv[7]
nma2=sys.argv[8]
sas=sys.argv[9]
soap=sys.argv[10]
host=sys.argv[11]
node=sys.argv[12]


change_port(bootstrap,orb,csiv2_multi,csiv2_server,dcs,drs,nda,nma1,nma2,sas,soap,host,node)

Websphere Application Deployment Script

This jython Script will Install and Update Application on cluster of Websphere Application Server:

WRITTEN BY Suvash

This Script install Application on cluster and map modules to Virtual Hosts

import sys,java
from java.util import Properties
from java.io import FileInputStream
from org.python.modules import time
lineSep = java.lang.System.getProperty('line.separator')


def appinstall(appfile,apppath,cluster,map_modules_cluster,map_modules_vh):

global AdminApp
global AdminConfig
global AdminControl

print " Getting Cell Name .."

cell = AdminControl.getCell()

print " Cell name is --> "+ cell

print " ----------------------------------------------------------------------------------------- "

###############################################################################################

## checking for the existence of application , is application exists then updating it and if it does not exists then installing it

application = AdminConfig.getid("/Deployment:"+appfile+"/")

if len(application) > 0:

print " ----------------------------------------------------------------------------------------- "

print " Application ---> " +appfile+ " is installed on cluster --> " + cluster

print " ----------------------------------------------------------------------------------------- "

print " Updating application --> " + appfile

pathToEAR = apppath

option1 = appfile

option2 = "\'app\'"

option3 = "-operation update -contents " + apppath + " -MapModulesToServers " + map_modules_cluster + " -MapWebModToVH " + map_modules_vh

print AdminApp.update(option1,'app',option3)

AdminConfig.save()

else :

print " Installing App on cluster --> " + cluster

print AdminApp.install(apppath , '[-appname '+appfile+' -cell '+cell+' -cluster '+cluster+' -MapModulesToServers '+map_modules_cluster+' -MapWebModToVH '+map_modules_vh+']')

print " ----------------------------------------------------------------------------- "

print " Application --> " +appfile+ " installed on cluster--> " +cluster

print " ----------------------------------------------------------------------------- "

print " Saving Configuration "

print " ----------------------------------------------------------------------------- "

AdminConfig.save()

print " ----------------------------------------------------------------------------- "

#####################Waiting for the application to expand and then starting the server################

print " Sleeping for 300 seconds after deploying application "

time.sleep(300)

app = AdminApp.isAppReady(appfile)

while (app == 'false'):

app = AdminApp.isAppReady(appfile)

if (app == 'true'):

print " Expansion of ear completed "

###########################Syncronizing Node######################

nodelist = AdminTask.listManagedNodes().split(lineSep)

for nodename in nodelist :

print " Syncronizing node.......... "

####################Identifying the ConfigRepository MBean and assign it to variable######################

repo = AdminControl.completeObjectName('type=ConfigRepository,process=nodeagent,node='+ nodename +',*')

print AdminControl.invoke(repo, 'refreshRepositoryEpoch')

sync = AdminControl.completeObjectName('cell='+ cell +',node='+ nodename +',type=NodeSync,*')

print AdminControl.invoke(sync , 'sync')

print " ----------------------------------------------------------------------------------------- "

print " Full Resyncronization completed "

print " ----------------------------------------------------------------------------------------- "


########################################################################################################

arglen=len(sys.argv)

num_exp_args=3

if (arglen != num_exp_args):

print "Three arguments are required. Two arguments should be a properties file."

print " ----------------------------------------------------------------------------------------- "

sys.exit(-1)

propFile=sys.argv[0]
propFile1=sys.argv[1]

properties=Properties();


try:

properties.load(FileInputStream(propFile))
properties.load(FileInputStream(propFile1))

print " ----------------------------------------------------------------------------------------- "

print "Succesfully read property file "+propFile
print "Succesfully read property file "+propFile1

print " ----------------------------------------------------------------------------------------- "

except:

print "Cannot read property file "+propFile
print "Cannot read property file "+propFile1
sys.exit(-1)

print " ----------------------------------------------------------------------------------------- "


appfile = str(properties.getProperty("APPLICATION_NAME"))

apppath = sys.argv[2]

cluster = str(properties.getProperty("CLUSTER_NAME"))

map_modules_cluster = str(properties.getProperty("MAP_MODULES_TO_SERVER"))

map_modules_vh = str(properties.getProperty("MAP_MODULES_TO_VH"))

print " app file " + appfile
print " apppath " + apppath
print " cluster " + cluster
print " map_modules_cluster " + map_modules_cluster
print " map_modules_vh " + map_modules_vh

appinstall(appfile,apppath,cluster,map_modules_cluster,map_modules_vh)