#!/bin/ksh93 # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # 61haes_r720 src/43haes/lib/ksh93/hacmp/KLIB_HACMP_list_dependencies.sh 1.4 # # Licensed Materials - Property of IBM # # COPYRIGHT International Business Machines Corp. 2010,2015 # 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 # @(#)04 1.4 src/43haes/lib/ksh93/hacmp/KLIB_HACMP_list_dependencies.sh, hacmp.assist, 61haes_r720, 1525A_hacmp720 6/10/15 16:20:10 #============================================================================ # # Name: KLIB_HACMP_list_dependencies # # Description: This is the main, FPATH function that is invoked by clmgr # to collect resource group dependency names. It uses the # "clrgdependency" utility to generate the list of names unless # a search is being conducted. In the case of a search, the # associated FPATH function, KLIB_HACMP_get_dependency_attributes # is invoked in verbose mode. The resulting data set is then # passed through the "search_properties()" function to arrive at # a set of outputs that matches the provided search parameters. # # Inputs: See the "devDoc()" function at the bottom of this file. # # Outputs: The list array is populated with one dependency per entry. # The only other outputs are any error messages that might be # needed. # # Returns: Zero if no errors are detected. Otherwise, an appropriate # non-zero value is returned. Refer to the "RETURN" section # of the "devDoc()" function at the bottom of this file for # the standard return code values/meanings for clmgr. # #============================================================================ function KLIB_HACMP_list_dependencies { LINENO=2 . $HALIBROOT/log_entry "$0()" "$CL" : version=1.4, src/43haes/lib/ksh93/hacmp/KLIB_HACMP_list_dependencies.sh, hacmp.assist, 61haes_r720, 1525A_hacmp720 : INPUTS: $* typeset -n list=$1 shift if [[ -n $2 && $2 != *=* ]]; then typeset -n id_list=$2 shift fi [[ $CLMGR_LOGGING == 'med' ]] && set +x # Only trace param values #================================================================ : Check for a defined cluster. No need to continue without one. #================================================================ CL=$LINENO isClusterDefined if (( $? != RC_SUCCESS )); then log_return_msg "$RC_MISSING_DEPENDENCY" "$0()" "$LINENO" return $? fi #=================================== : Declare and initialize variables #=================================== typeset -A queries typeset -u attr= typeset -i INDEX=0 i=0 j=0 longest=0 rc=$RC_SUCCESS typeset -A pcdeps stopafterdeps startafterdeps typeset parent= child= dep= value= OUTPUT= #=================================================== : Check for any specified attribute=value pairs. : If any are found, use those to query the output. #=================================================== while (( $# > 0 )); do value="$1" if [[ $value == *=* ]]; then attr=${value%%=*} # "attr" makes this uppercase queries[$attr]="${value#*=}" fi shift done if (( ${#queries[*]} == 0 )); then # List all ## ## ACQUIRE/RELEASE ORDER ## print "$0()[$LINENO]($SECONDS): clrgorder -s | grep -v '#'" >>$CLMGR_TMPLOG # Always log commands OUTPUT=$(clrgorder -s) print "$0()[$LINENO]($SECONDS): clrgorder RC: $?" >>$CLMGR_TMPLOG # Always log command result print -- "$OUTPUT" | grep -v '#' |\ IFS=: read sel_acq par_acq ser_rel par_rel for rg in ${par_acq//,/ }; do [[ -n $dep ]] && dep="$dep," dep="$dep$rg" done if [[ $dep != *([[:space:]]) ]]; then list[$INDEX]="$dep (ACQUIRE_IN_PARALLEL)" (( INDEX++ )) fi dep= for rg in ${sel_acq//,/ }; do [[ -n $dep ]] && dep="$dep," dep="$dep$rg" done if [[ $dep != *([[:space:]]) ]]; then list[$INDEX]="$dep (ACQUIRE_SERIALLY)" (( INDEX++ )) fi dep= for rg in ${par_rel//,/ }; do [[ -n $dep ]] && dep="$dep," dep="$dep$rg" done if [[ $dep != *([[:space:]]) ]]; then list[$INDEX]="$dep (RELEASE_IN_PARALLEL)" (( INDEX++ )) fi dep= for rg in ${ser_rel//,/ }; do [[ -n $dep ]] && dep="$dep," dep="$dep$rg" done if [[ $dep != *([[:space:]]) ]]; then list[$INDEX]="$dep (RELEASE_SERIALLY)" (( INDEX++ )) fi ## ## PARENT/CHILD ## print "$0()[$LINENO]($SECONDS): clrgdependency -t PARENT_CHILD -sl | grep -v '#'" >>$CLMGR_TMPLOG # Always log commands OUTPUT=$(clrgdependency -t PARENT_CHILD -sl) print "$0()[$LINENO]($SECONDS): clrgdependency RC: $?" >>$CLMGR_TMPLOG # Always log command result print -- "$OUTPUT" | grep -v '#' |\ while read parent child; do if [[ -n ${pcdeps[$parent]} ]]; then pcdeps[$parent]="${pcdeps[$parent]},$child" else pcdeps[$parent]=$child fi done for parent in ${!pcdeps[*]}; do list[$INDEX]="${parent}+${pcdeps[$parent]} (PARENT_CHILD)" (( INDEX++ )) done ## ## STOP AFTER ## print "$0()[$LINENO]($SECONDS): clrgdependency -t STOP_AFTER -sl | grep -v '#'" >>$CLMGR_TMPLOG # Always log commands OUTPUT=$(clrgdependency -t STOP_AFTER -sl) print "$0()[$LINENO]($SECONDS): clrgdependency RC: $?" >>$CLMGR_TMPLOG # Always log command result print -- "$OUTPUT" | grep -v '#' |\ while read source target; do if [[ -n ${stopafterdeps[$target]} ]]; then stopafterdeps[$target]="${stopafterdeps[$target]},$source" else stopafterdeps[$target]=$source fi done for target in ${!stopafterdeps[*]}; do list[$INDEX]="${target}+${stopafterdeps[$target]} (STOP_AFTER)" (( INDEX++ )) done ## ## START AFTER ## print "$0()[$LINENO]($SECONDS): clrgdependency -t START_AFTER -sl | grep -v '#'" >>$CLMGR_TMPLOG # Always log commands OUTPUT=$(clrgdependency -t START_AFTER -sl) print "$0()[$LINENO]($SECONDS): clrgdependency RC: $?" >>$CLMGR_TMPLOG # Always log command result print -- "$OUTPUT" | grep -v '#' |\ while read source target; do if [[ -n ${startafterdeps[$target]} ]]; then startafterdeps[$target]="${startafterdeps[$target]},$source" else startafterdeps[$target]=$source fi done for target in ${!startafterdeps[*]}; do list[$INDEX]="${target}+${startafterdeps[$target]} (START_AFTER)" (( INDEX++ )) done ## ## SAME SITE ## print "$0()[$LINENO]($SECONDS): clrgdependency -t SITECOLLOCATION -sl | grep -v '#'" >>$CLMGR_TMPLOG # Always log commands OUTPUT=$(clrgdependency -t SITECOLLOCATION -sl) print "$0()[$LINENO]($SECONDS): clrgdependency RC: $?" >>$CLMGR_TMPLOG # Always log command result print -- "$OUTPUT" | grep -v '#' |\ while read dep; do dep=${dep//+([[:space:]])/,} list[$INDEX]="$dep (SAME_SITE)" (( INDEX++ )) done ## ## SAME NODE ## print "$0()[$LINENO]($SECONDS): clrgdependency -t NODECOLLOCATION -sl | grep -v '#'" >>$CLMGR_TMPLOG # Always log commands OUTPUT=$(clrgdependency -t NODECOLLOCATION -sl) print "$0()[$LINENO]($SECONDS): clrgdependency RC: $?" >>$CLMGR_TMPLOG # Always log command result print -- "$OUTPUT"| grep -v '#' |\ while read dep; do dep=${dep//+([[:space:]])/,} list[$INDEX]="$dep (SAME_NODE)" (( INDEX++ )) done ## ## DIFFERENT NODES ## print "$0()[$LINENO]($SECONDS): clrgdependency -t ANTICOLLOCATION -sl | grep -v '#'" >>$CLMGR_TMPLOG # Always log commands OUTPUT=$(clrgdependency -t ANTICOLLOCATION -sl) print "$0()[$LINENO]($SECONDS): clrgdependency RC: $?" >>$CLMGR_TMPLOG # Always log command result print -- "$OUTPUT" | grep -v '#' |\ while IFS=: read high int low; do high=${high//+([[:space:]])/,} int=${int//+([[:space:]])/,} low=${low//+([[:space:]])/,} if [[ -n "$high$int$low" && "$high$int$low" != "::" ]]; then list[$INDEX]="${high}+${int}+${low} (DIFFERENT_NODES)" (( INDEX++ )) fi done else # A search was specified typeset -A allProperties CL=$LINENO CLMGR_VERBOSE=1 KLIB_HACMP_get_dependency_attributes "" allProperties CL=$LINENO search_properties queries allProperties rc=$? if (( $rc == RC_SUCCESS )); then for key in ${!allProperties[*]}; do [[ $key != NAME@(|+([0-9])) ]] && continue list[$INDEX]=${allProperties[$key]} (( INDEX++ )) done fi fi if (( $rc == RC_SUCCESS )); then for (( i=0; i longest )) && longest=${#dep} done (( longest += 3 )) for (( i=0; i # pod2text -c # pod2text -c --code # pod2html # # However, the more important use for this information is that # it is parsed by clmgr to display the syntax for this file's # operation. The information in the "SYNOPSIS" section is used # for this purpose. This feature was originally implemented # using the man page information. However, in a code review it # was pointed out that this approach had to be changed because # customers do not have to install the man pages! Therefore, a # built-in dependency on man page information would break the # automatic help feature of clmgr. So the SYNPOSIS section must # be used instead. # # IMPORTANT: As a result of this, it is imperative that the # information in this SYNOPSIS be kept in sync # with the man page information, which is owned # by the IDD team. # # Inputs: None. # # Outputs: None. # # Returns: n/a (not intended to be invoked) # #============================================================================ function devDoc { : <<'=cut' >/dev/null 2>&1 =head1 NAME KLIB_HACMP_list_dependencies =head1 VERSION Version Number: 1.4 Last Extracted: 6/16/15 17:51:12 Last Changed: 6/10/15 16:20:10 Path, Component, Release(, Level): src/43haes/lib/ksh93/hacmp/KLIB_HACMP_list_dependencies.sh, hacmp.assist, 61haes_r720, 1525A_hacmp720 =head1 SYNOPSIS clmgr query dependency NOTE: the alias for "dependency" is "de". =head1 DESCRIPTION Displays the currently configured set of resource group dependencies. =head1 ARGUMENTS 1. list [REQUIRED] [hash ref] An associative array within which data about the queried objects can be returned to the caller. =head1 RETURN 0: no errors were detected; the operation appears to have been successful 1: a general error has occurred 2: a specified resource does not exist, or could not be found 3: some required input was missing 4: some detected input was incorrect in some way 5: a required dependency does not exist 6: a specified search failed to match any data =head1 COPYRIGHT COPYRIGHT International Business Machines Corp. 2010,2015 All Rights Reserved =cut } # End of "devDoc()" #============================================================================== # The following, comment block attempts to enforce coding standards when this # file is edited via emacs or vim. This block _must_ appear at the very end # of the file, or the editor will not find it, and it will be ignored. #============================================================================== # Local Variables: # indent-tabs-mode: nil # tab-width: 4 # End: #============================================================================== # vim: tabstop=4 shiftwidth=4 expandtab #==============================================================================