#!/bin/ksh93 # ALTRAN_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # Copyright (C) Altran ACT S.A.S. 2019,2021. All rights reserved. # # ALTRAN_PROLOG_END_TAG # # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # 61haes_r714 src/43haes/lib/ksh93/hacmp/KLIB_HACMP_delete_mirror_pool.sh 1.3 # # Licensed Materials - Property of IBM # # Restricted Materials of IBM # # COPYRIGHT International Business Machines Corp. 2012 # 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 # @(#) 7d4c34b 43haes/lib/ksh93/hacmp/KLIB_HACMP_delete_mirror_pool.sh, 726, 2147A_aha726, Feb 05 2021 09:50 PM #============================================================================ # # Name: KLIB_HACMP_delete_mirror_pool # # Description: This is the main, FPATH function that is invoked by clmgr # to remove mirror pools from the cluster configuration. # # Inputs: See the "devDoc()" function, below. # # Outputs: 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, below, for the standard return # code values/meanings for clmgr. # #============================================================================ function KLIB_HACMP_delete_mirror_pool { . $HALIBROOT/log_entry "$0()" "$CL" : version=@(#) 7d4c34b 43haes/lib/ksh93/hacmp/KLIB_HACMP_delete_mirror_pool.sh, 726, 2147A_aha726, Feb 05 2021 09:50 PM : INPUTS: $* typeset MIRROR_POOLS=${1//\"/} MIRROR_POOLS=${MIRROR_POOLS//,/ } typeset VOLUME_GROUP=${2//\"/} typeset PHYSICAL_VOLUMES=${3//\"/} [[ $CLMGR_LOGGING == 'med' ]] && set +x # Only trace param values #=================================== : Declare and initialize variables #=================================== typeset -i rc=$RC_UNKNOWN typeset -i i=0 typeset mirror_pool= VG= #================= : Validate input #================= if [[ -z $MIRROR_POOLS ]]; then dspmsg -s $CLMGR_SET $CLMGR_MSGS 100 "\nERROR: a name/label must be provided.\n\n" 1>&2 rc=$RC_MISSING_INPUT else typeset -u uctext=$MIRROR_POOLS if [[ $uctext == "ALL" ]]; then MIRROR_POOLS= typeset available CL=$LINENO KLIB_HACMP_list_mirror_pools available for (( i=0; i<${#available[*]}; i++ )); do MIRROR_POOLS="$MIRROR_POOLS ${available[$i]/ /_}" done if [[ $MIRROR_POOLS == *([[:space:]]) ]]; then dspmsg -s $CLMGR_SET $CLMGR_MSGS 334 "Warning: there are no mirror pools to delete.\n" rc=$RC_SUCCESS fi fi fi if [[ -n $VOLUME_GROUP ]]; then CL=$LINENO KLIB_HACMP_is_known_volume_group "$VOLUME_GROUP" if (( $? != RC_SUCCESS )); then dspmsg -s $CLMGR_SET $CLMGR_MSGS 102 '\nERROR: "%1$s" does not appear to exist!\n\n' "$VOLUME_GROUP" 1>&2 dspmsg -s $CLMGR_SET $CLMGR_MSGS 160 'Available Volume Groups:\n\n' 1>&2 typeset available CL=$LINENO KLIB_HACMP_list_volume_groups available for (( i=0; i<${#available[*]}; i++ )); do if [[ ${available[$i]} != *([[:space:]]) ]]; then print -u2 "\t${available[$i]}" fi done print -u2 "" rc=$RC_NOT_FOUND fi fi #=============================================================== : Delete the mirror pool if no input errors have been detected #=============================================================== if (( $rc == RC_UNKNOWN )); then for mirror_pool in $MIRROR_POOLS; do print -- "$mirror_pool" | IFS=\( read mirror_pool VG [[ -n $VG ]] && VOLUME_GROUP=$VG mirror_pool=${mirror_pool%_} VOLUME_GROUP=${VOLUME_GROUP%\)} CL=$LINENO KLIB_HACMP_is_known_mirror_pool "$mirror_pool" "$VOLUME_GROUP" >/dev/null if (( $? != RC_SUCCESS )); then if [[ -n $VOLUME_GROUP ]] then dspmsg -s $CLMGR_SET $CLMGR_MSGS 357 '\nERROR: "%1$s" does not appear to exist in volume group "%2$s"!\n\n' "$mirror_pool" "$VOLUME_GROUP" 1>&2 else dspmsg -s $CLMGR_SET $CLMGR_MSGS 102 '\nERROR: "%1$s" does not appear to exist!\n\n' "$mirror_pool" 1>&2 fi dspmsg -s $CLMGR_SET $CLMGR_MSGS 173 "Available Mirror Pools:\n\n" 1>&2 typeset available CL=$LINENO KLIB_HACMP_list_mirror_pools available for (( i=0; i<${#available[*]}; i++ )); do if [[ ${available[$i]} != *([[:space:]]) ]]; then print -u2 "\t${available[$i]}" fi done rc=$RC_NOT_FOUND else typeset FOUND=$(CL=$LINENO KLIB_HACMP_is_known_mirror_pool "$mirror_pool" "$VOLUME_GROUP") typeset -i COUNT=0 print -- "$FOUND" |\ while read mirror_pool VOLUME_GROUP; do (( COUNT++ )) done if (( COUNT > 1 )); then cl_dspmsg -s $CLMGR_SET $CLMGR_MSGS 277 "\nERROR: more than one object matches the provided information:\n\n" 1>&2 print -u2 "$FOUND" rc=$RC_INCORRECT_INPUT else print -- "$FOUND" | read mirror_pool VOLUME_GROUP VOLUME_GROUP=${VOLUME_GROUP#\(} VOLUME_GROUP=${VOLUME_GROUP%\)} fi fi if (( $rc == RC_UNKNOWN || $rc == RC_SUCCESS)); then if [[ -z $PHYSICAL_VOLUMES ]]; then typeset -A vgprops CL=$LINENO KLIB_HACMP_get_volume_group_attributes "$VOLUME_GROUP" vgprops print "$0()[$LINENO]($SECONDS): cl_rmmp -cspoc -n"${vgprops[NODES]// /,}" $VOLUME_GROUP $mirror_pool" >>$CLMGR_TMPLOG cl_rmmp -cspoc -n"${vgprops[NODES]// /,}" "$VOLUME_GROUP" "$mirror_pool" >>$CLMGR_TMPLOG rc=$? print "$0()[$LINENO]($SECONDS): cl_rmmp RC: $rc" >>$CLMGR_TMPLOG if (( $rc != RC_SUCCESS )); then rc=$RC_ERROR dspmsg -s $CLMGR_SET $CLMGR_MSGS 300 '\nERROR: failed to delete "%1$s".\n\n' "$mirror_pool" 1>&2 break fi else : Determine if this operation will result in the removal : of the entire mirror pool. If so, tell the user. print "$0()[$LINENO]($SECONDS): LC_ALL=C cl_lsmpvgs -m $mirror_pool $VOLUME_GROUP" >>$CLMGR_TMPLOG # Always log commands typeset OUTPUT=$(LC_ALL=C cl_lsmpvgs -m $mirror_pool $VOLUME_GROUP) cmd_rc=$? print "cl_lsmpvgs RC: $cmd_rc; OUTPUT == \"$OUTPUT\"" >>$CLMGR_TMPLOG # Always log command result if (( $cmd_rc == RC_SUCCESS )); then typeset AIO_CACHE AIO_HWM DISKS REM typeset -u MODE SUPER_STRICT print "$OUTPUT" |\ while IFS=: read NAME VG MODE AIO_CACHE AIO_HWM SUPER_STRICT DISKS REM; do [[ $NAME == \#* ]] && continue DISKS=" ${DISKS//,/ } " break done fi if [[ $DISKS != *([[:space:]]) ]]; then for DISK in ${PHYSICAL_VOLUMES//,/ }; do DISKS=${DISKS//\ $DISK\ / } done if [[ $DISKS == *([[:space:]]) ]]; then cl_dspmsg -s $CLMGR_SET $CLMGR_MSGS 1404 '\n*** Warning: this removal operation, when completed, will leave no disks in\nmirror pool "%1$s", resulting in its automatic removal.\n\n' "$mirror_pool" sleep 5 fi fi : Removing $PHYSICAL_VOLUMES from mirror pool $mirror_pool in $VOLUME_GROUP print "$0()[$LINENO]($SECONDS): cl_mp_disks -cspoc -n\"${vgprops[NODES]// /,}\" -P $VOLUME_GROUP ${PHYSICAL_VOLUMES//,/ }" >>$CLMGR_TMPLOG cl_mp_disks -cspoc -n"${vgprops[NODES]// /,}" -P $VOLUME_GROUP ${PHYSICAL_VOLUMES//,/ } >>$CLMGR_TMPLOG rc=$? print "$0()[$LINENO]($SECONDS): cl_mp_disks RC: $rc" >>$CLMGR_TMPLOG if (( $rc != RC_SUCCESS )); then rc=$RC_ERROR cl_dspmsg -s $CLMGR_SET $CLMGR_MSGS 358 '\nERROR: failed to delete "%1$s" from "%2$s".\n\n' "$PHYSICAL_VOLUMES" "$mirror_pool ($VOLUME_GROUP)" 1>&2 break fi fi fi done (( $rc != RC_SUCCESS )) && print -u2 fi #======================================================================= : If a user input error was detected, provide some helpful suggestions #======================================================================= if (( $rc == RC_MISSING_INPUT || $rc == RC_INCORRECT_INPUT )) && \ [[ $CLMGR_GUI == *([[:space:]]) ]] then cl_dspmsg -s $CLMGR_SET $CLMGR_MSGS 104 "For more information about available options and syntax, try\n\"$HAUTILS/clmgr %1\$s\". As an\nalternative, if the PowerHA SystemMirror man pages have been installed, invoke\n\"$HAUTILS/clmgr -hv\" (or \"/usr/bin/man clmgr\"),\nsearching for \"%2\$s\" in the displayed text.\n\n" \ "delete mirror_pool -h" "MIRROR POOL:" "$CLMGR_PROGNAME" 1>&2 fi log_return_msg "$rc" "$0()" "$LINENO" return $? } # End of "KLIB_HACMP_delete_mirror_pool()" #============================================================================ # # 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_delete_mirror_pool =head1 SYNOPSIS clmgr query mirror_pool clmgr delete mirror_pool { [,,...] | ALL } \ [ VOLUME_GROUP= ] clmgr delete mirror_pool \ [ VOLUME_GROUP= ] \ PHYSICAL_VOLUMES="[,,...]" NOTE: when physical volumes are specified for a delete operation, the list of disks will be removed from the mirror pool. If all disks are removed, the mirror pool is removed. NOTE: aliases for "mirror_pool" are "mp", "mi", and "pool". =head1 DESCRIPTION Deletes one or more mirror pools, or deletes physical volumes from the specified mirror pool. =head1 ARGUMENTS 1. MIRROR_POOLS [REQUIRED] [string] One or more (comma or space separated) mirror pools to attempt to delete. 2. VOLUME_GROUP [OPTIONAL] [string] The label of the volume group that the targeted mirror pool is managed by. This is only needed if more than one mirror pool in this cluster shares the same name, resulting in ambiguity. 3. PHYSICAL_VOLUMES [OPTIONAL] [string] One or more disks to remove from the specified mirror pool. If all disks in the mirror pool are removed, then so is the mirror pool itself. =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 =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 #==============================================================================