Thursday, 16 January 2014

Shell script to Automate the process of Retiring and Activation of Multiple composites in different domain at one time.

blogger

Shell script to Automate the process of Retiring and Activation of Multiple composites in different domain at one time.
Hello to viewer,

Here is the Shell script to Automate the process of Retiring and Activation of Multiple composites in different domain at one time.

Benefit: Some time we are required to stop the Inflow of the data whenever we need to do any release in order to avoid any data failure or data loss.At that time we can use this script to Retire multiple composite in different domain that are getting data from external resource.
This can be one of the scenario ,however there can be several other reason.

You just need to follow the below steps :

Step 1) Create the directory structure as below:

cd /shared/fmw/build/Myscript/retservice

Step 2) Create Myservicelist.txt file under current directory "retservice"

This file contains the details of composites that we need to retire in below format. File can contains entry from different domain as shown below in given format.

Format:

composite_name,version,partition_name,domain_name

Example:
               Mycomposite,1.0.0,Mypartition,MyDomain.
               Mycomposite1,1.0.0,Mypartition1,MyDomain1

Step 3) Create "MyEnv.txt" in current directory file that contains details of your Environment

# My_MyDomain deployment server weblogic
 My_MyDomain_serverURL=http://host : managed_server_port
 My_MyDomain_user=user
 My_MyDomain_password=password
 My_MyDomain_host=host
 My_MyDomain_port=managed_server_port
 My_MyDomain_adminhost=admin_host
 My_MyDomain_adminport=admin_port


# My_MyDomain1 deployment server weblogicMy_MyDomain1_serverURL=http://host : managed_server_port
 My_MyDomain1_user=user
 My_MyDomain1_password=password
 My_MyDomain1_host=host
 My_MyDomain1_port=managed_server_port
 My_MyDomain1_adminhost=admin_host
 My_MyDomain1_adminport=admin_port


Step 3) Create "retireservice.py" in the current directory that executes the wlst command.


import sys
sca_retireComposite(sys.argv[1],sys.argv[2],sys.argv[3],sys.argv[4],sys.argv[5],sys.argv[6],partition=sys.argv[7])



Step 4) Create "retireComposite.sh" in the current directory that calls the python script.


#!/bin/sh
# set up WL_HOME, the root directory of your WebLogic installation
WL_HOME="wl_home"

umask 027

# set up common environment
WLS_NOT_BRIEF_ENV=true
. "${WL_HOME}/server/bin/setWLSEnv.sh"

CLASSPATH="${CLASSPATH}${CLASSPATHSEP}${FMWLAUNCH_CLASSPATH}${CLASSPATHSEP}${DERBY_CLASSPATH}${CLASSPATHSEP}${DERBY_TOOLS}${CLASSPATHSEP}${POINTBASE_CLASSPAT
H}${CLASSPATHSEP}${POINTBASE_TOOLS}"

if [ "${WLST_HOME}" != "" ] ; then
        WLST_PROPERTIES="-Dweblogic.wlstHome='${WLST_HOME}' ${WLST_PROPERTIES}"
        export WLST_PROPERTIES
fi

#echo
#echo CLASSPATH=${CLASSPATH}

JVM_ARGS="-Dprod.props.file='${WL_HOME}'/.product.properties ${WLST_PROPERTIES} ${JVM_D64} ${MEM_ARGS} ${CONFIG_JVM_ARGS}"
    while read LINE; do
      domain=$(echo "$LINE" | awk -F, '{ print $4 }');
      servicename=$(echo "$LINE" | awk -F, '{ print $1 }');
      version=$(echo "$LINE" | awk -F, '{ print $2 }');
      partition=$(echo "$LINE" | awk -F, '{ print $3 }');
          while read LINE1; do
          temp=$(echo "$LINE1" | grep $2'_'$domain'_adminhost'| awk -F= '{ print $2 }');
          if [ "$temp" != "" ]; then
          targethost=$temp;
          fi
          temp=$(echo "$LINE1" | grep $2'_'$domain'_port'| awk -F= '{ print $2 }');
          if [ "$temp" != "" ]; then
          targetport=$temp;
          fi
          temp=$(echo "$LINE1" | grep $2'_'$domain'_user'| awk -F= '{ print $2 }');
          if [ "$temp" != "" ]; then
          user=$temp;
          fi
          temp=$(echo "$LINE1" | grep $2'_'$domain'_password'| awk -F= '{ print $2 }');
          if [ "$temp" != "" ]; then
          password=$temp;
          fi
          done < $2'Env'.txt
    ORACLE_HOME/common/bin/wlst.sh retireservice.py ${targethost} ${targetport} ${user} ${password} $servicename $version $partition > output.txt
    done < $1'servicelist'.txt

                                
Note: Change the value of wl_home, ORACLE_HOME according to your environment.

How to execute this:

It will require two parameter.

sh retireComposite.sh My My ( $1'servicelist'.txt and $2'Env'.txt , Hope you understand the difference between Two twins My ;))

After this just refersh the FARM and verify the composite.

For Activation : You jus need to change the wlst command in retireservice.py rather you should prefer to give some meaning full name . Replace retireservice with activateservice, retireComposite with activateComposite and retservice with actservice.

import sys
sca_activateComposite(sys.argv[1],sys.argv[2],sys.argv[3],sys.argv[4],sys.argv[5],sys.argv[6],partition=sys.argv[7])

Thanks a lot for your patience!!!

Regards
-Ashish

No comments:

Post a Comment