#!/bin/ksh93 # ALTRAN_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # Copyright (C) Altran ACT S.A.S. 2017,2021. All rights reserved. # # ALTRAN_PROLOG_END_TAG # # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # 61haes_r721 src/43haes/lib/ksh93/hacmp/KLIB_HACMP_list_physical_volume.sh 1.9.1.2 # # Licensed Materials - Property of IBM # # COPYRIGHT International Business Machines Corp. 2010,2016 # 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_list_physical_volume.sh, 726, 2147A_aha726, Feb 05 2021 09:50 PM #============================================================================ # # Name: KLIB_HACMP_list_physical_volume # # Description: This is the main, FPATH function that is invoked by clmgr to # collect physical volume names for disks that are common and # unused across the given set of nodes. If a search is being # conducted, the same FPATH function is invoked, but this time # 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 hash is populated. 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_physical_volume { LINENO=2 . $HALIBROOT/log_entry "$0()" "$CL" : version=@(#) 7d4c34b 43haes/lib/ksh93/hacmp/KLIB_HACMP_list_physical_volume.sh, 726, 2147A_aha726, Feb 05 2021 09:50 PM : INPUTS: $* typeset -n list=$1 typeset NODES=${2//\"/} typeset -l TYPE=${3//\"/} shift 3 [[ $CLMGR_LOGGING == 'med' ]] && set +x # Only trace param values #=================================== : Declare and initialize variables #=================================== typeset -A queries typeset -u attr= typeset dname= OUTPUT= indexes= value= typeset -i index=0 matches=0 rc=$RC_UNKNOWN while (( $# > 0 )); do value="$1" if [[ $value == *=* ]]; then attr=${value%%=*} # "attr" makes this uppercase if [[ $attr == @(TYPE|NODE|NODES) ]];then shift continue fi queries[$attr]="${value#*=}" fi shift done #======================================================== # If no nodes are specified, default to the local node. # This behavior differs from the verbose listing of # physical volumes, but is now a legacy requirement. # NOTE: if the type of disk listing requested is # tiebreaker, then go ahead and default to # all nodes. #======================================================== if [[ $NODES == *([[:space:]]) ]]; then [[ $TYPE != t* ]] && NODES=$LOCAL_NODE || NODES=$(clnodename) fi if [[ $TYPE != *([[:space:]]) ]]; then if [[ $TYPE == "tb" ]]; then TYPE="tiebreaker" else CL=$LINENO verify_in_set TYPE "$TYPE" "available, all, tiebreaker" TYPE (( $? != RC_SUCCESS )) && rc=$RC_INCORRECT_INPUT fi fi if (( rc == RC_UNKNOWN )) && (( ${#queries[*]} == 0 )); then # List all typeset -A props #================================ : Retrieve the disk information #================================ CL=$LINENO KLIB_HACMP_get_physical_volume_attributes "" props "${NODES//+([[:space:]])/,}" "$TYPE" rc=$? if (( $rc == RC_SUCCESS )); then for key in ${!props[*]}; do [[ $key != NAME* ]] && continue [[ -n $indexes ]] && indexes="$indexes$NL" indexes="$indexes${key##+([[:alpha:]])}" done indexes=$(print -- "$indexes" | sort -n -u) if [[ -n $indexes ]]; then for index in $indexes; do [[ -n $OUTPUT ]] && OUTPUT="$OUTPUT$NL" OUTPUT="$OUTPUT${props[NAME$index]}:${props[PVID$index]}" [[ $CLMGR_GUI == "SMUI" ]] && OUTPUT="$OUTPUT:${props[SIZE$index]}" done else [[ -n $OUTPUT ]] && OUTPUT="$OUTPUT$NL" OUTPUT="${OUTPUT}${props[NAME]}:${props[PVID]}" [[ $CLMGR_GUI == "SMUI" ]] && OUTPUT="$OUTPUT:${props[SIZE]}" fi else rc=$RC_ERROR fi if (( rc == RC_SUCCESS )); then index=0 print -- "$OUTPUT" | sort |\ while IFS=: read dname pvid size rem; do [[ -z $dname || -z $pvid ]] && continue if [[ $CLMGR_GUI == "SMUI" && $size == +([0-9]) ]] then list[$index]="$dname ($pvid) [$size]" else list[$index]="$dname ($pvid)" fi (( index++ )) done fi elif (( rc == RC_UNKNOWN )); then # A search was specified typeset -A allProperties CL=$LINENO CLMGR_VERBOSE=1 KLIB_HACMP_get_physical_volume_attributes "" allProperties "${NODES//+([[:space:]])/,}" "$TYPE" 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 log_return_msg "$rc" "$0()" "$LINENO" return $? } # End of "KLIB_HACMP_list_physical_volume()" #============================================================================ # # 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_physical_volume =head1 VERSION Version Number: 1.9.1.2 Last Extracted: 5/3/16 18:54:04 Last Changed: 4/6/16 06:57:04 Path, Component, Release(, Level): src/43haes/lib/ksh93/hacmp/KLIB_HACMP_list_physical_volume.sh, hacmp.assist, 61haes_r721, 1618A_hacmp721 =head1 SYNOPSIS clmgr query physical_volume \ [ NODES=,[,,...] ] \ [ TYPE={available|all|tiebreaker} ] NOTE: "node" may be either a node name, or a network- resolvable name (i.e. hostname or IP address). NOTE: the alias for "physical_volume" is "pv". =head1 DESCRIPTION Displays the physical volumes for the specified node(s). If no nodes are specified, defaults to the local node. =head1 ARGUMENTS 1. list [REQUIRED] [hash ref] An associative array within which data about the queried objects can be returned to the caller. 2. NODES [OPTIONAL] string A list of nodes/hosts to query. Defaults to all defined nodes, if not provided. 3. TYPE [OPTIONAL] [set] The type of disks to list, from the set: available (only unused disks are listed) all (lists disks even if they are currently in use) tiebreaker (disks that are suitable for tiebreaker usage) =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 #==============================================================================