#!/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_r721 src/43haes/lib/ksh93/hacmp/KLIB_HACMP_modify_cluster_roha.sh 1.7 # # Licensed Materials - Property of IBM # # Restricted Materials of IBM # # COPYRIGHT International Business Machines Corp. 2014,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_modify_cluster_roha.sh, 726, 2147A_aha726, Feb 05 2021 09:50 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_modify_cluster_roha =head1 SYNOPSIS clmgr manage cluster roha \ [ ALWAYS_START_RG={YES|NO} ] \ [ ADJUST_SPP_SIZE={YES|NO} ]\ [ FORCE_SYNC_RELEASE={YES|NO} ] \ [ AGREE_TO_COD_COSTS={YES|NO} ] ] \ [ ONOFF_DAYS= ] \ [ RESOURCE_ALLOCATION_ORDER={free_pool_before_enterprise_pool|enterprise_pool_before_free_pool|all_enterprise_pool_before_free_pool} ] NOTE: the alias for "cluster" is "cl". =head1 DESCRIPTION Attempts to modify the cluster Resource Optimized High Availability (aka roha) configuration. =head1 ARGUMENTS 1. properties [REQUIRED] [hash ref] An associative array within which data about the modified object can be returned to the caller. 2. ALWAYS_START_RG [OPTIONAL] [string] If the cluster should always start resource group even if resources are insufficient. 3. ADJUST_SPP_SIZE [OPTIONAL] [string] If the cluster should adjust shared processor pool size when acquiring resources. 4. FORCE_SYNC_RELEASE [OPTIONAL] [string] If the cluster should force release of resources synchronously. 5. AGREE_TO_COD_COSTS [OPTIONAL] [string] If the cluster may use available On/Off CoD resources. 6. ONOFF_DAYS [OPTIONAL] [integer] The amount of days for On/Off CoD request. 7. RESOURCE_ALLOCATION_ORDER [OPTIONAL] [string] Tunable to define the order of resource allocation. =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. function KLIB_HACMP_modify_cluster_roha { . $HALIBROOT/log_entry "$0()" "$CL" : version=@(#) 7d4c34b 43haes/lib/ksh93/hacmp/KLIB_HACMP_modify_cluster_roha.sh, 726, 2147A_aha726, Feb 05 2021 09:50 PM : INPUTS: $* typeset -n properties=$1 shift typeset user_input=$* typeset -l always_start_rg=${1//\"/} typeset -l adjust_spp_size=${2//\"/} typeset -l force_sync_release=${3//\"/} typeset -l agree_to_cod_costs=${4//\"/} typeset onoff_days=${5//\"/} typeset -l resource_allocation_order=${6//\"/} [[ $CLMGR_LOGGING == 'med' ]] && set +x # Only trace param values #=================================== : Declare and initialize variables #=================================== typeset -i rc=$RC_UNKNOWN typeset -A clattrs CL=$LINENO KLIB_HACMP_get_cluster_attributes clattrs #================================================================ : Check for a defined cluster. No need to continue without one. #================================================================ if (( $rc == RC_UNKNOWN )) && [[ -z ${clattrs[CLUSTER_NAME]} ]]; then dspmsg -s $CLMGR_SET $CLMGR_MSGS 35 "\nERROR: no cluster is defined yet.\n\n" 1>&2 rc=$RC_MISSING_DEPENDENCY #================= : Validate input #================= elif [[ $user_input == *([[:space:]]) ]] ; then dspmsg -s $CLMGR_SET $CLMGR_MSGS 401 "\nERROR: no valid modifications were specified for \"%1\$s\".\n\n" "$(cllsclstr -cS | /usr/bin/cut -d: -f2)" 1>&2 rc=$RC_MISSING_INPUT fi if [[ -n $always_start_rg ]] ; then if [[ $always_start_rg == @(1|y|t)* ]]; then always_start_rg=1 # yes and true (lowercase or uppercase), 1 elif [[ $always_start_rg == @(0|n|f)* ]]; then always_start_rg=0 # no and false (lowercase or uppercase), 0 else dspmsg -s $CLMGR_SET $CLMGR_MSGS 110 "\nERROR: invalid value specified for \"%1\$s\": \"%2\$s\".\n" ALWAYS_START_RG "$always_start_rg" 1>&2 dspmsg -s $CLMGR_SET $CLMGR_MSGS 3 "Valid values: %1\$s\n\n" "true, false" 1>&2 rc=$RC_INCORRECT_INPUT fi fi if [[ -n $adjust_spp_size ]] ; then if [[ $adjust_spp_size == @(1|y|t)* ]]; then adjust_spp_size=1 # yes and true (lowercase or uppercase), 1 elif [[ $adjust_spp_size == @(0|n|f)* ]]; then adjust_spp_size=0 # no and false (lowercase or uppercase), 0 else dspmsg -s $CLMGR_SET $CLMGR_MSGS 110 "\nERROR: invalid value specified for \"%1\$s\": \"%2\$s\".\n" ADJUST_SPP_SIZE "$adjust_spp_size" 1>&2 dspmsg -s $CLMGR_SET $CLMGR_MSGS 3 "Valid values: %1\$s\n\n" "true, false" 1>&2 rc=$RC_INCORRECT_INPUT fi fi if [[ -n $force_sync_release ]] ; then if [[ $force_sync_release == @(1|y|t)* ]]; then force_sync_release=1 # yes and true (lowercase or uppercase), 1 elif [[ $force_sync_release == @(0|n|f)* ]]; then force_sync_release=0 # no and false (lowercase or uppercase), 0 else dspmsg -s $CLMGR_SET $CLMGR_MSGS 110 "\nERROR: invalid value specified for \"%1\$s\": \"%2\$s\".\n" FORCE_SYNC_RELEASE "$force_sync_release" 1>&2 dspmsg -s $CLMGR_SET $CLMGR_MSGS 3 "Valid values: %1\$s\n\n" "true, false" 1>&2 rc=$RC_INCORRECT_INPUT fi fi if [[ -n $agree_to_cod_costs ]] ; then if [[ $agree_to_cod_costs == @(1|y|t)* ]]; then agree_to_cod_costs=1 # yes and true (lowercase or uppercase), 1 elif [[ $agree_to_cod_costs == @(0|n|f)* ]]; then agree_to_cod_costs=0 # no and false (lowercase or uppercase), 0 else dspmsg -s $CLMGR_SET $CLMGR_MSGS 110 "\nERROR: invalid value specified for \"%1\$s\": \"%2\$s\".\n" AGREE_TO_COD_COSTS "$agree_to_cod_costs" 1>&2 dspmsg -s $CLMGR_SET $CLMGR_MSGS 3 "Valid values: %1\$s\n\n" "true, false" 1>&2 rc=$RC_INCORRECT_INPUT fi fi if [[ -n $onoff_days && $onoff_days != +([[:digit:]]) || $onoff_days == 0 ]]; then dspmsg -s $CLMGR_SET $CLMGR_MSGS 111 "\nERROR: \"%1\$s\" requires a positive, integer value.\n\n" ONOFF_DAYS 1>&2 rc=$RC_INCORRECT_INPUT elif [[ -n $onoff_days ]] && (( $onoff_days > 90 )); then dspmsg -s $CLMGR_SET $CLMGR_MSGS 175 "\nERROR: \"%1\$s\" maximum value is \"%2\$d\".\n\n" ONOFF_DAYS 90 1>&2 rc=$RC_INCORRECT_INPUT fi if [[ $resource_allocation_order != *([[:space:]]) ]]; then CL=$LINENO verify_in_set RESOURCE_ALLOCATION_ORDER "$resource_allocation_order" "free_pool_before_enterprise_pool,enterprise_pool_before_free_pool,all_enterprise_pool_before_free_pool" resource_allocation_order (( $? != RC_SUCCESS )) && rc=$RC_INCORRECT_INPUT fi #================================= # Tune the cluster, if requested #================================= if (( $rc == RC_UNKNOWN || $rc == RC_SUCCESS )); then if [[ -n $always_start_rg ]]; then #================================================ : Setting always_start_rg to "$always_start_rg" #================================================ print "HACMProhaparam: always_start_rg=$always_start_rg" | /usr/bin/odmchange -o HACMProhaparam typeset VAL=$(clodmget -n -f always_start_rg HACMProhaparam) [[ $VAL == $always_start_rg ]] && rc=$RC_SUCCESS || rc=$RC_ERROR fi fi if (( $rc == RC_UNKNOWN || $rc == RC_SUCCESS )); then if [[ -n $adjust_spp_size ]]; then #================================================ : Setting adjust_spp_size to "$adjust_spp_size" #================================================ print "HACMProhaparam: adjust_spp_size=$adjust_spp_size" | /usr/bin/odmchange -o HACMProhaparam typeset VAL=$(clodmget -n -f adjust_spp_size HACMProhaparam) [[ $VAL == $adjust_spp_size ]] && rc=$RC_SUCCESS || rc=$RC_ERROR fi fi if (( $rc == RC_UNKNOWN || $rc == RC_SUCCESS )); then if [[ -n $force_sync_release ]]; then #================================================ : Setting force_sync_release to "$force_sync_release" #================================================ print "HACMProhaparam: force_sync_release=$force_sync_release" | /usr/bin/odmchange -o HACMProhaparam typeset VAL=$(clodmget -n -f force_sync_release HACMProhaparam) [[ $VAL == $force_sync_release ]] && rc=$RC_SUCCESS || rc=$RC_ERROR fi fi if (( $rc == RC_UNKNOWN || $rc == RC_SUCCESS )); then if [[ -n $agree_to_cod_costs ]]; then #================================================ : Setting agree_to_cod_costs to "$agree_to_cod_costs" #================================================ print "HACMProhaparam: agree_to_cod_costs=$agree_to_cod_costs" | /usr/bin/odmchange -o HACMProhaparam typeset VAL=$(clodmget -n -f agree_to_cod_costs HACMProhaparam) [[ $VAL == $agree_to_cod_costs ]] && rc=$RC_SUCCESS || rc=$RC_ERROR fi fi if (( $rc == RC_UNKNOWN || $rc == RC_SUCCESS )); then if [[ -n $onoff_days ]]; then #================================================ : Setting onoff_days to "$onoff_days" #================================================ print "HACMProhaparam: onoff_days=$onoff_days" | /usr/bin/odmchange -o HACMProhaparam typeset VAL=$(clodmget -n -f onoff_days HACMProhaparam) [[ $VAL == $onoff_days ]] && rc=$RC_SUCCESS || rc=$RC_ERROR fi fi if (( $rc == RC_UNKNOWN || $rc == RC_SUCCESS )); then if [[ -n $resource_allocation_order ]]; then if [[ $resource_allocation_order == "all_enterprise_pool_before_free_pool" ]]; then allocation_order=2 elif [[ $resource_allocation_order == "enterprise_pool_before_free_pool" ]]; then allocation_order=1 else allocation_order=0 fi #================================================ : Setting resource_allocation_order to "$resource_allocation_order" #================================================ print "HACMProhaparam: resource_allocation_order=$allocation_order" | /usr/bin/odmchange -o HACMProhaparam typeset VAL=$(clodmget -n -f resource_allocation_order HACMProhaparam) [[ $VAL == $allocation_order ]] && rc=$RC_SUCCESS || rc=$RC_ERROR fi fi #=========================================================== : If output from this operation was requested, retrieve it #=========================================================== if (( $rc == RC_SUCCESS )); then #=========================================================== # Set the "handle" attribute in the HACMPcluster class # to zero to indicate that an unsynced change exists in # the cluster configuration. #=========================================================== if [[ -n $always_start_rg || -n $adjust_spp_size || -n $force_sync_release || -n $agree_to_cod_costs || -n $resource_allocation_order || -n $onoff_days ]]; then print "\ HACMPcluster: \thandle=0" | /usr/bin/odmchange -o HACMPcluster fi if (( CLMGR_VERBOSE )) || [[ -n $CLMGR_ATTRS ]]; then CL=$LINENO KLIB_HACMP_get_cluster_attributes properties fi 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=$LINENO 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" \ "manage cluster -h" "CLUSTER:" "$CLMGR_PROGNAME" 1>&2 fi log_return_msg "$rc" "$0()" "$LINENO" return $? } # End of "KLIB_HACMP_modify_cluster_roha()" #================================================ # The following, commented line enforces coding # standards when this file is edited via vim. #================================================ # vim:tabstop=4:shiftwidth=4:expandtab:smarttab #================================================