#!/bin/ksh93 # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # 61haes_r720 src/43haes/lib/ksh93/hacmp/KLIB_HACMP_list_repositories.sh 1.13 # # Licensed Materials - Property of IBM # # COPYRIGHT International Business Machines Corp. 2012,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 # @(#)18 1.13 src/43haes/lib/ksh93/hacmp/KLIB_HACMP_list_repositories.sh, hacmp.assist, 61haes_r720, 1531B_hacmp720 7/29/15 10:54:43 #============================================================================ # # Name: KLIB_HACMP_list_repositories # # Description: This is the main, FPATH function that is invoked by clmgr to # collect repository names and PVIDs. It uses the "clodmget" # utility to read data from the "HACMPsircol" ODM 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_repository_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 repository per entry, # with the active repository first, followed by any backup # repositories. The format of each repository entry is # " ()". 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_repositories { LINENO=2 . $HALIBROOT/log_entry "$0()" "$CL" : version=1.13, src/43haes/lib/ksh93/hacmp/KLIB_HACMP_list_repositories.sh, hacmp.assist, 61haes_r720, 1531B_hacmp720 : INPUTS: $* typeset -n list=$1 shift typeset -i RETURN_NODES=0 if [[ -n $1 && $1 != *=* ]]; then typeset -n NODE_MAP=$1 shift RETURN_NODES=1 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 rc=$RC_UNKNOWN count=0 typeset REPOSITORIES= value= typeset disk= DISK_DATA= BACKUPS= NODES= SITE= REQ_SITE="" typeset DISK_NAME= DISK_PVID= DISK_UUID= REFNODE= REM= #=================================================== : 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 if [[ $attr == "SITE" ]]; then REQ_SITE=${value#*=} else queries[$attr]="${value#*=}" fi fi shift done if (( ${#queries[*]} == 0 )); then # List all if [[ $CLUSTER_TYPE == "LC" ]]; then for SITE in $(clodmget -n -f name HACMPsite); do [[ -n $REQ_SITE && $REQ_SITE != $SITE ]] && continue NODES=$(clodmget -n -f nodelist -q name=$SITE HACMPsite) NODES=${NODES//+([[:space:]])/ } : Retrieve the name of the active repository disk for $SITE for disk in $(clodmget -n -f repository -q name="${SITE}_sircol" HACMPsircol); do if [[ " $NODES " == *\ $LOCAL_NODE\ * ]]; then lspv | grep -w $disk | read DISK_DATA junk elif [[ -n $NODES ]]; then $CLRSH ${NODES%% *} "/usr/sbin/lspv | /usr/bin/grep -w $disk" | read DISK_DATA junk fi if [[ -n $DISK_DATA ]]; then REPOSITORIES[$count]="_$disk:$DISK_DATA:$NODES:$SITE" (( count++ )) fi done : Retrieve the names of any backup repository disks for $SITE BACKUPS=$(clodmget -n -f backup_repository -q name="${SITE}_sircol" HACMPsircol) for disk in ${BACKUPS//,/ }; do if [[ " $NODES " == *\ $LOCAL_NODE\ * ]]; then lspv | grep -w $disk | read DISK_DATA junk elif [[ -n $NODES ]]; then $CLRSH ${NODES%% *} "/usr/sbin/lspv | /usr/bin/grep -w $disk" | read DISK_DATA junk fi if [[ -n $DISK_DATA ]]; then REPOSITORIES[$count]="_$disk:$DISK_DATA:$NODES:$SITE" (( count++ )) fi done [[ -n $REQ_SITE ]] && break done else NODES=$(clnodename) NODES=${NODES//+([[:space:]])/ } : Retrieve the name of the active repository disk for disk in $(clodmget -n -f repository HACMPsircol); do # Want to show the name of the active repository disk # as it appears on the local node lspv | grep -w $disk | read DISK_DATA junk REPOSITORIES[$count]="_$disk:$DISK_DATA:$NODES:" (( count++ )) done : Retrieve the names of any backup repository disks BACKUPS=$(clodmget -n -f backup_repository HACMPsircol) for disk in ${BACKUPS//,/ }; do lspv | grep -w $disk | read DISK_DATA junk REPOSITORIES[$count]="_$disk:$DISK_DATA:$NODES:" (( count++ )) done fi integer ridx=0 for (( ridx=0; ridx < $count; ridx++ )); do print -- "${REPOSITORIES[$ridx]}" |\ IFS=: read disk NAME NODES SITE junk disk=${disk#_} [[ $disk == *([[:space:]]) ]] && continue list[$index]="$NAME ($disk)" (( RETURN_NODES )) && NODE_MAP[_$disk]="$NODES($SITE)" (( index++ )) done if (( rc == RC_UNKNOWN )); then (( index > 0 )) && rc=$RC_SUCCESS || rc=$RC_NOT_FOUND fi else # Searches were provided typeset -A allProperties CLMGR_VERBOSE=1 CL=$LINENO KLIB_HACMP_get_repository_attributes "" allProperties CL=$LINENO search_properties queries allProperties rc=$? if (( $rc == RC_SUCCESS )); then for key in ${!allProperties[*]}; do [[ $key != NAME@(|+([0-9])) ]] && continue typeset NAME=${allProperties[$key]} typeset IDX=${key#NAME} typeset PVID=${allProperties[PVID$IDX]} typeset SITE=${allProperties[SITE$IDX]} if [[ $SITE == *([[:space:]]) ]]; then NODES=$(clnodename) else NODES=$(clodmget -n -f nodelist -q name=$SITE HACMPsite) fi NODES=${NODES//+([[:space:]])/ } list[$index]="$NAME ($PVID)" (( RETURN_NODES )) && NODE_MAP[_$PVID]="$NODES($SITE)" (( index++ )) done else rc=$RC_SEARCH_FAILED fi fi log_return_msg "$rc" "$0()" "$LINENO" return $? } # End of "KLIB_HACMP_list_repositories()" #============================================================================ # # Name: devDoc # # Description: This is a never-to-be-called, wrapper function that all the # clmgr FPATH functions implement in order to hide embedded # syntax from trace logging. This information is implemented # in POD format, and can be viewed in a number of ways using # POD tools. Some viewing suggestions for this function's POD- # formatted information are: # # perldoc # 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_repositories =head1 VERSION Version Number: 1.13 Last Extracted: 7/30/15 19:50:43 Last Changed: 7/29/15 10:54:43 Path, Component, Release(, Level): src/43haes/lib/ksh93/hacmp/KLIB_HACMP_list_repositories.sh, hacmp.assist, 61haes_r720, 1531B_hacmp720 =head1 SYNOPSIS clmgr query repository =head1 DESCRIPTION Displays the names of the currently configured repository disk(s). =head1 ARGUMENTS 1. list [REQUIRED] [hash ref] An array within which data about the queried objects can be returned to the caller. 2. NODE_MAP [OPTIONAL] [hash ref] An associative array that is used to return the list of nodes that the disks were found on. The key is the PVID of the disk, and the value is the node list. =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. 2012,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 #==============================================================================