#!/bin/ksh93 # ALTRAN_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # Copyright (C) Altran ACT S.A.S. 2018,2019,2020,2021. All rights reserved. # # ALTRAN_PROLOG_END_TAG # # @(#) 5f56dbd 43haes/lib/ksh93/hacmp/KLIB_HACMP_list_backup_profile.sh, 726, 2147A_aha726, Mar 08 2021 04:44 PM # Start of POD-formatted documentation. Viewing suggestions: # perldoc # pod2text -c # pod2text -c --code # pod2html function devDoc { : <<'=cut' >/dev/null 2>&1 =head1 NAME KLIB_HACMP_list_backup_profile =head1 SYNOPSIS clmgr query backup_profile backup_profile => bp, backup_p, replication_profile =head1 DESCRIPTION Displays the currently configured set of resource groups for backup_profile. =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 =cut } # End of POD-formatted documentation. #================================================================================== # # Name: KLIB_HACMP_list_backup_profile # # Description: This is the main, FPATH function that is invoked by clmgr # to collect resource group which are configured for backup_profile. # It uses the "cl_cbm_list" 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_backup_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 resource group 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_backup_profile { . $HALIBROOT/log_entry "$0()" "$CL" typeset -n list=$1 shift [[ $CLMGR_LOGGING == 'med' ]] && set +x # Only trace param values #=================================== : Declare and initialize variables #=================================== typeset -A queries typeset -u attr= typeset item= groups= value= typeset -i index=0 matches=0 rc=$RC_UNKNOWN #==================================== : Check python is installed or not #==================================== LANG=C cl_get_python_version 2>&1 >>/dev/null rc=$? if (( $rc != 0 )); then cl_dspmsg -s $CLMGR_SET $CLMGR_MSGS 1315 "\nERROR: Python must be installed for using backup feature.\n\n" 1>&2 log_return_msg "$rc" "$0()" "$LINENO" return $rc fi #================================================================ : 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 #=================================================== : 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 #============================================== : List the resource groups. If there are no : resource groups, cl_cbm_list returns an error. #============================================== print "$0()[$LINENO]($SECONDS): cl_cbm_list" >>$CLMGR_TMPLOG # Always log commands groups=$(LANG=C cl_cbm_list 2>>$CLMGR_TMPLOG) rc=$? print "$0()[$LINENO]($SECONDS): cl_cbm_list RC: $rc; groups == \"${groups//+([[:space:]])/, }\"" >>$CLMGR_TMPLOG # Always log command result #Display error only in case of XML parse error if (( $rc != RC_SUCCESS && $rc > 2 ));then cl_dspmsg -s $CLMGR_SET $CLMGR_MSGS 1197 "\nERROR: No resource group configured for backup.\n\n" 1>&2 rc=$RC_ERROR else rc=$RC_SUCCESS fi for item in $groups; do list[$index]=$item (( index++ )) done else # A search was specified typeset -A allProperties CL=$LINENO CLMGR_VERBOSE=1 KLIB_HACMP_get_backup_profile_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 log_return_msg "$rc" "$0()" "$LINENO" return $? } # End of "KLIB_HACMP_list_backup_profile()" #================================================ # The following, commented line enforces coding # standards when this file is edited via vim. #================================================ # vim:tabstop=4:shiftwidth=4:expandtab:smarttab #================================================