# @(#)69 1.1 src/43haes/usr/sbin/cluster/sa/oraappsrv/sbin/ASConfig.sh, hacmp, 61haes_r714 11/28/11 15:03:40 # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # 61haes_r714 src/43haes/usr/sbin/cluster/sa/oraappsrv/sbin/ASConfig.sh 1.1 # # Licensed Materials - Property of IBM # # Restricted Materials of IBM # # COPYRIGHT International Business Machines Corp. 2009,2010 # All Rights Reserved # # US Government Users Restricted Rights - Use, duplication or # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. # # IBM_PROLOG_END_TAG #----------------------------------------------------------------------------- # Global Definitions: #----------------------------------------------------------------------------- . /usr/es/sbin/cluster/sa/oraappsrv/sbin/IO . /usr/es/sbin/cluster/sa/oraappsrv/sbin/ASUtilities #----------------------------------------------------------------------------- # Functions: # osaASDumpCfg # osaASGetCfg # osaASGetResourceGroups # osaASGetMetadata # osaASGetNodes # osaASGetResource # osaASGetConfiguredInstances #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- # Function: # osaASDumpCfg # # Purpose: # Dump allASInstances and allASComponents to App Discovery database # `allASInstances' is just an array of strings (instance names) # `allASComponents' contains instance name with index as key and a # component as value. # # For instance, # allASComponents["as1_0"]="OC4J" # allASComponents["as1_1"]="OID" # allASComponents["as1_2"]="SSO" # where, `as1' is the AS instance name, consisting of three components # OC4J, OID and SSO. # # Used this since there is no easy way to handle array of arrays. # The following function is called after one has parsed the OPMN # configuration file, i.e., both arrays have been instantiated. # # Arguments: # (1) AS Instance Name # (2) Application Name (Smart Assist) for storing config data # # Returns: # 0 on success # 1 on failure # function osaASDumpCfg { [[ "$VERBOSE_LOGGING" == "high" ]] && set -x typeset id=$1 typeset app_id=$2 typeset -A allcomps typeset comp typeset instance_name=${id//\./\_} typeset -i x=0 for comp in ${!allASComponents[*]}; do component=${comp##$instance_name} if [[ $component != $comp ]]; then # match found allcomps[$x]=${allASComponents[$comp]} (( x+=1 )) fi done if [[ (-z $id) || (${#allcomps[*]} -le 0) ]]; then osaError "No components for given instance ["$id"] found." else claddsaapp -a $app_id components="${allcomps[*]}" fi } #----------------------------------------------------------------------------- # Function: # osaASGetCfg # # Purpose: # Fetches component names that belong to a given instance name. # # Arguments: # (1) id: Instance name/ID whose components we are looking for. # (2) allcomps: Array name which is populated with all components for # `inst' # Returns: # 0 on Success # 1 on failure # function osaASGetCfg { [[ "$VERBOSE_LOGGING" == "high" ]] && set -x typeset id=$1 typeset -n allcomps=$2 typeset comps=$(clquerysaapp -a $id components | sed 's/^components=//') typeset -i index=0 for comp in $comps; do allcomps[$index]=$comp (( index = $index + 1 )) done } #---------------------------------------------------------------------------- # Function: # osaASGetResourceGroups # # Purpose: # Get a list of HACMP resource groups for the specified application name # # Arguments: # (1) Application Name # # Output: # List of HACMP resource groups # # Returns: # 0 on success # 1 on failure # function osaASGetResourceGroups { [[ "$VERBOSE_LOGGING" == "high" ]] && set -x typeset appid=$1 typeset name value odmget -q "sa_key=$appid" HACMPgroup | while IFS='=' read name value do name=$(echo $name) [[ "$name" == "group" ]] && { value=${value//\"/} echo $(echo $value) } done } #---------------------------------------------------------------------------- # Function: # osaASGetMetadata # # Purpose: # Get HACMPsa_metadata for a particular HACMP application, name name/value # pair. # # Arguments: # (1) Application Name # (2) Name of the name/value pair # # Output: # Value(s) of the name/value pair # # Return: # 0 on success # 1 on failure # function osaASGetMetadata { [[ "$VERBOSE_LOGGING" == "high" ]] && set -x typeset appid=$1 typeset name=$2 clquerysaapp -a $appid | grep $name | awk -F= '{ print $2 }' } #---------------------------------------------------------------------------- # Function: # osaASGetNodes # # Purpose: # Get a list of nodes from resource groups that belong to the application # # Arguments: # (1) Application Name # # Output: # List of nodes, list of nodes is ordered based on appearance in # participating node list. # # Returns: # 0 on success # 1 on failure # function osaASGetNodes { [[ "$VERBOSE_LOGGING" == "high" ]] && set -x typeset appid=$1 typeset arrNodes typeset RGS=$(osaASGetResourceGroups $appid) # # Get a list of nodes for the application, need to preserve the order # in which the nodes are presented in the resource group list(s) # for rg in $RGS; do set -a eval $(clvt query resource_group $rg | grep NODES) set +a for nodeA in $NODES; do found=0 for nodeB in $arrNodes; do [[ "$nodeA" == "$nodeB" ]] && found=1 done (( $found == 0 )) && arrNodes="$arrNodes $nodeA" done done echo $arrNodes } #---------------------------------------------------------------------------- # Function: # osaASGetResource # # Purpose: # Get the value of a particular resource type given the application name # # Arguments: # (1) Application Name # (2) Resource type (i.e. SERVICE_LABEL) # # Output: # List of resources defined to HACMP of the specified type # # Return: # 0 on success # 1 on failure # function osaASGetResource { [[ "$VERBOSE_LOGGING" == "high" ]] && set -x typeset appid=$1 typeset rName=$2 typeset RGS=$(osaASGetResourceGroups $appid) for rg in $RGS; do clvt query resource_group $rg | grep $rName | awk -F= '{ print $2 }' | sed -e "s/\"//g" done } #---------------------------------------------------------------------------- # Function: # osaASGetConfiguredInstances # # Purpose: # Output a list of already configured to HACMP AS instances (AFC or CFC) # # Arguments: # n/a # # Returns: # 0 on success # function osaASGetConfiguredInstances { [[ "$VERBOSE_LOGGING" == "high" ]] && set -x typeset -n dbinsts=$1 typeset -i index=0 /usr/bin/odmget -q "name=ORACLE_AS_INSTANCE" HACMPsa_metadata | while IFS='=' read name value; do name=$(echo $name) [[ "$name" == "value" ]] && { value=$(echo $value) dbinsts[$index]=${value//\"/} (( index += 1 )) } done return 0 }