Appreciations accepted

Vladlen Litvinov, the author: If you have some job offer for me, I'm ready to discuss it. View Vladlen Litvinov's profile on LinkedIn

Password

Thursday, September 26, 2013

Interactive script for IBM BPM offline installation of PAs (Export Part)

Continue the subject about automation of a process of IBM BPM administration what has been initiated here.

Now I publish the shell script for exporting of a snapshot for offline installation.
#!/bin/sh
# V.Litvinov 2013


# Change this to your data
HOSTNAME=host <hostname of Process Center server/use DMserver for cluster>
PORT=8880 <SOAP port>
USER=admin
PASSWORD=password
DM_HOME=/opt/ibm/BPM80/profiles/ProcCtr01 <PC_PROFILE_HOME (use DM profile for custer)>
EXP_FOLDER=/ibm/export <Export folder>

echo
echo "***************************************************************"
echo "*  INTERACTIVE SCRIPT FOR IBM BPM OFFLINE INSTALLATION OF PAs *"
echo "*                      (Export Part)                          *"
echo "***************************************************************"
echo

echo Wait, please........
echo

# Reading Information about PAs using wasadmin
$DM_HOME/bin/wsadmin.sh -lang jython -conntype SOAP -port $PORT -host $HOSTNAME -user $USER -password $PASSWORD -c "print AdminTask.BPMListProcessApplications('[]')" > PAPP.log

# Creating List of PAs (except Toolkits)
declare -a ARRAY
exec 10<PAPP.log
let count=0
while read LINE <&10; do
if [ -n "$LINE" ]
then
    if [[ ${LINE:0:7} = 'Acronym' ]]
    then
    ARRAY[$count]=${LINE:9}
    ((count++))
    fi

    if [[ ${LINE:0:13} = 'Toolkit: true' ]]
    then
    ARRAY[$count-1]=''
    count=$count-1
    fi
fi
done
exec 10>&-

# Changing of working PA
echo LIST OF YOUR PROCESS APPLICATIONS
echo =================================
for (( i=0;i<$count;i++ )); do
echo $i '    '  ${ARRAY[${i}]}
done
echo =================================
echo -n "Enter the number of PA > "
read pa
PANAME=${ARRAY[${pa}]}
echo "You changed PA $PANAME"


# Reading Information about Snapshots using wasadmin
$DM_HOME/bin/wsadmin.sh -lang jython -conntype SOAP -port $PORT -host $HOSTNAME -user $USER -password $PASSWORD -c "print AdminTask.BPMShowProcessApplication('[-containerAcronym ${ARRAY[${pa}]}]')" > $PANAME.log

# Creating List of Snapshots of the current PA
unset ARRAY
exec 11<$PANAME.log
let count=0
while read LINE <&11; do
if [ -n "$LINE" ]
then
    if [[ ${LINE:0:7} = 'Acronym' ]]
    then
    ARRAY[$count]=${LINE:9}
    ((count++))
    fi

    if [[ ${LINE:0:22} = 'State: State[Archived]' ]]
    then
    ARRAY[$count-1]=''
    count=$count-1
    fi
fi
done
exec 11>&-

echo
echo LIST OF SNAPSHOTS
echo =================================
for (( i=1;i<$count;i++ )); do
echo $i '    '  ${ARRAY[${i}]}
done
echo =================================
echo -n "Enter the number of Snapshot > "
read pa
SNNAME=${ARRAY[${pa}]}
echo "You changed Snapshot $SNNAME of PA $PANAME"

# Reading Information about Servers using wasadmin
$DM_HOME/bin/wsadmin.sh -lang jython -conntype SOAP -port $PORT -host $HOSTNAME -user $USER -password $PASSWORD -c "print AdminTask.BPMListServers('[]')" > SERVERS.log

# Creating List of Snapshots of the current PA
unset ARRAY
exec 12<SERVERS.log
let count=0
while read LINE <&12; do
if [ -n "$LINE" ]
then
    if [[ ${LINE:0:6} = 'Name: ' ]]
    then
    ARRAY[$count]=${LINE:6}
    ((count++))
    fi

    if [[ ${LINE:0:14} = 'URL: corbaname' ]]
    then
    ARRAY[$count-1]=''
    count=$count-1
    fi
fi
done
exec 12>&-

echo
echo LIST OF SERVERS
echo =================================
for (( i=0;i<$count;i++ )); do
echo $i '    '  ${ARRAY[${i}]}
done
echo =================================
echo -n "Enter the number of Server > "
read pa
SERVNAME=${ARRAY[${pa}]}
echo "You changed Snapshot $SNNAME of PA $PANAME for installation on $SERVNAME"

# Creating Offline Package using wasadmin
$DM_HOME/bin/wsadmin.sh -lang jython -conntype SOAP -port $PORT -host $HOSTNAME -user $USER -password $PASSWORD -c "AdminTask.BPMCreateOfflinePackage  ('[-containerAcronym $PANAME -containerSnapshotAcronym $SNNAME -containerTrackAcronym Main -serverName $SERVNAME]')" > BPMCreateOfflinePackage.log

# Verifing the result of BPMCreateOfflinePackage
unset ARRAY
exec 13<BPMCreateOfflinePackage.log
let count=0
bpmc="BPMCreateOfflinePackage not passed. See logs"
while read LINE <&13; do
if [ -n "$LINE" ]
then
        if [[ ${LINE:1:31} = 'BPMCreateOfflinePackage passed.' ]]
        then
        bpmc="BPMCreateOfflinePackage passed successfully"
        fi
    ARRAY[$count]=${LINE}
    ((count++))
fi
done
exec 13>&-

echo
echo RESULT OF BPMCreateOfflinePackage
echo =================================
echo $bpmc
echo
if [[ ${bpmc:0:45} = 'BPMCreateOfflinePackage not passed. See logs' ]]
then
    for (( i=0;i<$count;i++ )); do
    echo ${ARRAY[${i}]}
    done
fi

# Extracting Offline Package using wasadmin
$DM_HOME/bin/wsadmin.sh -lang jython -conntype SOAP -port $PORT -host $HOSTNAME -user $USER -password $PASSWORD -c "AdminTask.BPMExtractOfflinePackage ('[-containerAcronym $PANAME -containerSnapshotAcronym $SNNAME -containerTrackAcronym Main -serverName $SERVNAME -outputFile $EXP_FOLDER/$PANAME$SNNAME.zip]')" > BPMExtractOfflinePackage.log

# Verifing the result of BPMExtractOfflinePackage
unset ARRAY
exec 14<BPMExtractOfflinePackage.log
let count=0
bpmc="BPMExtractOfflinePackage not passed. See logs"
while read LINE <&14; do
if [ -n "$LINE" ]
then
        if [[ ${LINE:1:32} = 'BPMExtractOfflinePackage passed.' ]]
        then
        bpmc="BPMExtractOfflinePackage passed successfully"
        fi
    ARRAY[$count]=${LINE}
    ((count++))
fi
done
exec 14>&-

echo
echo RESULT OF BPMExtractOfflinePackage
echo ==================================
echo $bpmc
echo
if [[ ${bpmc:0:45} = 'BPMExtractOfflinePackage not passed. See logs' ]]
then
    for (( i=0;i<$count;i++ )); do
    echo ${ARRAY[${i}]}
    done
fi
echo
echo -n "Press Enter for exit > "
read

# Deleting of temporary files
rm BPMCreateOfflinePackage.log
rm BPMExtractOfflinePackage.log
rm SERVERS.log
rm PAPP.log
rm $PANAME.log





After starting of the script you'll see this dialog (for example):

admin@devserver:~> ./export.sh

*********************************************************************
*  INTERACTIVE SCRIPT FOR IBM BPM OFFLINE INSTALLATION OF PAs *
*********************************************************************

Wait, please........

LIST OF YOUR PROCESS APPLICATIONS
=================================
0      PATEST

1      TSET
2      KGB
3      GTP
4      AFS
5      RPT
6      SDT
7      UATR
=================================
Enter the number of PA > 2
You changed PA KGB

LIST OF SNAPSHOTS
=================================
1      1.17.07
2      1.18.00
3      1.18.01
4      1.18.02
5      1.18.03
=================================
Enter the number of Snapshot > 5
You changed Snapshot 1.18.03 of PA KGB

LIST OF SERVERS
=================================
0      testserver
1      prodserver
=================================
Enter the number of Server > 1
You changed Snapshot 1.18.03 of PA KGB for installation on testserver

RESULT OF BPMCreateOfflinePackage
=================================
BPMCreateOfflinePackage passed successfully


RESULT OF BPMCreateOfflinePackage
=================================
BPMExtractOfflinePackage passed successfully


Press Enter for exit >

 


Enjoy!


No comments:

Post a Comment