#!/bin/ksh93 # ALTRAN_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # Copyright (C) Altran ACT S.A.S. 2017,2018,2019,2020,2021. All rights reserved. # # ALTRAN_PROLOG_END_TAG # ############################################################################### # @(#) 7d4c34b 43haes/usr/sbin/cluster/events/utils/clidentifyroha.sh, 726, 2147A_aha726, Feb 05 2021 09:50 PM ############################################################################### ######################################################################### # # COMPONENT_NAME: hacmp.events # # CLASS: # # roha_identify # # DESCRIPTION: # # This file contains all atomic functions needed to perform # 'identify' step, which is the third step of the ROHA runtime # (query step, compute step, identify step, apply step). # # The identify step can be done for acquisition or for release. # The identify is done once for memory and once for CPUs (dedicated # processing mode) or for PUs and VPs (shared processing mode). # # For acquisition : # The identify step tries to find out how the # ROHA 'needed' resources can be satisfied, taking into account the # various types of resources available, and their amounts. # Eventually we need to provision LPAR with resources from the # Managed System free pool of resources, through a DLPAR operation. # But we often first need to provision this Managed System free pool # of resources with resources coming from external pools of resources # (Enterprise Pool and On/Off CoD). # The identify step simulates the acquisition of resources # until the needs are satisfied, so see how it can be done at best. # Three policies are possible (DLPAR followed by Enterprise Pool or # Enterprise Pool without creating unreturned followed by DLPAR, # Enterprise Pool even with creating unreturned resources followed by DLPAR). # # For release : # The identify step tries to find out how the # ROHA 'to_release' resources can be released at the LPAR level # and at the Enterprise Pool and On/Off CoD levels. # The identify step simulates the release of resources # until the amount of resources is released, so see how it can # be done at best. # # FUNCTIONS: # # roha_identify_onoff_days # # roha_identify_mem # roha_identify_mem_to_acquire # roha_identify_mem_to_release # roha_identify_mem_report # roha_identify_mem_to_acquire_report # roha_identify_mem_to_release_report # # roha_identify_cpu # roha_identify_shd_cpu_to_acquire # roha_identify_ded_cpu_to_acquire # roha_identify_shd_cpu_to_release # roha_identify_ded_cpu_to_release # roha_identify_cpu_report # roha_identify_shd_cpu_to_acquire_report # roha_identify_ded_cpu_to_acquire_report # roha_identify_shd_cpu_to_release_report # roha_identify_ded_cpu_to_release_report # ######################################################################### #================================================ # The following, commented line enforces coding # standards when this file is edited via vim. #================================================ # vim:tabstop=4:shiftwidth=4:expandtab:smarttab #================================================ #======================================================= # R O H A _ I D E N T I F Y #======================================================= typeset roha_identify=( typeset dlpar=( typeset -F4 mem=0.00 typeset -F4 pu=0.00 typeset -F4 vp=0.00 typeset -F4 cpu=0.00 typeset -F4 spp_size=0.00 ) typeset codpool=( typeset -F4 mem=0.00 typeset -F4 mem_to_yank=0.00 typeset -A mem_to_yank_compliant typeset -A mem_to_yank_uncompliant typeset -F4 cpu=0.00 typeset -F4 cpu_to_yank=0.00 typeset -A cpu_to_yank_compliant typeset -A cpu_to_yank_uncompliant ) typeset onoff=( typeset -F4 mem=0.00 typeset -i mem_days=0 typeset -F4 cpu=0.00 typeset -i cpu_days=0 ) ) #============================================================================= # # Name: initialize_identify_globals # # Description: Initialize global vars specific to this file that may otherwise # be used unreinitialized during reassessment # # Inputs: None # # Outputs: None # # Globals: roha_identify # # Returns: RC_SUCCESS # #============================================================================= function initialize_identify_globals { [[ $VERBOSE_LOGGING == high ]] && set -x roha_identify.dlpar.mem=0.00 roha_identify.dlpar.pu=0.00 roha_identify.dlpar.vp=0.00 roha_identify.dlpar.cpu=0.00 roha_identify.dlpar.spp_size=0 roha_identify.codpool.mem=0.00 roha_identify.codpool.mem_to_yank=0.00 roha_identify.codpool.cpu=0.00 roha_identify.codpool.cpu_to_yank=0.00 typeset SYS_NAME="" for SYS_NAME in ${roha_query_codpool_members_names}; do roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]=0.00 roha_identify.codpool.mem_to_yank_uncompliant[$SYS_NAME]=0.00 roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]=0.00 roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]=0.00 done roha_identify.onoff.mem=0.00 roha_identify.onoff.mem_days=0 roha_identify.onoff.cpu=0.00 roha_identify.onoff.cpu_days=0.00 return $RC_SUCCESS } #============================================================================= # # Name: roha_identify_onoff_days # # Description: Compute requested amount of resources and number of days for # the request based on available amount and potential previous # request. # # Inputs: [IN/OUT] requested_res - amount of resources needed # [IN/OUT] requested_days - number of days needed for the resource type # [IN] days_avail - available number of days for the resource type # [IN] days_left - number of days left in the current On/Off CoD request # # Outputs: None # # Returns: RC_SUCCESS # #============================================================================= function roha_identify_onoff_days { [[ $VERBOSE_LOGGING == high ]] && set -x typeset -i res_days_req=0 res_days_avail=0 # in [GB].[days] or [#CPU].[days] typeset -n requested_res=$1 typeset -n requested_days=$2 typeset days_avail=$3 # Proc.days or GB.days typeset days_left=$4 # Proc.days or GB.days requested_days=$(roha_session_read_odm_rohaparam "onoff_days") (( res_days_req = $requested_res * $requested_days )) (( res_days_avail = $days_avail + $days_left )) if (( $res_days_req > $res_days_avail )) ; then #======================================================= : There are not enough available days. : Thus, reduce duration so that remaining available : resources are used. #======================================================= (( requested_days = $res_days_avail / $requested_res )) if (( $requested_days > 0 )) ; then roha_session_log "$(dspmsg -s $ROHA_SET $ROHA_MSGS 130 \ "%1\$s: WARNING: Reducing duration to %2\$d to still activate %3\$d On/Off CoD resources.\n" \ "$PROGNAME" "$requested_days" "$requested_res")" else # requested_days = 0 if (( $(roha_session_read_odm_rohaparam "always_start_rg") == 1 )) ; then #======================================================= : There are not enough resources available. : Thus, reduce amount of requested resources so that : each resource could be given at least one day. #======================================================= requested_res=$res_days_avail requested_days=1 roha_session_log "$(dspmsg -s $ROHA_SET $ROHA_MSGS 131 \ "%1\$s: WARNING: Reducing quantity of On/Off Cod resources to %2\$d to activate the maximum of resources for 1 day.\n" \ "$PROGNAME" "$requested_res")" fi fi fi return $RC_SUCCESS } # End of "roha_identify_onoff_days()" #============================================================================= # # Name: roha_identify_mem # # Description: Find out how much this LPAR could possibly acquire in terms of # DLPAR, Enterprise Pool, or On/Off CoD. Depending on the # configurable order of acquisition (DLPAR first/Enterprise Pool # second or Enterprise Pool first/DLPAR second), consider # successively DLPAR resources and Enterprise Pool resources. # Then, consider On/Off CoD resources. And, check if SystemMirror # should always start RGs or not. # # Inputs: None # # Outputs: None # # Globals: roha_session # # Returns: RC_SUCCESS # or else, failure error code. # #============================================================================= function roha_identify_mem { [[ $VERBOSE_LOGGING == high ]] && set -x typeset -i rc=$RC_SUCCESS case ${roha_session.operation} in "acquire") roha_identify_mem_to_acquire rc=$? ;; "release") roha_identify_mem_to_release rc=$? ;; esac return $rc } # End of "roha_identify_mem()" #============================================================================= # # Name: roha_identify_mem_report # # Description: Displays computation results. # # Inputs: None # # Outputs: None # # Globals: roha_session # # Returns: None # #============================================================================= function roha_identify_mem_report { case ${roha_session.operation} in "acquire") roha_identify_mem_to_acquire_report ;; "release") roha_identify_mem_to_release_report ;; esac } # End of "roha_identify_mem_report()" #============================================================================= # # Name: roha_identify_mem_to_acquire # # Description: Find out how much this LPAR could possibly acquire in terms of # DLPAR, Enterprise Pool, or On/Off CoD. # - Consider Enterprise Pool resources (normal, yank normal/force). # - Consider DLPAR resources. # - Consider On/Off CoD resources. # - And, check if SystemMirror should always start RGs # even if resources are insufficient. # # Tunable resource_allocation_order modifies the # precedence order between sources of resources. # If resource_allocation_order set to 1 # - Enterprise Pool # - DLPAR # - Enterprise Pool with yank normal/force # If resource_allocation_order set to 2 # - Enterprise Pool # - Enterprise Pool with yank normal/force # - DLPAR # Otherwise, order is # - DLPAR # - Enterprise Pool # - Enterprise Pool with yank normal/force # # Inputs: None # # Outputs: None # # Internal functions: # function roha_identify_epcod_mem_to_acquire # function roha_identify_epcod_from_previous_active_mem_to_acquire # function roha_identify_epcod_from_active_mem_to_acquire # function roha_identify_dlpar_mem_to_acquire # function roha_identify_onoff_mem_to_acquire # # Globals: roha_query # roha_compute # roha_identify # # Returns: RC_SUCCESS # RC_IDENTIFY_MEM_ERROR_RESOURCES # #============================================================================= function roha_identify_mem_to_acquire { #======================================================= # Internal function to consider Enterprise Pool CoD # resources. # Inputs : in/out parameter needed. #======================================================= function roha_identify_epcod_mem_to_acquire { [[ $VERBOSE_LOGGING == high ]] && set -x typeset -n needed=$1 if (( $needed > 0.00 )) ; then #======================================================= : There are still some needed resources. : Consider Enterprise Pool CoD resources. #======================================================= if [[ ${roha_query.codpool.state} == @("In compliance"|"Approaching")* ]] && (( ${roha_query.cec.mem.realtime_inactive} > 0.00 )) && (( ${roha_query.codpool.mem.available} > 0.00 )); then #======================================================= : There are available resources in Enterprise Pool CoD, : take as much as it can, but no more than inactive. #======================================================= roha_identify.codpool.mem=$(min ${needed} ${roha_query.codpool.mem.available}) roha_identify.codpool.mem=$(min ${roha_identify.codpool.mem} ${roha_query.cec.mem.realtime_inactive}) #======================================================= : Update DLPAR and needed accordingly : Remove from needed what is going to be EPCoD-acquired #======================================================= (( roha_identify.dlpar.mem += ${roha_identify.codpool.mem} )) (( needed -= ${roha_identify.codpool.mem} )) #======================================================= : Then, always activate whole amount of Enterprise Pool : CoD resources, rounded up. : Update real inactive accordingly : what is going : to be EPCoD-acquired must be removed from the amount : of inactive. #======================================================= roha_identify.codpool.mem=$(print ${roha_identify.codpool.mem} | awk '{printf "%0.4f\n",int($0+0.9999)}') (( roha_query.cec.mem.realtime_inactive -= ${roha_identify.codpool.mem} )) fi fi if (( $needed > 0.00 )) ; then #======================================================= : There are still some needed resources. : Consider releasing Enterprise Pool : CoD resources from 'other' managed system only : if using the same pool. : This is the 'normal' yank : we only yank from the : other Managed System if it is down, or if the LPAR is : down, we do not create unreturned resources, we do not : yank more than what was DLPAR allocated on the other : LPAR. #======================================================= if [[ -n ${roha_session.other_lpar} ]] && (( ${roha_query.other_node.codpool.mem.mobile} > 0.00 )) && [[ ${roha_query.other_node.codpool.name} == ${roha_query.codpool.name} ]] ; then if [[ ${roha_query.other_node.cec.state} != @("Operating"|"Standby") ]] ; then #======================================================= : Source Managed System is down and there are resources : in Enterprise Pool CoD to be yanked. : Take as much as it can. : You cannot take more than the available nor the inactive. #======================================================= roha_identify.codpool.mem_to_yank=$(min ${needed} ${roha_query.other_node.codpool.mem.mobile}) roha_identify.codpool.mem_to_yank=$(min ${roha_identify.codpool.mem_to_yank} ${roha_query.cec.mem.realtime_inactive}) elif [[ ${roha_query.other_node.lpar.state} != @("Running") ]] ; then #======================================================= : Source LPAR is down and there are resources in : Enterprise Pool CoD to be yanked. : Take as much as it can. : You cannot take more than the available nor the inactive. : We can take only from the LPAR what would be released by : this LPAR : curr - min. To know if we round up or down, : we use the same method than the one used in the real release. #======================================================= roha_identify.codpool.mem_to_yank=$(min ${needed} ${roha_query.other_node.codpool.mem.mobile}) roha_identify.codpool.mem_to_yank=$(min ${roha_identify.codpool.mem_to_yank} ${roha_query.cec.mem.realtime_inactive}) typeset -F4 other_node_roha (( other_node_roha = ${roha_query.other_node.lpar.mem.curr} - ${roha_query.other_node.lpar.mem.min} )) typeset -F4 other_node_roha_up=$(print ${other_node_roha} | awk '{printf "%0.4f\n",int($0+0.9999)}') typeset -F4 other_node_roha_down=$(print ${other_node_roha} | awk '{printf "%0.4f\n",int($0)}') if (( ${roha_query.other_node.cec.mem.available} + ${other_node_roha} >= ${other_node_roha_up} )) ; then other_node_roha=$other_node_roha_up else other_node_roha=$other_node_roha_down fi roha_identify.codpool.mem_to_yank=$(min ${roha_identify.codpool.mem_to_yank} ${other_node_roha} ) #======================================================= : Because of EPCoD unreturned limit, we cannot yank : uncompliantly more than the pool capacity. So that the : yank cannot exceed the other_node available resource : for the compliant part, and the difference between the : EPCoD capacity and the EPCOD unreturned for the uncompliant : part. #======================================================= roha_identify.codpool.mem_to_yank=$(min ${roha_identify.codpool.mem_to_yank} ${roha_query_codpool_members["${roha_query.other_node.cec.name}" "realtime_curr_avail_sys_mem"]}+${roha_query.codpool.mem.capacity}-${roha_query.codpool.mem.realtime_unreturned}) else roha_identify.codpool.mem_to_yank=0.00 fi #======================================================= : Update DLPAR and needed accordingly : Remove from needed what is going to be EPCoD-yanked #======================================================= (( roha_identify.dlpar.mem += ${roha_identify.codpool.mem_to_yank} )) (( needed -= ${roha_identify.codpool.mem_to_yank} )) #======================================================= : Then, always yank whole amount of Enterprise Pool : CoD resources, rounded up. : It can be decimal only if the needed is the limit, so : we can safely round up here : Update real inactive accordingly : what is going : to be EPCoD-yanked must be removed from the amount : of inactive. #======================================================= roha_identify.codpool.mem_to_yank=$(print ${roha_identify.codpool.mem_to_yank} | awk '{printf "%0.4f\n",int($0+0.9999)}') (( roha_query.cec.mem.realtime_inactive -= ${roha_identify.codpool.mem_to_yank} )) #======================================================= : Update : realtime pool unreturned : realtime other_cec available #======================================================= (( roha_query.codpool.mem.realtime_unreturned += $(max 0.00 ${roha_identify.codpool.mem_to_yank}-${roha_query_codpool_members["${roha_query.other_node.cec.name}" "realtime_curr_avail_sys_mem"]}) )) roha_query_codpool_members["${roha_query.other_node.cec.name}" "realtime_curr_avail_sys_mem"]=$(max 0.00 ${roha_query_codpool_members["${roha_query.other_node.cec.name}" "realtime_curr_avail_sys_mem"]}-${roha_identify.codpool.mem_to_yank} ) #======================================================= : What is going to be EPCoD-yanked here cannot be : EPCoD-yanked force. So remove it from the amount of : mobile resources available on this other cec. #======================================================= (( roha_query_codpool_members["${roha_session.other_cec}" "sys_mobile_mem"] -= ${roha_identify.codpool.mem_to_yank} )) fi fi } # End of "roha_identify_epcod_mem_to_acquire()" #======================================================= # Internal function to consider Enterprise Pool CoD # resources from Previous hosting Managed Systems. # Inputs : in/out parameter needed #======================================================= function roha_identify_epcod_from_previous_active_mem_to_acquire { [[ $VERBOSE_LOGGING == high ]] && set -x typeset -n needed=$1 typeset SYS_NAME="${roha_query.other_node.cec.name}" if (( $needed > 0.00 )) && [[ -n $SYS_NAME && $SYS_NAME != "${roha_query.cec.name}" ]]; then #======================================================= : There are still some needed resources. : Consider releasing Enterprise Pool : CoD resources from Previous hosting managed systems : using the same Enterprise Pool. : Go through and compute what can be got from : this managed system : without creating unreturned : with creating unreturned #======================================================= #================================================================= : Go through Previous Managed System to search for Enterprise Pool : resources, without creating unreturned. #================================================================= roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]=0.00 #======================================================= : This is on $SYS_NAME Managed System #======================================================= if (( $needed > 0.00 )); then #======================================================= : How many mem can be got from $SYS_NAME MS without : creating unreturned. #======================================================= if (( ${roha_query_codpool_members["$SYS_NAME" "sys_unreturned_mobile_mem"]} == 0.00 )); then #======================================================= : Check available amounts on CEC only in case of CEC up : because unreturned are not generated on a down CEC #======================================================= if [[ ${roha_query_codpool_members["$SYS_NAME" "state"]} == @("Operating"|"Standby") ]] ; then roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]=$(min ${roha_query_codpool_members["$SYS_NAME" "sys_mobile_mem"]} ${roha_query_codpool_members["$SYS_NAME" "realtime_curr_avail_sys_mem"]} ) else roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]=${roha_query_codpool_members["$SYS_NAME" "sys_mobile_mem"]} fi #======================================================= : Only whole amounts can be yanked compliantly : rounded down #======================================================= roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]=$(print ${roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]} | awk '{printf "%0.4f\n",int($0)}') #======================================================= : Then limit amount to what is really needed : and what can really be acquired #======================================================= roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]=$(min ${roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]} ${needed}) roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]=$(min ${roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]} ${roha_query.cec.mem.realtime_inactive} ) #======================================================= : Update DLPAR accordingly #======================================================= (( roha_identify.dlpar.mem += ${roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]} )) #======================================================= : Decrease accordingly the amount still needed #======================================================= (( needed -= ${roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]} )) #======================================================= : Then, always yank whole amount of Enterprise Pool : CoD resources, rounded up. #======================================================= roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]=$(print ${roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]} | awk '{printf "%0.4f\n",int($0+0.9999)}') #======================================================= : Update real inactive accordingly : what is going : to be EPCoD-yanked compliantly must be removed : from the amount of inactive. : Also update realtime available on yanked CEC if up #======================================================= (( roha_query.cec.mem.realtime_inactive -= ${roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]} )) if [[ ${roha_query_codpool_members["$SYS_NAME" "state"]} == @("Operating"|"Standby") ]] ; then (( roha_query_codpool_members["$SYS_NAME" "realtime_curr_avail_sys_mem"] -= ${roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]} )) fi #=============================================== : Update codpool mem to acquire accordingly #=============================================== (( roha_identify.codpool.mem += ${roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]} )) else #======================================================= : Nothing to be done, as there is already some unreturned : on this CEC #======================================================= fi fi #===================================================================== : Search for Enterprise Pool resources, even with creating unreturned. #===================================================================== roha_identify.codpool.mem_to_yank_uncompliant[$SYS_NAME]=0.00 #======================================================= : This is on $SYS_NAME Managed System #======================================================= if (( $needed > 0.00 )); then #======================================================= : How many mem can be got from $SYS_NAME MS even : with creating unreturned #======================================================= # We can consider that uncompliant = total - compliant because if this # path is triggered, its because all compliant is already yanked. roha_identify.codpool.mem_to_yank_uncompliant[$SYS_NAME]=${roha_query_codpool_members["$SYS_NAME" "sys_mobile_mem"]} (( roha_identify.codpool.mem_to_yank_uncompliant[$SYS_NAME] -= ${roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]} )) roha_identify.codpool.mem_to_yank_uncompliant[$SYS_NAME]=$(min ${roha_identify.codpool.mem_to_yank_uncompliant[$SYS_NAME]} ${needed}) roha_identify.codpool.mem_to_yank_uncompliant[$SYS_NAME]=$(min ${roha_identify.codpool.mem_to_yank_uncompliant[$SYS_NAME]} ${roha_query.cec.mem.realtime_inactive} ) roha_identify.codpool.mem_to_yank_uncompliant[$SYS_NAME]=$(min ${roha_identify.codpool.mem_to_yank_uncompliant[$SYS_NAME]} ${roha_query.codpool.mem.capacity}-${roha_query.codpool.mem.realtime_unreturned}) #======================================================= : Update DLPAR accordingly #======================================================= (( roha_identify.dlpar.mem += ${roha_identify.codpool.mem_to_yank_uncompliant[$SYS_NAME]} )) #======================================================= : Decrease accordingly the amount still needed #======================================================= (( needed -= ${roha_identify.codpool.mem_to_yank_uncompliant[$SYS_NAME]} )) #======================================================= : Then, always yank whole amount of Enterprise Pool : CoD resources, rounded up. #======================================================= roha_identify.codpool.mem_to_yank_uncompliant[$SYS_NAME]=$(print ${roha_identify.codpool.mem_to_yank_uncompliant[$SYS_NAME]} | awk '{printf "%0.4f\n",int($0+0.9999)}') #======================================================= : Update real inactive accordingly : what is going : to be EPCoD-yanked uncompliantly must be removed : from the amount of inactive. : Also update total amount of pool unreturned #======================================================= (( roha_query.cec.mem.realtime_inactive -= ${roha_identify.codpool.mem_to_yank_uncompliant[$SYS_NAME]} )) (( roha_query.codpool.mem.realtime_unreturned += ${roha_identify.codpool.mem_to_yank_uncompliant[$SYS_NAME]} )) #=================================================== : Update codpool mem to acquire accordingly #=================================================== (( roha_identify.codpool.mem += ${roha_identify.codpool.mem_to_yank_uncompliant[$SYS_NAME]} )) fi fi } # End of "roha_identify_epcod_from_previous_active_mem_to_acquire" #======================================================= # Internal function to consider Enterprise Pool CoD # resources from Active Managed Systems. # Inputs : in/out parameter needed #======================================================= function roha_identify_epcod_from_active_mem_to_acquire { [[ $VERBOSE_LOGGING == high ]] && set -x typeset -n needed=$1 if (( $needed > 0.00 )) ; then #======================================================= : There are still some needed resources. : Consider releasing Enterprise Pool : CoD resources from active managed systems using : the same Enterprise Pool. : Go through all managed systems sharing this : Enterprise Pool and compute what can be got from : this managed system : without creating unreturned : with creating unreturned #======================================================= #======================================================= : Loop around Managed Systems to search for Enterprise Pool : resources, without creating unreturned. #======================================================= typeset SYS_NAME="" for SYS_NAME in ${roha_query_codpool_members_names}; do #======================================================= # Resources from previous active are already considered #======================================================= if [[ $SYS_NAME == "${roha_query.other_node.cec.name}" ]]; then continue fi roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]=0.00 if [[ $SYS_NAME == "${roha_query.cec.name}" ]]; then continue fi #======================================================= : This loop is on $SYS_NAME Managed System #======================================================= if (( $needed > 0.00 )); then #======================================================= : How many mem can be got from $SYS_NAME MS without : creating unreturned. #======================================================= if (( ${roha_query_codpool_members["$SYS_NAME" "sys_unreturned_mobile_mem"]} == 0.00 )); then #======================================================= : Check available amounts on CEC only in case of CEC up : because unreturned are not generated on a down CEC #======================================================= if [[ ${roha_query_codpool_members["$SYS_NAME" "state"]} == @("Operating"|"Standby") ]] ; then roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]=$(min ${roha_query_codpool_members["$SYS_NAME" "sys_mobile_mem"]} ${roha_query_codpool_members["$SYS_NAME" "realtime_curr_avail_sys_mem"]} ) else roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]=${roha_query_codpool_members["$SYS_NAME" "sys_mobile_mem"]} fi #======================================================= : Only whole amounts can be yanked compliantly : rounded down #======================================================= roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]=$(print ${roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]} | awk '{printf "%0.4f\n",int($0)}') #======================================================= : Then limit amount to what is really needed : and what can really be acquired #======================================================= roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]=$(min ${roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]} ${needed}) roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]=$(min ${roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]} ${roha_query.cec.mem.realtime_inactive} ) #======================================================= : Update DLPAR accordingly #======================================================= (( roha_identify.dlpar.mem += ${roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]} )) #======================================================= : Decrease accordingly the amount still needed #======================================================= (( needed -= ${roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]} )) #======================================================= : Then, always yank whole amount of Enterprise Pool : CoD resources, rounded up. #======================================================= roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]=$(print ${roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]} | awk '{printf "%0.4f\n",int($0+0.9999)}') #======================================================= : Update real inactive accordingly : what is going : to be EPCoD-yanked compliantly must be removed : from the amount of inactive. : Also update realtime available on yanked CEC if up #======================================================= (( roha_query.cec.mem.realtime_inactive -= ${roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]} )) if [[ ${roha_query_codpool_members["$SYS_NAME" "state"]} == @("Operating"|"Standby") ]] ; then (( roha_query_codpool_members["$SYS_NAME" "realtime_curr_avail_sys_mem"] -= ${roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]} )) fi #=============================================== : Update codpool mem to acquire accordingly #=============================================== (( roha_identify.codpool.mem += ${roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]} )) else #======================================================= : Nothing to be done, as there is already some unreturned : on this CEC #======================================================= fi fi done #======================================================= : Loop around Managed Systems to search for Enterprise Pool : resources, even with creating unreturned. #======================================================= for SYS_NAME in ${roha_query_codpool_members_names}; do #======================================================= # Resources from previous active are already considered #======================================================= if [[ $SYS_NAME == "${roha_query.other_node.cec.name}" ]]; then continue fi roha_identify.codpool.mem_to_yank_uncompliant[$SYS_NAME]=0.00 if [[ $SYS_NAME == "${roha_query.cec.name}" ]] || [[ ${roha_query_codpool_members["$SYS_NAME" "state"]} != @("Operating"|"Standby") ]]; then continue fi #======================================================= : This loop is on $SYS_NAME Managed System #======================================================= if (( $needed > 0.00 )); then #======================================================= : How many mem can be got from $SYS_NAME MS even : with creating unreturned #======================================================= # We can consider that uncompliant = total - compliant because if this # path is triggered, its because all compliant is already yanked. roha_identify.codpool.mem_to_yank_uncompliant[$SYS_NAME]=${roha_query_codpool_members["$SYS_NAME" "sys_mobile_mem"]} (( roha_identify.codpool.mem_to_yank_uncompliant[$SYS_NAME] -= ${roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]} )) roha_identify.codpool.mem_to_yank_uncompliant[$SYS_NAME]=$(min ${roha_identify.codpool.mem_to_yank_uncompliant[$SYS_NAME]} ${needed}) roha_identify.codpool.mem_to_yank_uncompliant[$SYS_NAME]=$(min ${roha_identify.codpool.mem_to_yank_uncompliant[$SYS_NAME]} ${roha_query.cec.mem.realtime_inactive} ) roha_identify.codpool.mem_to_yank_uncompliant[$SYS_NAME]=$(min ${roha_identify.codpool.mem_to_yank_uncompliant[$SYS_NAME]} ${roha_query.codpool.mem.capacity}-${roha_query.codpool.mem.realtime_unreturned}) #======================================================= : Update DLPAR accordingly #======================================================= (( roha_identify.dlpar.mem += ${roha_identify.codpool.mem_to_yank_uncompliant[$SYS_NAME]} )) #======================================================= : Decrease accordingly the amount still needed #======================================================= (( needed -= ${roha_identify.codpool.mem_to_yank_uncompliant[$SYS_NAME]} )) #======================================================= : Then, always yank whole amount of Enterprise Pool : CoD resources, rounded up. #======================================================= roha_identify.codpool.mem_to_yank_uncompliant[$SYS_NAME]=$(print ${roha_identify.codpool.mem_to_yank_uncompliant[$SYS_NAME]} | awk '{printf "%0.4f\n",int($0+0.9999)}') #======================================================= : Update real inactive accordingly : what is going : to be EPCoD-yanked uncompliantly must be removed : from the amount of inactive. : Also update total amount of pool unreturned #======================================================= (( roha_query.cec.mem.realtime_inactive -= ${roha_identify.codpool.mem_to_yank_uncompliant[$SYS_NAME]} )) (( roha_query.codpool.mem.realtime_unreturned += ${roha_identify.codpool.mem_to_yank_uncompliant[$SYS_NAME]} )) #=================================================== : Update codpool mem to acquire accordingly #=================================================== (( roha_identify.codpool.mem += ${roha_identify.codpool.mem_to_yank_uncompliant[$SYS_NAME]} )) fi done fi } # End of "roha_identify_epcod_from_active_mem_to_acquire" #======================================================= # Internal function to consider DLPAR resources. # Inputs : in/out parameter needed #======================================================= function roha_identify_dlpar_mem_to_acquire { [[ $VERBOSE_LOGGING == high ]] && set -x typeset -n needed=$1 typeset -F4 freepool_to_get=0.00 if (( $needed > 0.00 )) ; then #======================================================= : There are still some needed resources. : Consider DLPAR resources. Take as much as it : can to fulfill the required. #======================================================= freepool_to_get=$(min ${needed} ${roha_query.cec.mem.free}) fi #======================================================= : Update DLPAR and needed accordingly #======================================================= (( roha_identify.dlpar.mem += ${freepool_to_get} )) (( needed -= ${freepool_to_get} )) } # End of "roha_identify_dlpar_mem_to_acquire" #========================================================= # Internal function to consider On/Off Cod resources. # Inputs : in/out parameter needed #========================================================= function roha_identify_onoff_mem_to_acquire { [[ $VERBOSE_LOGGING == high ]] && set -x typeset -n needed=$1 if (( $needed > 0.00 )) ; then #======================================================= : There are still some needed resources. : Consider On/Off CoD resources. #======================================================= if (( $(roha_session_read_odm_rohaparam "agree_to_cod_costs") == 1 )) && [[ ${roha_query.onoff.mem.state} == @("Available"|"Running"|"Unreturned") ]] && (( ${roha_query.cec.mem.realtime_inactive} > 0.00 )) ; then #======================================================= : There are available On/Off CoD resources. Take as much : as it can. #======================================================= roha_identify.onoff.mem=$(min ${needed} ${roha_query.cec.mem.realtime_inactive}) #======================================================= : On/Off CoD available resources is the sum of what was : not yet activated and what was already activated but : remains to be consumed, minus what was activated : -this is going to be activated again at apply- and : minus the unreturned if any. #======================================================= roha_identify.onoff.mem=$(min ${roha_identify.onoff.mem} ${roha_query.onoff.mem.days_avail}+${roha_query.onoff.mem.days_left}-${roha_query.onoff.mem.activated}-${roha_query.onoff.mem.unreturned} ) #======================================================= : Update DLPAR and needed accordingly. #======================================================= (( roha_identify.dlpar.mem += ${roha_identify.onoff.mem} )) (( needed -= ${roha_identify.onoff.mem} )) #======================================================= : Then, always activate whole amount of On/Off CoD : resources, rounded up. #======================================================= roha_identify.onoff.mem=$(print ${roha_identify.onoff.mem} | awk '{printf "%0.4f\n",int($0+0.9999)}') #======================================================= : Compute number of days in the request. It may modify : the amount of resources requested if always start rg. #======================================================= roha_identify_onoff_days "roha_identify.onoff.mem" "roha_identify.onoff.mem_days" "${roha_query.onoff.mem.days_avail}" "${roha_query.onoff.mem.days_left}" #======================================================= : Update inactive accordingly #======================================================= (( roha_query.cec.mem.realtime_inactive -= ${roha_identify.onoff.mem} )) fi fi } # End of "roha_identify_onoff_mem_to_acquire" [[ $VERBOSE_LOGGING == high ]] && set -x typeset -i rc=$RC_SUCCESS typeset -F4 needed=0.00 typeset -i balance_epcod_unreturned=0 (( needed = ${roha_compute.mem} )) # initialization roha_identify.dlpar.mem=0 if (( $(roha_session_read_odm_rohaparam "resource_allocation_order") == 1 )); then #================================================================== : Before trying to get Enterprise Pool, if ever there are : unreturned resources then they must be added to the amount : of resources necessary to get. #================================================================== if (( $needed > 0.00 )); then (( balance_epcod_unreturned = 1 )) (( needed += ${roha_query.codpool.mem.unreturned})) fi # first epcod normal roha_identify_epcod_mem_to_acquire needed # get previous active CEC resources either compliantly or uncompliantly roha_identify_epcod_from_previous_active_mem_to_acquire needed # get Freepool resources roha_identify_dlpar_mem_to_acquire needed # get other CEC resources either compliantly or uncompliantly roha_identify_epcod_from_active_mem_to_acquire needed elif (( $(roha_session_read_odm_rohaparam "resource_allocation_order") == 2 )); then #================================================================== : Before trying to get Enterprise Pool, if ever there are : unreturned resources then they must be added to the amount : of resources necessary to get. #================================================================== if (( $needed > 0.00 )); then (( balance_epcod_unreturned = 1 )) (( needed += ${roha_query.codpool.mem.unreturned})) fi # first epcod normal roha_identify_epcod_mem_to_acquire needed # get previous hosting CEC resources either compliantly or uncompliantly roha_identify_epcod_from_previous_active_mem_to_acquire needed # get other CEC resources either compliantly or uncompliantly roha_identify_epcod_from_active_mem_to_acquire needed # get Freepool resources roha_identify_dlpar_mem_to_acquire needed else # first dlpar roha_identify_dlpar_mem_to_acquire needed #================================================================== : Before trying to get Enterprise Pool, if ever there are : unreturned resources then they must be added to the amount : of resources necessary to get. #================================================================== if (( $needed > 0.00 )); then (( balance_epcod_unreturned = 1 )) (( needed += ${roha_query.codpool.mem.unreturned} )) fi # then epcod normal, then epcod yank roha_identify_epcod_mem_to_acquire needed # get other CEC resources either compliantly or uncompliantly roha_identify_epcod_from_previous_active_mem_to_acquire needed # get active CEC resources either compliantly or uncompliantly roha_identify_epcod_from_active_mem_to_acquire needed fi # then onoff roha_identify_onoff_mem_to_acquire needed #==================================================================== : If Enterprise Pool unreturned resources were considered, they were not : acquired for the LPAR, so remove them. Also we cannot acquire : less than 0. #==================================================================== if (( $balance_epcod_unreturned == 1 )); then (( roha_identify.dlpar.mem -= ${roha_query.codpool.mem.unreturned} )) roha_identify.dlpar.mem=$(max ${roha_identify.dlpar.mem} 0.00) fi if (( $needed > 0.00 )) ; then #======================================================= : There are still some needed resources. : Check if SystemMirror should always : start RGs or not. #======================================================= if (( $(roha_session_read_odm_rohaparam "always_start_rg") == 0 )) ; then #======================================================= : Notify user. #======================================================= roha_session_log "$(dspmsg -s $ROHA_SET $ROHA_MSGS 117 \ "%1\$s: ERROR: %2\$d GB of memory needed will exceed available resources. %3\$d GB of memory cannot be satisfied by On/Off CoD nor Enterprise Pool resources.\n" \ "$PROGNAME" "${roha_compute.mem}" "$needed")" #======================================================= : There are not enough free resources. Do not acquire : any. #======================================================= roha_identify.dlpar.mem=0.00 roha_identify.codpool.mem=0.00 roha_identify.onoff.mem=0.00 roha_identify.onoff.mem_days=0 typeset SYS_NAME="" for SYS_NAME in ${roha_query_codpool_members_names}; do roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]=0.00 roha_identify.codpool.mem_to_yank_uncompliant[$SYS_NAME]=0.00 done rc=$RC_IDENTIFY_MEM_ERROR_RESOURCES fi fi return $rc } # End of "roha_identify_mem_to_acquire()" #============================================================================= # # Name: roha_identify_mem_to_acquire_report # # Description: Displays computation results. # # Inputs: None # # Outputs: None # # Globals: roha_query # roha_identify # # Returns: None # #============================================================================= function roha_identify_mem_to_acquire_report { roha_session_log "$(print "=========== Identify ROHA Memory ===========")" roha_session_log "$(print "Remaining available memory for partition: \t${roha_query.cec.mem.free} GB")" typeset -F4 total_epcod_to_acquire=${roha_identify.codpool.mem} if [[ -n ${roha_session.other_lpar} ]] ; then roha_session_log "$(print "Total Enterprise Pool memory to yank normal from" )" roha_session_log "$(print "\t${roha_session.other_cec}: \t${roha_identify.codpool.mem_to_yank} GB")" (( total_epcod_to_acquire += ${roha_identify.codpool.mem_to_yank} )) fi typeset SYS_NAME="" for SYS_NAME in ${roha_query_codpool_members_names}; do if [[ $SYS_NAME == "${roha_query.cec.name}" ]]; then continue fi roha_session_log "$(print "Total Enterprise Pool memory to yank compliantly from" )" roha_session_log "$(print "\t$SYS_NAME MS: \t${roha_identify.codpool.mem_to_yank_compliant[$SYS_NAME]:-0.00} GB")" roha_session_log "$(print "Total Enterprise Pool memory to yank uncompliantly from" )" roha_session_log "$(print "\t$SYS_NAME MS: \t${roha_identify.codpool.mem_to_yank_uncompliant[$SYS_NAME]:-0.00} GB")" done roha_session_log "$(print "Total Enterprise Pool memory to acquire including all yanked amounts: \t${total_epcod_to_acquire} GB")" roha_session_log "$(print "Total On/Off CoD memory to activate: \t${roha_identify.onoff.mem} GB for ${roha_identify.onoff.mem_days} days")" roha_session_log "$(print "Total DLPAR memory to allocate: \t${roha_identify.dlpar.mem} GB")" if (( ${roha_compute.mem} != ${roha_identify.dlpar.mem} )) && (( $(roha_session_read_odm_rohaparam "always_start_rg") == 1 )) ; then roha_session_log "$(print "Total DLPAR memory computed to be allocated was ${roha_compute.mem}, but as always_start_rg=1, acquisition is performed at best, rather than failing.")" fi roha_session_log "$(print "=================== End ====================\n")" } # End of "roha_identify_mem_to_acquire_report()" #============================================================================= # # Name: roha_identify_mem_to_release # # Description: Find out how much this LPAR could possibly release in terms of # On/Off or Enterprise Pool CoD. First, consider On/Off CoD # resources. Then, consider Enterprise Pool CoD. # As far as DLPAR release is concerned, this function considers # information from HACMPdynresop as a maximum to be released. # # Inputs: None # # Outputs: None # # Globals: roha_query # roha_compute # roha_identify # # Returns: RC_SUCCESS # #============================================================================= function roha_identify_mem_to_release { [[ $VERBOSE_LOGGING == high ]] && set -x # Total to be released for this LPAR, for the DLPAR release. # This was computed by taking into account what workload # remains to be run on this LPAR, and taking into account # as a base level, either the 'min' level of the LPAR, or the # 'desired' level of the LPAR, depending on type of ROHA # configuration set on Application Controllers (if there # are any 'use_desired' ROHA or not). typeset -F4 to_release=0.00 # This is computed by taking into account what is free at the CEC level # and this amount evolves to store what remains to be released # on Enterprise Pool after release of On/Off CoD. typeset -F4 temp_to_release=0.00 (( to_release = ${roha_compute.mem} )) (( temp_to_release = ${to_release} )) #======================================================= : Find out how much this LPAR could possibly release in : terms of On/Off CoD or Enterprise Pool CoD or DLPAR. : First, try to release them back from On/Off CoD. #======================================================= if (( $temp_to_release > 0.00 && $(roha_session_read_odm_rohaparam "agree_to_cod_costs") == 1 )) ; then typeset -F4 odm_onoff_mem=$(roha_session_read_odm_dynresop "ONOFF_MEM") if (( ${roha_query.onoff.mem.activated} >= 0.00 )) ; then #======================================================= : There were some On/Off CoD activated. : Do not release more than what needs to be released, : no more than the amount activated, : and no more than the value stored in ODM. : Always release whole amount of On/Off CoD resources. : Either rounded up or down depending on what has to be : released and what would be left available after release. #======================================================= roha_identify.onoff.mem=$(min ${temp_to_release} ${roha_query.onoff.mem.activated}) roha_identify.onoff.mem=$(min ${roha_identify.onoff.mem} $odm_onoff_mem) typeset -F4 round_up=$(print ${roha_identify.onoff.mem} | awk '{printf "%0.4f\n",int($0+0.9999)}') typeset -F4 round_down=$(print ${roha_identify.onoff.mem} | awk '{printf "%0.4f\n",int($0)}') if (( ${roha_query.cec.mem.available} + ${roha_identify.onoff.mem} >= $round_up )) ; then roha_identify.onoff.mem=$round_up else roha_identify.onoff.mem=$round_down fi #==================================================================================== : Reset the resource value in ODM if there are no OnOff COD memory resources to be released. #==================================================================================== if (( ${roha_identify.onoff.mem} == 0.00 && $odm_onoff_mem > 0.00 )) ; then roha_session_write_odm_dynresop ONOFF_MEM 0 fi #======================================================= : What remains to be released is what has not been : de-activated on On/Off CoD. #======================================================= (( temp_to_release -= ${roha_identify.onoff.mem} )) fi fi #======================================================= : If there are still some resources to be released : and we are not in async, try to release them back from : the Enterprise Pool CoD. #======================================================= rel_apps=$(ODMDIR=/etc/es/objrepos clodmget -q "key=REL_APPS" -nf value HACMPdynresop 2>/dev/null) if (( $temp_to_release > 0.00 )) && [[ -z ${rel_apps} ]] ; then typeset -F4 odm_codpool_mem=$(roha_session_read_odm_dynresop "CODPOOL_MEM") if (( ${roha_query.codpool.mem.mobile} >= 0.00 )) ; then #======================================================= : There were some Enterprise Pool acquired. : Do not release more than what needs to be released, : no more than the amount acquired, : and no more than the value stored in ODM. : Always release whole amount of Enterprise Pool resources. : Either rounded up or down depending on what has to be : released and what would be left available after release. #======================================================= roha_identify.codpool.mem=$(min ${temp_to_release} ${roha_query.codpool.mem.mobile}) roha_identify.codpool.mem=$(min ${roha_identify.codpool.mem} $odm_codpool_mem) typeset -F4 round_up=$(print ${roha_identify.codpool.mem} | awk '{printf "%0.4f\n",int($0+0.9999)}') typeset -F4 round_down=$(print ${roha_identify.codpool.mem} | awk '{printf "%0.4f\n",int($0)}') if (( ${roha_query.cec.mem.available} + ${roha_identify.codpool.mem} >= $round_up )) ; then roha_identify.codpool.mem=$round_up else roha_identify.codpool.mem=$round_down fi #=========================================================================================== : Reset the resource value in ODM if there are no EPCOD memory resources to be released. #=========================================================================================== if (( ${roha_identify.codpool.mem} == 0.00 && $odm_codpool_mem > 0.00 )) ; then roha_session_write_odm_dynresop CODPOOL_MEM 0 fi fi fi #========================================================================= : Reduce unreturned from identified codpool #========================================================================= if (( ${roha_identify.codpool.mem} > 0.00 )) && (( ${roha_query.codpool.mem.unreturned} > 0.00 )) ; then (( roha_identify.codpool.mem=${roha_identify.codpool.mem} - ${roha_query.codpool.mem.unreturned} )) if (( ${roha_identify.codpool.mem} < 0.00 )) ; then roha_identify.codpool.mem=0 fi fi #========================================================================= : Finally, dlpar to be released is what was computed to be released at : LPAR level #========================================================================= roha_identify.dlpar.mem=${to_release} return $RC_SUCCESS } # End of "roha_identify_mem_to_release()" #============================================================================= # # Name: roha_identify_mem_to_release_report # # Description: Displays computation results. # # Inputs: None # # Outputs: None # # Globals: roha_identify # # Returns: None # #============================================================================= function roha_identify_mem_to_release_report { roha_session_log "$(print "============ Identify ROHA Memory ============")" roha_session_log "$(print "Total Enterprise Pool memory to return back: \t${roha_identify.codpool.mem} GB")" roha_session_log "$(print "Total On/Off CoD memory to de-activate: \t${roha_identify.onoff.mem} GB")" roha_session_log "$(print "Total DLPAR memory to release: \t${roha_identify.dlpar.mem} GB")" roha_session_log "$(print "=================== End ======================\n")" } # End of "roha_identify_mem_to_release_report()" #============================================================================= # # Name: roha_identify_cpu # # Description: Find out how much this LPAR could possibly acquire in terms of # DLPAR, Enterprise Pool, or On/Off CoD. Depending on the # configurable order of acquisition (DLPAR first/Enterprise Pool # second or Enterprise Pool first/DLPAR second), consider # successively DLPAR resources and Enterprise Pool resources. # Then, consider On/Off CoD resources. And, check if SystemMirror # should always start RGs or not. # # Inputs: None # # Outputs: None # # Globals: roha_query # roha_session # # Returns: RC_SUCCESS # or else, failure error code. # #============================================================================= function roha_identify_cpu { [[ $VERBOSE_LOGGING == high ]] && set -x typeset -i rc=$RC_SUCCESS if [[ ${roha_query.lpar.cpu.proc_mode} == "shared" ]] ; then if [[ ${roha_session.operation} == "acquire" ]] ; then roha_identify_shd_cpu_to_acquire rc=$? else # [[ ${roha_session.operation} == "release" ]] roha_identify_shd_cpu_to_release rc=$? fi else # [[ ${roha_query.lpar.cpu.proc_mode} == "ded" ]] if [[ ${roha_session.operation} == "acquire" ]] ; then roha_identify_ded_cpu_to_acquire rc=$? else # [[ ${roha_session.operation} == "release" ]] roha_identify_ded_cpu_to_release rc=$? fi fi return $rc } # End of "roha_identify_cpu()" #============================================================================= # # Name: roha_identify_cpu_report # # Description: Displays computation results. # # Inputs: None # # Outputs: None # # Globals: roha_query # roha_session # # Returns: None # #============================================================================= function roha_identify_cpu_report { case ${roha_query.lpar.cpu.proc_mode} in "shared") case ${roha_session.operation} in "acquire") roha_identify_shd_cpu_to_acquire_report ;; "release") roha_identify_shd_cpu_to_release_report ;; esac ;; "ded") case ${roha_session.operation} in "acquire") roha_identify_ded_cpu_to_acquire_report ;; "release") roha_identify_ded_cpu_to_release_report ;; esac ;; esac } # End of "roha_identify_cpu_report()" #============================================================================= # # Name: roha_identify_shd_cpu_to_acquire # # Description: Find out how much this LPAR could possibly acquire in terms of # DLPAR, Enterprise Pool, or On/Off CoD. # Consider DLPAR resources. # Consider Enterprise Pool resources (normal, yank normal/force). # Consider On/Off CoD resources. # Check if SystemMirror should always start RGs or not # # Tunable resource_allocation_order modifies the # precedence order between sources of resources. # If resource_allocation_order set to 1 # - Enterprise Pool # - DLPAR # - Enterprise Pool with yank normal/force # If resource_allocation_order set to 2 # - Enterprise Pool # - Enterprise Pool with yank normal/force # - DLPAR # Otherwise, order is # - DLPAR # - Enterprise Pool # - Enterprise Pool with yank normal/force # # Inputs: None # # Outputs: None # # Internal functions: # function roha_identify_epcod_shd_cpu_to_acquire # function roha_identify_epcod_from_previous_active_shd_cpu_to_acquire # function roha_identify_epcod_from_active_shd_cpu_to_acquire # function roha_identify_dlpar_shd_cpu_to_acquire # function roha_identify_onoff_shd_cpu_to_acquire # # Globals: roha_query # roha_compute # roha_identify # # Returns: RC_SUCCESS # RC_IDENTIFY_CPU_ERROR_RESOURCES # #============================================================================= function roha_identify_shd_cpu_to_acquire { #======================================================= # Internal function to consider Enterprise Pool CoD # resources. # Inputs : in/out parameter needed. #======================================================= function roha_identify_epcod_shd_cpu_to_acquire { [[ $VERBOSE_LOGGING == high ]] && set -x typeset -n needed=$1 if (( $needed > 0.00 )) ; then #======================================================= : There are still some needed resources. : Consider Enterprise Pool CoD resources. #======================================================= if [[ ${roha_query.codpool.state} == @("In compliance"|"Approaching")* ]] && (( ${roha_query.cec.cpu.realtime_inactive} > 0.00 )) && (( ${roha_query.codpool.cpu.available} >= 0.00 )); then #======================================================= : There are available resources in Enterprise Pool CoD, : take as much as it can, but no more than inactive. #======================================================= roha_identify.codpool.cpu=$(min ${needed} ${roha_query.codpool.cpu.available}) roha_identify.codpool.cpu=$(min ${roha_identify.codpool.cpu} ${roha_query.cec.cpu.realtime_inactive}) #======================================================= : Update DLPAR and needed accordingly : Remove from needed what is going to be Enterprise Pool-acquired #======================================================= (( roha_identify.dlpar.pu += ${roha_identify.codpool.cpu} )) (( needed -= ${roha_identify.codpool.cpu} )) #======================================================= : Then, always allocate whole amount of Enterprise Pool : CoD resources, rounded up. : Update real inactive accordingly : what is going : to be EPCoD-acquired must be removed from the amount : of inactive. #======================================================= roha_identify.codpool.cpu=$(print ${roha_identify.codpool.cpu} | awk '{printf "%0.4f\n",int($0+0.9999)}') (( roha_query.cec.cpu.realtime_inactive -= ${roha_identify.codpool.cpu} )) fi fi if (( $needed > 0.00 )) ; then #======================================================= : There are still some needed resources. : Consider releasing Enterprise Pool : CoD resources from 'other' managed system only : if using the same pool. : This is the 'normal' yank : we only yank from the : other Managed System if it is down, or if the LPAR is : down, we do not create unreturned resources, we do not : yank more than what was DLPAR allocated on the other : LPAR. #======================================================= if [[ -n ${roha_session.other_lpar} ]] && (( ${roha_query.other_node.codpool.cpu.mobile} > 0.00 )) && [[ ${roha_query.other_node.codpool.name} == ${roha_query.codpool.name} ]] ; then if [[ ${roha_query.other_node.cec.state} != @("Operating"|"Standby") ]] ; then #======================================================= : Source Managed System is down and there are resources : in Enterprise Pool CoD to be yanked. : Take as much as it can. : You cannot take more than the available nor the inactive. #======================================================= roha_identify.codpool.cpu_to_yank=$(min ${needed} ${roha_query.other_node.codpool.cpu.mobile}) roha_identify.codpool.cpu_to_yank=$(min ${roha_identify.codpool.cpu_to_yank} ${roha_query.cec.cpu.realtime_inactive}) elif [[ ${roha_query.other_node.lpar.state} != @("Running") ]] ; then #======================================================= : Source LPAR is down and there are resources in : Enterprise Pool CoD to be yanked. : Take as much as it can. : You cannot take more than the available nor the inactive. : We can take only from the LPAR what would be released by : this LPAR : curr - min. To know if we round up or down, : we use the same method then the one used in the real release. #======================================================= roha_identify.codpool.cpu_to_yank=$(min ${needed} ${roha_query.other_node.codpool.cpu.mobile}) roha_identify.codpool.cpu_to_yank=$(min ${roha_identify.codpool.cpu_to_yank} ${roha_query.cec.cpu.realtime_inactive}) typeset -F4 other_node_roha if [[ ${roha_query.other_node.lpar.cpu.proc_mode} == "shared" ]] ; then (( other_node_roha = ${roha_query.other_node.lpar.cpu.proc_units.curr} - ${roha_query.other_node.lpar.cpu.proc_units.min} )) typeset -F4 other_node_roha_up=$(print ${other_node_roha} | awk '{printf "%0.4f\n",int($0+0.9999)}') typeset -F4 other_node_roha_down=$(print ${other_node_roha} | awk '{printf "%0.4f\n",int($0)}') if (( ${roha_query.other_node.cec.cpu.available} + ${other_node_roha} >= ${other_node_roha_up} )) ; then other_node_roha=$other_node_roha_up else other_node_roha=$other_node_roha_down fi else (( other_node_roha = ${roha_query.other_node.lpar.cpu.procs.curr} - ${roha_query.other_node.lpar.cpu.procs.min} )) fi roha_identify.codpool.cpu_to_yank=$(min ${roha_identify.codpool.cpu_to_yank} ${other_node_roha} ) #======================================================= : Because of EPCoD unreturned limit, we cannot yank : uncompliantly more than the pool capacity. So that the : yank cannot exceed the other_node available resource : for the compliant part, and the difference between the : EPCoD capacity and the EPCoD unreturned for the uncompliant : part. #======================================================= roha_identify.codpool.cpu_to_yank=$(min ${roha_identify.codpool.cpu_to_yank} ${roha_query_codpool_members["${roha_query.other_node.cec.name}" "realtime_curr_avail_sys_proc_units"]}+${roha_query.codpool.cpu.capacity}-${roha_query.codpool.cpu.realtime_unreturned}) else roha_identify.codpool.cpu_to_yank=0.00 fi #======================================================= : Update DLPAR and needed accordingly : Remove from needed what is going to be EPCoD-yanked #======================================================= (( roha_identify.dlpar.pu += ${roha_identify.codpool.cpu_to_yank} )) (( needed -= ${roha_identify.codpool.cpu_to_yank} )) #======================================================= : Then, always yank whole amount of Enterprise Pool : CoD resources, rounded up. : Update real inactive accordingly : what is going : to be EPCoD-yanked must be removed from the amount : of inactive. #======================================================= roha_identify.codpool.cpu_to_yank=$(print ${roha_identify.codpool.cpu_to_yank} | awk '{printf "%0.4f\n",int($0+0.9999)}') (( roha_query.cec.cpu.realtime_inactive -= ${roha_identify.codpool.cpu_to_yank} )) #======================================================= : Update : realtime pool unreturned : realtime other_cec available #======================================================= (( roha_query.codpool.cpu.realtime_unreturned += $(max 0.00 ${roha_identify.codpool.cpu_to_yank}-${roha_query_codpool_members["${roha_query.other_node.cec.name}" "realtime_curr_avail_sys_proc_units"]}) )) roha_query_codpool_members["${roha_query.other_node.cec.name}" "realtime_curr_avail_sys_proc_units"]=$(max 0.00 ${roha_query_codpool_members["${roha_query.other_node.cec.name}" "realtime_curr_avail_sys_proc_units"]}-${roha_identify.codpool.cpu_to_yank} ) #======================================================= : What is going to be EPCoD-yanked here cannot be : EPCoD-yanked force. So remove it from the amount of : mobile resources available on this other cec. #======================================================= (( roha_query_codpool_members["${roha_session.other_cec}" "sys_mobile_procs"] -= ${roha_identify.codpool.cpu_to_yank} )) fi fi } # End of "roha_identify_epcod_shd_cpu_to_acquire()" #======================================================= # Internal function to consider DLPAR resources. # Inputs : in/out parameter needed #======================================================= function roha_identify_dlpar_shd_cpu_to_acquire { [[ $VERBOSE_LOGGING == high ]] && set -x typeset -n needed=$1 typeset -F4 freepool_to_get=0.00 if (( $needed > 0.00 )) ; then #======================================================= : There are still some needed resources. : Consider DLPAR resources. Take as much as it : can to fulfill the required. #======================================================= freepool_to_get=$(min ${needed} ${roha_query.cec.cpu.free}) fi #======================================================= : Update DLPAR and needed accordingly #======================================================= (( roha_identify.dlpar.pu += ${freepool_to_get} )) (( needed -= ${freepool_to_get} )) } # End of "roha_identify_dlpar_shd_cpu_to_acquire()" #======================================================= # Internal function to consider Enterprise Pool CoD # resources from Previous Hosting Managed Systems. # Inputs : in/out parameter needed #======================================================= function roha_identify_epcod_from_previous_active_shd_cpu_to_acquire { [[ $VERBOSE_LOGGING == high ]] && set -x typeset -n needed=$1 typeset SYS_NAME="${roha_query.other_node.cec.name}" if (( $needed > 0.00 )) && [[ -n $SYS_NAME && $SYS_NAME != "${roha_query.cec.name}" ]]; then #======================================================= : There are still some needed resources. : Consider releasing Enterprise Pool : CoD resources from Previous hosting managed systems : using the same Enterprise Pool. : Go through and compute what can be got from : this managed system : without creating unreturned : with creating unreturned #======================================================= #=================================================================== : Search for Enterprise Pool resources, without creating unreturned. #=================================================================== roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]=0.00 #======================================================= : This is on $SYS_NAME Managed System #======================================================= if (( $needed > 0.00 )); then #======================================================= : How many procs can be got from $SYS_NAME MS without : creating unreturned. #======================================================= if (( ${roha_query_codpool_members["$SYS_NAME" "sys_unreturned_mobile_procs"]} == 0.00 )); then #======================================================= : Check available amounts on CEC only in case of CEC up : because unreturned are not generated on a down CEC #======================================================= if [[ ${roha_query_codpool_members["$SYS_NAME" "state"]} == @("Operating"|"Standby") ]] ; then roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]=$(min ${roha_query_codpool_members["$SYS_NAME" "sys_mobile_procs"]} ${roha_query_codpool_members["$SYS_NAME" "curr_avail_sys_proc_units"]} ) else roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]=${roha_query_codpool_members["$SYS_NAME" "sys_mobile_procs"]} fi #======================================================= : Only whole amounts can be yanked compliantly : rounded down #======================================================= roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]=$(print ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} | awk '{printf "%0.4f\n",int($0)}') #======================================================= : Then limit amount to what is really needed : and what can really be acquired #======================================================= roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]=$(min ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} ${needed}) roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]=$(min ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} ${roha_query.cec.cpu.realtime_inactive} ) #======================================================== : Update DLPAR accordingly #======================================================= (( roha_identify.dlpar.pu += ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} )) #======================================================= : Decrease accordingly the amount still needed #======================================================= (( needed -= ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} )) #======================================================= : Then, always yank whole amount of Enterprise Pool : CoD resources, rounded up. #======================================================= roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]=$(print ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} | awk '{printf "%0.4f\n",int($0+0.9999)}') #======================================================= : Update real inactive accordingly : what is going : to be EPCoD-yanked compliantly must be removed : from the amount of inactive. : Also update realtime available on yanked CEC if up #======================================================= (( roha_query.cec.cpu.realtime_inactive -= ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} )) if [[ ${roha_query_codpool_members["$SYS_NAME" "state"]} == @("Operating"|"Standby") ]] ; then (( roha_query_codpool_members["$SYS_NAME" "realtime_curr_avail_sys_proc_units"] -= ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} )) fi #=================================================== : Update codpool cpu to acquire accordingly #=================================================== (( roha_identify.codpool.cpu += ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} )) else #======================================================= : Nothing to be done, as there is already some unreturned : on this CEC #======================================================= fi fi #===================================================================== : Search for Enterprise Pool resources, even with creating unreturned. #===================================================================== roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]=0.00 #======================================================= : This is on $SYS_NAME Managed System #======================================================= if (( $needed > 0.00 )); then #======================================================= : How many procs can be got from $SYS_NAME MS even : with creating unreturned #======================================================= roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]=${roha_query_codpool_members["$SYS_NAME" "sys_mobile_procs"]} (( roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME] -= ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} )) roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]=$(min ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} ${needed}) roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]=$(min ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} ${roha_query.cec.cpu.realtime_inactive} ) roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]=$(min ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} ${roha_query.codpool.cpu.capacity}-${roha_query.codpool.cpu.realtime_unreturned}) #======================================================= : Update DLPAR accordingly #======================================================= (( roha_identify.dlpar.pu += ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} )) #======================================================= : Decrease accordingly the amount still needed #======================================================= (( needed -= ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} )) #======================================================= : Then, always yank whole amount of Enterprise Pool : CoD resources, rounded up. #======================================================= roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]=$(print ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} | awk '{printf "%0.4f\n",int($0+0.9999)}') #======================================================= : Update real inactive accordingly : what is going : to be EPCoD-yanked uncompliantly must be removed : from the amount of inactive. : Also update total amount of pool unreturned #======================================================= (( roha_query.cec.cpu.realtime_inactive -= ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} )) (( roha_query.codpool.cpu.realtime_unreturned += ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} )) #=================================================== : Update codpool cpu to acquire accordingly #=================================================== (( roha_identify.codpool.cpu += ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} )) fi fi } # End of "roha_identify_epcod_from_previous_active_shd_cpu_to_acquire" #======================================================= # Internal function to consider Enterprise Pool CoD # resources from Active Managed Systems. # Inputs : in/out parameter needed #======================================================= function roha_identify_epcod_from_active_shd_cpu_to_acquire { [[ $VERBOSE_LOGGING == high ]] && set -x typeset -n needed=$1 if (( $needed > 0.00 )) ; then #======================================================= : There are still some needed resources. : Consider releasing Enterprise Pool : CoD resources from active managed systems using : the same Enterprise Pool. : Go through all managed systems sharing this : Enterprise Pool and compute what can be got from : this managed system : without creating unreturned : with creating unreturned #======================================================= #======================================================= : Loop around Managed Systems to search for Enterprise Pool : resources, without creating unreturned. #======================================================= typeset SYS_NAME="" for SYS_NAME in ${roha_query_codpool_members_names}; do #======================================================= # Resources from previous active are already considered #======================================================= if [[ $SYS_NAME == "${roha_query.other_node.cec.name}" ]]; then continue fi roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]=0.00 if [[ $SYS_NAME == "${roha_query.cec.name}" ]]; then continue fi #======================================================= : This loop is on $SYS_NAME Managed System #======================================================= if (( $needed > 0.00 )); then #======================================================= : How many procs can be got from $SYS_NAME MS without : creating unreturned. #======================================================= if (( ${roha_query_codpool_members["$SYS_NAME" "sys_unreturned_mobile_procs"]} == 0.00 )); then #======================================================= : Check available amounts on CEC only in case of CEC up : because unreturned are not generated on a down CEC #======================================================= if [[ ${roha_query_codpool_members["$SYS_NAME" "state"]} == @("Operating"|"Standby") ]] ; then roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]=$(min ${roha_query_codpool_members["$SYS_NAME" "sys_mobile_procs"]} ${roha_query_codpool_members["$SYS_NAME" "curr_avail_sys_proc_units"]} ) else roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]=${roha_query_codpool_members["$SYS_NAME" "sys_mobile_procs"]} fi #======================================================= : Only whole amounts can be yanked compliantly : rounded down #======================================================= roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]=$(print ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} | awk '{printf "%0.4f\n",int($0)}') #======================================================= : Then limit amount to what is really needed : and what can really be acquired #======================================================= roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]=$(min ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} ${needed}) roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]=$(min ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} ${roha_query.cec.cpu.realtime_inactive} ) #======================================================== : Update DLPAR accordingly #======================================================= (( roha_identify.dlpar.pu += ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} )) #======================================================= : Decrease accordingly the amount still needed #======================================================= (( needed -= ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} )) #======================================================= : Then, always yank whole amount of Enterprise Pool : CoD resources, rounded up. #======================================================= roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]=$(print ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} | awk '{printf "%0.4f\n",int($0+0.9999)}') #======================================================= : Update real inactive accordingly : what is going : to be EPCoD-yanked compliantly must be removed : from the amount of inactive. : Also update realtime available on yanked CEC if up #======================================================= (( roha_query.cec.cpu.realtime_inactive -= ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} )) if [[ ${roha_query_codpool_members["$SYS_NAME" "state"]} == @("Operating"|"Standby") ]] ; then (( roha_query_codpool_members["$SYS_NAME" "realtime_curr_avail_sys_proc_units"] -= ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} )) fi #=================================================== : Update codpool cpu to acquire accordingly #=================================================== (( roha_identify.codpool.cpu += ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} )) else #======================================================= : Nothing to be done, as there is already some unreturned : on this CEC #======================================================= fi fi done #======================================================= : Loop around Managed Systems to search for Enterprise Pool : resources, even with creating unreturned. #======================================================= for SYS_NAME in ${roha_query_codpool_members_names}; do #======================================================= # Resources from previous active are already considered #======================================================= if [[ $SYS_NAME == "${roha_query.other_node.cec.name}" ]]; then continue fi roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]=0.00 if [[ $SYS_NAME == "${roha_query.cec.name}" ]] || [[ ${roha_query_codpool_members["$SYS_NAME" "state"]} != @("Operating"|"Standby") ]]; then continue fi #======================================================= : This loop is on $SYS_NAME Managed System #======================================================= if (( $needed > 0.00 )); then #======================================================= : How many procs can be got from $SYS_NAME MS even : with creating unreturned #======================================================= roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]=${roha_query_codpool_members["$SYS_NAME" "sys_mobile_procs"]} (( roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME] -= ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} )) roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]=$(min ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} ${needed}) roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]=$(min ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} ${roha_query.cec.cpu.realtime_inactive} ) roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]=$(min ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} ${roha_query.codpool.cpu.capacity}-${roha_query.codpool.cpu.realtime_unreturned}) #======================================================= : Update DLPAR accordingly #======================================================= (( roha_identify.dlpar.pu += ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} )) #======================================================= : Decrease accordingly the amount still needed #======================================================= (( needed -= ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} )) #======================================================= : Then, always yank whole amount of Enterprise Pool : CoD resources, rounded up. #======================================================= roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]=$(print ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} | awk '{printf "%0.4f\n",int($0+0.9999)}') #======================================================= : Update real inactive accordingly : what is going : to be EPCoD-yanked uncompliantly must be removed : from the amount of inactive. : Also update total amount of pool unreturned #======================================================= (( roha_query.cec.cpu.realtime_inactive -= ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} )) (( roha_query.codpool.cpu.realtime_unreturned += ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} )) #=================================================== : Update codpool cpu to acquire accordingly #=================================================== (( roha_identify.codpool.cpu += ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} )) fi done fi } # End of "roha_identify_epcod_from_active_shd_cpu_to_acquire" #========================================================= # Internal function to consider On/Off Cod resources. # Inputs : in/out parameter needed #========================================================= function roha_identify_onoff_shd_cpu_to_acquire { [[ $VERBOSE_LOGGING == high ]] && set -x typeset -n needed=$1 if (( $needed > 0.00 )) ; then #======================================================= : There are still some needed resources. : Consider On/Off CoD resources. #======================================================= if (( $(roha_session_read_odm_rohaparam "agree_to_cod_costs") == 1 )) && [[ ${roha_query.onoff.cpu.state} == @("Available"|"Running"|"Unreturned") ]] && (( ${roha_query.cec.cpu.realtime_inactive} > 0.00 )) ; then #======================================================= : There are available On/Off CoD resources. Take as much : as it can. #======================================================= roha_identify.onoff.cpu=$(min ${needed} ${roha_query.cec.cpu.realtime_inactive}) roha_identify.onoff.cpu=$(min ${roha_identify.onoff.cpu} ${roha_query.onoff.cpu.days_avail}+${roha_query.onoff.cpu.days_left}-${roha_query.onoff.cpu.activated}-${roha_query.onoff.cpu.unreturned}) #======================================================= : Update DLPAR and needed accordingly. #======================================================= (( roha_identify.dlpar.pu += ${roha_identify.onoff.cpu} )) (( needed -= ${roha_identify.onoff.cpu} )) #======================================================= : Then, always activate whole amount of On/Off CoD : resources, rounded up. #======================================================= roha_identify.onoff.cpu=$(print ${roha_identify.onoff.cpu} | awk '{printf "%0.4f\n",int($0+0.9999)}') #======================================================= : Compute number of days in the request. It may modify : the amount of resources requested if always start rg. #======================================================= roha_identify_onoff_days "roha_identify.onoff.cpu" "roha_identify.onoff.cpu_days" "${roha_query.onoff.cpu.days_avail}" "${roha_query.onoff.cpu.days_left}" #======================================================= : Update realtime inactive accordingly. #======================================================= (( roha_query.cec.cpu.realtime_inactive -= ${roha_identify.onoff.cpu} )) fi fi } # End of "roha_identify_onoff_shd_cpu_to_acquire()" [[ $VERBOSE_LOGGING == high ]] && set -x typeset -i rc=$RC_SUCCESS typeset -F4 needed=0.00 typeset -i balance_epcod_unreturned=0 roha_identify.dlpar.pu=0 roha_identify.dlpar.vp=0 roha_identify.dlpar.spp_size=0 (( needed = ${roha_compute.pu} )) if (( $(roha_session_read_odm_rohaparam "resource_allocation_order") == 1 )); then #================================================================== : Before trying to get Enterprise Pool, if ever there are : unreturned resources then they must be added to the amount : of resources necessary to get. #================================================================== if (( $needed > 0.00 )); then (( balance_epcod_unreturned = 1 )) (( needed += ${roha_query.codpool.cpu.unreturned})) fi # first epcod normal, then epcod yank roha_identify_epcod_shd_cpu_to_acquire needed # get previous active CEC resources either compliantly or uncompliantly roha_identify_epcod_from_previous_active_shd_cpu_to_acquire needed # get Freepool resources roha_identify_dlpar_shd_cpu_to_acquire needed # get other CEC resources either compliantly or uncompliantly roha_identify_epcod_from_active_shd_cpu_to_acquire needed elif (( $(roha_session_read_odm_rohaparam "resource_allocation_order") == 2 )); then #================================================================== : Before trying to get Enterprise Pool, if ever there are : unreturned resources then they must be added to the amount : of resources necessary to get. #================================================================== if (( $needed > 0.00 )); then (( balance_epcod_unreturned = 1 )) (( needed += ${roha_query.codpool.cpu.unreturned})) fi # first epcod normal, then epcod yank roha_identify_epcod_shd_cpu_to_acquire needed # get previous active CEC resources either compliantly or uncompliantly roha_identify_epcod_from_previous_active_shd_cpu_to_acquire needed # get other CEC resources either compliantly or uncompliantly roha_identify_epcod_from_active_shd_cpu_to_acquire needed # get Freepool resources roha_identify_dlpar_shd_cpu_to_acquire needed else # first dlpar roha_identify_dlpar_shd_cpu_to_acquire needed #================================================================== : Before trying to get Enterprise Pool, if ever there are : unreturned resources then they must be added to the amount : of resources necessary to get. #================================================================== if (( $needed > 0.00 )); then (( balance_epcod_unreturned = 1 )) (( needed += ${roha_query.codpool.cpu.unreturned} )) fi # then epcod normal, then epcod yank roha_identify_epcod_shd_cpu_to_acquire needed # get other CEC resources either compliantly or uncompliantly roha_identify_epcod_from_previous_active_shd_cpu_to_acquire needed # then epcod yank force roha_identify_epcod_from_active_shd_cpu_to_acquire needed fi # then onoff roha_identify_onoff_shd_cpu_to_acquire needed #==================================================================== : If Enterprise Pool unreturned resources were considered, they were not : acquired for the LPAR, so remove them. Also we cannot acquire : less than 0. #==================================================================== if (( $balance_epcod_unreturned == 1 )); then (( roha_identify.dlpar.pu -= ${roha_query.codpool.cpu.unreturned} )) roha_identify.dlpar.pu=$(max ${roha_identify.dlpar.pu} 0.00) fi roha_identify.dlpar.vp=${roha_compute.vp} roha_identify.dlpar.spp_size=${roha_compute.spp_size} if (( $needed > 0.00 )) ; then #======================================================= : There are still some needed resources. : Check if SystemMirror should always : start RGs or not. #======================================================= if (( $(roha_session_read_odm_rohaparam "always_start_rg") == 0 )) ; then #======================================================= : Notify user. #======================================================= roha_session_log "$(dspmsg -s $ROHA_SET $ROHA_MSGS 119 \ "%1\$s: ERROR: %2\$d Processing Unit(s) needed will exceed available resources. %3\$d Processing Unit(s) cannot be satisfied by On/Off CoD nor Enterprise Pool resources.\n" \ "$PROGNAME" "${roha_compute.pu}" "$needed")" #======================================================= : There are not enough free resources. Do not acquire : any. #======================================================= roha_identify.dlpar.pu=0.00 roha_identify.dlpar.vp=0 roha_identify.dlpar.spp_size=${roha_query.lpar.cpu.proc_units.spp_max} roha_identify.codpool.cpu=0 roha_identify.onoff.cpu=0 roha_identify.onoff.cpu_days=0 typeset SYS_NAME="" for SYS_NAME in ${roha_query_codpool_members_names}; do roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]=0.00 roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]=0.00 done rc=$RC_IDENTIFY_CPU_ERROR_RESOURCES else #======================================================= : Check expected processing units towards expected : virtual processor ratio. #======================================================= typeset -F4 total_pu=$((roha_query.lpar.cpu.proc_units.curr + roha_identify.dlpar.pu)) typeset -F4 total_vp=$((roha_query.lpar.cpu.procs.curr + roha_identify.dlpar.vp)) if (( $total_pu <= ${roha_query.cec.cpu.ratio} * $total_vp )) ; then #======================================================= : And, adjust virtual processor quantity if needed. : Round down to have not less than the min ratio #======================================================= (( total_vp = ${total_pu} / ${roha_query.cec.cpu.ratio} )) total_vp=$(print ${total_vp} | awk '{printf "%0.4f\n",int($0)}') (( roha_identify.dlpar.vp = ${total_vp} - ${roha_query.lpar.cpu.procs.curr} )) roha_identify.dlpar.vp=$(max 0 ${roha_identify.dlpar.vp}) fi #======================================================= : Also update the minimal spp size needed #======================================================= (( roha_identify.dlpar.spp_size = ${roha_query.lpar.cpu.proc_units.spp_max} - ${roha_query.lpar.cpu.proc_units.spp_free} + ${roha_identify.dlpar.pu} )) roha_identify.dlpar.spp_size=$(print ${roha_identify.dlpar.spp_size} | awk '{printf "%0.4f\n",int($0+0.9999)}') fi fi return $rc } # End of "roha_identify_shd_cpu_to_acquire()" #============================================================================= # # Name: roha_identify_shd_cpu_to_acquire_report # # Description: Displays computation results. # # Inputs: None # # Outputs: None # # Globals: roha_query # roha_identify # # Returns: None # #============================================================================= function roha_identify_shd_cpu_to_acquire_report { roha_session_log "$(print "========== Identify ROHA Processor ===========")" roha_session_log "$(print "Remaining available PU(s) for partition: \t${roha_query.cec.cpu.free} Processing Unit(s)")" typeset -F4 total_epcod_to_acquire=${roha_identify.codpool.cpu} if [[ -n ${roha_session.other_lpar} ]] ; then roha_session_log "$(print "Total Enterprise Pool CPU(s) to yank normal from" )" roha_session_log "$(print "\t${roha_session.other_cec}: \t${roha_identify.codpool.cpu_to_yank} CPU(s)")" (( total_epcod_to_acquire += ${roha_identify.codpool.cpu_to_yank} )) fi typeset SYS_NAME="" for SYS_NAME in ${roha_query_codpool_members_names}; do if [[ $SYS_NAME == "${roha_query.cec.name}" ]]; then continue fi roha_session_log "$(print "Total Enterprise Pool CPU(s) to yank compliantly from" )" roha_session_log "$(print "\t$SYS_NAME MS: \t${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]:-0.00} CPU(s)")" roha_session_log "$(print "Total Enterprise Pool CPU(s) to yank uncompliantly from" )" roha_session_log "$(print "\t$SYS_NAME MS: \t${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]:-0.00} CPU(s)")" done roha_session_log "$(print "Total Enterprise Pool CPU(s) to acquire including all yanked amounts: \t${total_epcod_to_acquire} CPU(s)")" roha_session_log "$(print "Total On/Off CoD CPU(s) to activate: \t${roha_identify.onoff.cpu} CPU(s) for ${roha_identify.onoff.cpu_days} days")" roha_session_log "$(print "Total DLPAR PU(s)/VP(s) to allocate: \t${roha_identify.dlpar.pu} Processing Unit(s) and ${roha_identify.dlpar.vp} Virtual Processor(s)")" if (( ${roha_compute.pu} != ${roha_identify.dlpar.pu} )) && (( $(roha_session_read_odm_rohaparam "always_start_rg") == 1 )) ; then roha_session_log "$(print "Total DLPAR PU(s)/VP(s) computed to be allocated was ${roha_compute.pu} Processing Unit(s) and ${roha_compute.vp} Virtual Processor(s) but as always_start_rg=1, acquisition is performed at best, rather than failing.")" fi if (( ${roha_identify.dlpar.spp_size} != ${roha_compute.spp_size} )) ; then if (( ${roha_identify.dlpar.spp_size} > ${roha_query.lpar.cpu.proc_units.spp_max} )) ; then roha_session_log "$(print "SPP_SIZE is decreased from computed ${roha_compute.spp_size} to ${roha_identify.dlpar.spp_size} to match the Processing Unit(s) acquisition")" elif (( ${roha_compute.spp_size} > ${roha_query.lpar.cpu.proc_units.spp_max} )) ; then roha_session_log "$(print "SPP_SIZE is decreased from computed ${roha_compute.spp_size} to current ${roha_query.lpar.cpu.proc_units.spp_max} to match the Processing Unit(s) acquisition. SPP_SIZE will not change.")" fi fi roha_session_log "$(print "=================== End =====================\n")" } # End of "roha_identify_shd_cpu_to_acquire_report()" #============================================================================= # # Name: roha_identify_ded_cpu_to_acquire # # Description: Find out how much this LPAR could possibly acquire in terms of # DLPAR, Enterprise Pool, or On/Off CoD. # Consider DLPAR resources. # Consider Enterprise Pool resources (normal, normal yank, yank force). # Consider On/Off CoD resources. # Check if SystemMirror should always start RGs or not. # # Tunable resource_allocation_order modifies the # precedence order between sources of resources. # If resource_allocation_order set to 1 # - Enterprise Pool # - DLPAR # - Enterprise Pool with yank normal/force # If resource_allocation_order set to 2 # - Enterprise Pool # - Enterprise Pool with yank normal/force # - DLPAR # Otherwise, order is # - DLPAR # - Enterprise Pool # - Enterprise Pool with yank normal/force # # Inputs: None # # Outputs: None # # Internal functions: # function roha_identify_epcod_ded_cpu_to_acquire # function roha_identify_epcod_from_previous_active_ded_cpu_to_acquire # function roha_identify_epcod_from_active_ded_cpu_to_acquire # function roha_identify_dlpar_ded_cpu_to_acquire # function roha_identify_onoff_ded_cpu_to_acquire # # Globals: roha_query # roha_compute # roha_identify # # Returns: RC_SUCCESS # RC_IDENTIFY_CPU_ERROR_RESOURCES # #============================================================================= function roha_identify_ded_cpu_to_acquire { #======================================================= # Internal function to consider Enterprise Pool CoD # resources. # Inputs : in/out parameter needed. #======================================================= function roha_identify_epcod_ded_cpu_to_acquire { [[ $VERBOSE_LOGGING == high ]] && set -x typeset -n needed=$1 if (( $needed > 0.00 )) ; then #======================================================= : There are still some needed resources. : Consider Enterprise Pool CoD resources. #======================================================= if [[ ${roha_query.codpool.state} == @("In compliance"|"Approaching")* ]] && (( ${roha_query.cec.cpu.realtime_inactive} > 0.00 )) && (( ${roha_query.codpool.cpu.available} > 0.00 )); then #======================================================= : There are available resources in Enterprise Pool CoD, : take as much as it can, but no more than inactive. #======================================================= roha_identify.codpool.cpu=$(min ${needed} ${roha_query.codpool.cpu.available}) roha_identify.codpool.cpu=$(min ${roha_identify.codpool.cpu} ${roha_query.cec.cpu.realtime_inactive}) #======================================================= : Update DLPAR and needed accordingly : Remove from needed what is going to be EPCoD-acquired #======================================================= (( roha_identify.dlpar.cpu += ${roha_identify.codpool.cpu} )) (( needed -= ${roha_identify.codpool.cpu} )) #======================================================= : Then, always allocate whole amount of Enterprise Pool : CoD resources, rounded up. : Update real inactive accordingly : what is going : to be EPCoD-acquired must be removed from the amount : of inactive. #======================================================= roha_identify.codpool.cpu=$(print ${roha_identify.codpool.cpu} | awk '{printf "%0.4f\n",int($0+0.9999)}') (( roha_query.cec.cpu.realtime_inactive -= ${roha_identify.codpool.cpu} )) fi fi if (( $needed > 0.00 )) ; then #======================================================= : There are still some needed resources. : Consider releasing Enterprise Pool : CoD resources from 'other' managed system only : if using the same pool. : This is the 'normal' yank : we only yank from the : other Managed System if it is down, or if the LPAR is : down, we do not create unreturned resources, we do not : yank more than what was DLPAR allocated on the other : LPAR. #======================================================= if [[ -n ${roha_session.other_lpar} ]] && (( ${roha_query.other_node.codpool.cpu.mobile} > 0.00 )) && [[ ${roha_query.other_node.codpool.name} == ${roha_query.codpool.name} ]] ; then if [[ ${roha_query.other_node.cec.state} != @("Operating"|"Standby") ]] ; then #======================================================= : Source Managed System is down and there are resources : in Enterprise Pool CoD to be yanked. : Take as much as it can. : You cannot take more than the available nor the inactive. #======================================================= roha_identify.codpool.cpu_to_yank=$(min ${needed} ${roha_query.other_node.codpool.cpu.mobile}) roha_identify.codpool.cpu_to_yank=$(min ${roha_identify.codpool.cpu_to_yank} ${roha_query.cec.cpu.realtime_inactive}) elif [[ ${roha_query.other_node.lpar.state} != @("Running") ]] ; then #======================================================= : Source LPAR is down and there are resources in : Enterprise Pool CoD to be yanked. : Take as much as it can. : You cannot take more than the available nor the inactive. : We can take only from the LPAR what would be released by : this LPAR : curr - min. To know if we round up or down, : we use the same method than the one used in the real release. #======================================================= roha_identify.codpool.cpu_to_yank=$(min ${needed} ${roha_query.other_node.codpool.cpu.mobile}) roha_identify.codpool.cpu_to_yank=$(min ${roha_identify.codpool.cpu_to_yank} ${roha_query.cec.cpu.realtime_inactive}) typeset -F4 other_node_roha if [[ ${roha_query.other_node.lpar.cpu.proc_mode} == "shared" ]] ; then (( other_node_roha = ${roha_query.other_node.lpar.cpu.proc_units.curr} - ${roha_query.other_node.lpar.cpu.proc_units.min} )) typeset -F4 other_node_roha_up=$(print ${other_node_roha} | awk '{printf "%0.4f\n",int($0+0.9999)}') typeset -F4 other_node_roha_down=$(print ${other_node_roha} | awk '{printf "%0.4f\n",int($0)}') if (( ${roha_query.other_node.cec.cpu.available} + ${other_node_roha} >= ${other_node_roha_up} )) ; then other_node_roha=$other_node_roha_up else other_node_roha=$other_node_roha_down fi else (( other_node_roha = ${roha_query.other_node.lpar.cpu.procs.curr} - ${roha_query.other_node.lpar.cpu.procs.min} )) fi roha_identify.codpool.cpu_to_yank=$(min ${roha_identify.codpool.cpu_to_yank} ${other_node_roha} ) #======================================================= : Because of EPCoD unreturned limit, we cannot yank : uncompliantly more than the pool capacity. So that the : yank cannot exceed the other_node available resource : for the compliant part, and the difference between the : EPCoD capacity and the EPCoD unreturned for the uncompliant : part. #======================================================= roha_identify.codpool.cpu_to_yank=$(min ${roha_identify.codpool.cpu_to_yank} ${roha_query_codpool_members["${roha_query.other_node.cec.name}" "realtime_curr_avail_sys_proc_units"]}+${roha_query.codpool.cpu.capacity}-${roha_query.codpool.cpu.realtime_unreturned}) else roha_identify.codpool.cpu_to_yank=0.00 fi #======================================================= : Update DLPAR and needed accordingly : Remove from needed what is going to be EPCoD-yanked #======================================================= (( roha_identify.dlpar.cpu += ${roha_identify.codpool.cpu_to_yank} )) (( needed -= ${roha_identify.codpool.cpu_to_yank} )) #======================================================= : Then, always yank whole amount of Enterprise Pool : CoD resources, rounded up. : Update real inactive accordingly : what is going : to be EPCoD-yanked must be removed from the amount : of inactive. #======================================================= roha_identify.codpool.cpu_to_yank=$(print ${roha_identify.codpool.cpu_to_yank} | awk '{printf "%0.4f\n",int($0+0.9999)}') (( roha_query.cec.cpu.realtime_inactive -= ${roha_identify.codpool.cpu_to_yank} )) #======================================================= : Update : realtime pool unreturned : realtime other_cec available #======================================================= (( roha_query.codpool.cpu.realtime_unreturned += $(max 0.00 ${roha_identify.codpool.cpu_to_yank}-${roha_query_codpool_members["${roha_query.other_node.cec.name}" "realtime_curr_avail_sys_proc_units"]}) )) roha_query_codpool_members["${roha_query.other_node.cec.name}" "realtime_curr_avail_sys_proc_units"]=$(max 0.00 ${roha_query_codpool_members["${roha_query.other_node.cec.name}" "realtime_curr_avail_sys_proc_units"]}-${roha_identify.codpool.cpu_to_yank} ) #======================================================= : What is going to be EPCoD-yanked here cannot be : EPCoD-yanked force. So remove it from the amount of : mobile resources available on this other cec. #======================================================= (( roha_query_codpool_members["${roha_session.other_cec}" "sys_mobile_procs"] -= ${roha_identify.codpool.cpu_to_yank} )) fi fi } # End of "roha_identify_epcod_ded_cpu_to_acquire()" #======================================================= # Internal function to consider DLPAR resources. # Inputs : in/out parameter needed #======================================================= function roha_identify_dlpar_ded_cpu_to_acquire { [[ $VERBOSE_LOGGING == high ]] && set -x typeset -n needed=$1 typeset -F4 freepool_to_get=0.00 if (( $needed > 0.00 )) ; then #======================================================= : There are still some needed resources. : Consider DLPAR resources. Take as : much as it can to fulfill the required. #======================================================= freepool_to_get=$(min ${needed} ${roha_query.cec.cpu.free}) #======================================================= : Then, always acquire whole amount of DLPAR processors, : rounded down. #======================================================= freepool_to_get=$(print ${freepool_to_get} | awk '{printf "%0.4f\n",int($0)}') fi #======================================================= : Update DLPAR and needed accordingly #======================================================= (( roha_identify.dlpar.cpu += ${freepool_to_get} )) (( needed -= ${freepool_to_get} )) } # End of "roha_identify_dlpar_ded_cpu_to_acquire()" #======================================================= # Internal function to consider Enterprise Pool CoD # resources from Previous Hosting Managed Systems. # Inputs : in/out parameter needed #======================================================= function roha_identify_epcod_from_previous_active_ded_cpu_to_acquire { [[ $VERBOSE_LOGGING == high ]] && set -x typeset -n needed=$1 typeset SYS_NAME="${roha_query.other_node.cec.name}" if (( $needed > 0.00 )) && [[ -n $SYS_NAME && $SYS_NAME != "${roha_query.cec.name}" ]]; then #======================================================= : There are still some needed resources. : Consider releasing Enterprise Pool : CoD resources from Previous hosting managed systems : using the same Enterprise Pool. : Go through and compute what can be got from : this managed system : without creating unreturned : with creating unreturned #======================================================= #=================================================================== : Search for Enterprise Pool resources, without creating unreturned. #=================================================================== roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]=0.00 #======================================================= : This is on $SYS_NAME Managed System #======================================================= if (( $needed > 0.00 )); then #======================================================= : How many procs can be got from $SYS_NAME MS without : creating unreturned. #======================================================= if (( ${roha_query_codpool_members["$SYS_NAME" "sys_unreturned_mobile_procs"]} == 0.00 )); then #======================================================= : Check available amounts on CEC only in case of CEC up : because unreturned are not generated on a down CEC #======================================================= if [[ ${roha_query_codpool_members["$SYS_NAME" "state"]} == @("Operating"|"Standby") ]] ; then roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]=$(min ${roha_query_codpool_members["$SYS_NAME" "sys_mobile_procs"]} ${roha_query_codpool_members["$SYS_NAME" "curr_avail_sys_proc_units"]} ) else roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]=${roha_query_codpool_members["$SYS_NAME" "sys_mobile_procs"]} fi #======================================================= : Only whole amounts can be yanked compliantly : rounded down #======================================================= roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]=$(print ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} | awk '{printf "%0.4f\n",int($0)}') #======================================================= : Then limit amount to what is really needed : and what can really be acquired #======================================================= roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]=$(min ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} ${needed}) roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]=$(min ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} ${roha_query.cec.cpu.realtime_inactive} ) #======================================================= : Update DLPAR accordingly #======================================================= (( roha_identify.dlpar.cpu += ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} )) #======================================================= : Decrease accordingly the amount still needed #======================================================= (( needed -= ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} )) #======================================================= : Then, always yank whole amount of Enterprise Pool : CoD resources, rounded up. #======================================================= roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]=$(print ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} | awk '{printf "%0.4f\n",int($0+0.9999)}') #======================================================= : Update real inactive accordingly : what is going : to be EPCoD-yanked compliantly must be removed : from the amount of inactive. : Also update realtime available on yanked CEC if up #======================================================= (( roha_query.cec.cpu.realtime_inactive -= ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} )) if [[ ${roha_query_codpool_members["$SYS_NAME" "state"]} == @("Operating"|"Standby") ]] ; then (( roha_query_codpool_members["$SYS_NAME" "realtime_curr_avail_sys_proc_units"] -= ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} )) fi #=================================================== : Update codpool cpu to acquire accordingly #=================================================== (( roha_identify.codpool.cpu += ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} )) else #======================================================= : Nothing to be done, as there is already some unreturned : on this CEC #======================================================= fi fi #=================================================================== : Search for Enterprise Pool resources, without creating unreturned. #=================================================================== roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]=0.00 #======================================================= : This is on $SYS_NAME Managed System #======================================================= if (( $needed > 0.00 )); then #======================================================= : How many procs can be got from $SYS_NAME MS even : with creating unreturned #======================================================= #======================================================= roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]=${roha_query_codpool_members["$SYS_NAME" "sys_mobile_procs"]} (( roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME] -= ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} )) roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]=$(min ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} ${needed}) roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]=$(min ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} ${roha_query.cec.cpu.realtime_inactive} ) roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]=$(min ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} ${roha_query.codpool.cpu.capacity}-${roha_query.codpool.cpu.realtime_unreturned}) #======================================================= : Update DLPAR accordingly #======================================================= (( roha_identify.dlpar.cpu += ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} )) #======================================================= : Decrease accordingly the amount still needed #======================================================= (( needed -= ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} )) #======================================================= : Then, always yank whole amount of Enterprise Pool : CoD resources, rounded up. #======================================================= roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]=$(print ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} | awk '{printf "%0.4f\n",int($0+0.9999)}') #======================================================= : Update real inactive accordingly : what is going : to be EPCoD-yanked uncompliantly must be removed : from the amount of inactive. : Also update total amount of pool unreturned #======================================================= (( roha_query.cec.cpu.realtime_inactive -= ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} )) (( roha_query.codpool.cpu.realtime_unreturned += ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} )) #=================================================== : Update codpool cpu to acquire accordingly #=================================================== (( roha_identify.codpool.cpu += ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} )) fi fi } # End of "roha_identify_epcod_from_previous_active_ded_cpu_to_acquire" #======================================================= # Internal function to consider Enterprise Pool CoD # resources from Active Managed Systems. # Inputs : in/out parameter needed #======================================================= function roha_identify_epcod_from_active_ded_cpu_to_acquire { [[ $VERBOSE_LOGGING == high ]] && set -x typeset -n needed=$1 if (( $needed > 0.00 )) ; then #======================================================= : There are still some needed resources. : Consider releasing Enterprise Pool : CoD resources from active managed systems using : the same Enterprise Pool. : Go through all managed systems sharing this : Enterprise Pool and compute what can be got from : this managed system : without creating unreturned : with creating unreturned #======================================================= #======================================================= : Loop around Managed Systems to search for Enterprise Pool : resources, without creating unreturned. #======================================================= typeset SYS_NAME="" for SYS_NAME in ${roha_query_codpool_members_names}; do #======================================================= # Resources from previous active are already considered #======================================================= if [[ $SYS_NAME == "${roha_query.other_node.cec.name}" ]]; then continue fi roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]=0.00 if [[ $SYS_NAME == "${roha_query.cec.name}" ]]; then continue fi #======================================================= : This loop is on $SYS_NAME Managed System #======================================================= if (( $needed > 0.00 )); then #======================================================= : How many procs can be got from $SYS_NAME MS without : creating unreturned. #======================================================= if (( ${roha_query_codpool_members["$SYS_NAME" "sys_unreturned_mobile_procs"]} == 0.00 )); then #======================================================= : Check available amounts on CEC only in case of CEC up : because unreturned are not generated on a down CEC #======================================================= if [[ ${roha_query_codpool_members["$SYS_NAME" "state"]} == @("Operating"|"Standby") ]] ; then roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]=$(min ${roha_query_codpool_members["$SYS_NAME" "sys_mobile_procs"]} ${roha_query_codpool_members["$SYS_NAME" "curr_avail_sys_proc_units"]} ) else roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]=${roha_query_codpool_members["$SYS_NAME" "sys_mobile_procs"]} fi #======================================================= : Only whole amounts can be yanked compliantly : rounded down #======================================================= roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]=$(print ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} | awk '{printf "%0.4f\n",int($0)}') #======================================================= : Then limit amount to what is really needed : and what can really be acquired #======================================================= roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]=$(min ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} ${needed}) roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]=$(min ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} ${roha_query.cec.cpu.realtime_inactive} ) #======================================================= : Update DLPAR accordingly #======================================================= (( roha_identify.dlpar.cpu += ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} )) #======================================================= : Decrease accordingly the amount still needed #======================================================= (( needed -= ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} )) #======================================================= : Then, always yank whole amount of Enterprise Pool : CoD resources, rounded up. #======================================================= roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]=$(print ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} | awk '{printf "%0.4f\n",int($0+0.9999)}') #======================================================= : Update real inactive accordingly : what is going : to be EPCoD-yanked compliantly must be removed : from the amount of inactive. : Also update realtime available on yanked CEC if up #======================================================= (( roha_query.cec.cpu.realtime_inactive -= ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} )) if [[ ${roha_query_codpool_members["$SYS_NAME" "state"]} == @("Operating"|"Standby") ]] ; then (( roha_query_codpool_members["$SYS_NAME" "realtime_curr_avail_sys_proc_units"] -= ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} )) fi #=================================================== : Update codpool cpu to acquire accordingly #=================================================== (( roha_identify.codpool.cpu += ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} )) else #======================================================= : Nothing to be done, as there is already some unreturned : on this CEC #======================================================= fi fi done #======================================================= : Loop around Managed Systems to search for Enterprise Pool : resources, even with creating unreturned. #======================================================= for SYS_NAME in ${roha_query_codpool_members_names}; do #======================================================= # Resources from previous active are already considered #======================================================= if [[ $SYS_NAME == "${roha_query.other_node.cec.name}" ]]; then continue fi roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]=0.00 if [[ $SYS_NAME == "${roha_query.cec.name}" ]] || [[ ${roha_query_codpool_members["$SYS_NAME" "state"]} != @("Operating"|"Standby") ]]; then continue fi #======================================================= : This loop is on $SYS_NAME Managed System #======================================================= if (( $needed > 0.00 )); then #======================================================= : How many procs can be got from $SYS_NAME MS even : with creating unreturned #======================================================= #======================================================= roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]=${roha_query_codpool_members["$SYS_NAME" "sys_mobile_procs"]} (( roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME] -= ${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]} )) roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]=$(min ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} ${needed}) roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]=$(min ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} ${roha_query.cec.cpu.realtime_inactive} ) roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]=$(min ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} ${roha_query.codpool.cpu.capacity}-${roha_query.codpool.cpu.realtime_unreturned}) #======================================================= : Update DLPAR accordingly #======================================================= (( roha_identify.dlpar.cpu += ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} )) #======================================================= : Decrease accordingly the amount still needed #======================================================= (( needed -= ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} )) #======================================================= : Then, always yank whole amount of Enterprise Pool : CoD resources, rounded up. #======================================================= roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]=$(print ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} | awk '{printf "%0.4f\n",int($0+0.9999)}') #======================================================= : Update real inactive accordingly : what is going : to be EPCoD-yanked uncompliantly must be removed : from the amount of inactive. : Also update total amount of pool unreturned #======================================================= (( roha_query.cec.cpu.realtime_inactive -= ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} )) (( roha_query.codpool.cpu.realtime_unreturned += ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} )) #=================================================== : Update codpool cpu to acquire accordingly #=================================================== (( roha_identify.codpool.cpu += ${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]} )) fi done fi } # End of "roha_identify_epcod_from_active_ded_cpu_to_acquire" #========================================================= # Internal function to consider On/Off Cod resources. # Inputs : in/out parameter needed #========================================================= function roha_identify_onoff_ded_cpu_to_acquire { [[ $VERBOSE_LOGGING == high ]] && set -x typeset -n needed=$1 if (( $needed > 0.00 )) ; then #======================================================= : There are still some needed resources. : Consider On/Off CoD resources. #======================================================= if (( $(roha_session_read_odm_rohaparam "agree_to_cod_costs") == 1 )) && [[ ${roha_query.onoff.cpu.state} == @("Available"|"Running"|"Unreturned") ]] && (( ${roha_query.cec.cpu.realtime_inactive} > 0.00 )) ; then #======================================================= : There are available On/Off CoD resources. Take as much : as it can. #======================================================= roha_identify.onoff.cpu=$(min ${needed} ${roha_query.cec.cpu.realtime_inactive}) roha_identify.onoff.cpu=$(min ${roha_identify.onoff.cpu} ${roha_query.onoff.cpu.days_avail}+${roha_query.onoff.cpu.days_left}-${roha_query.onoff.cpu.activated}-${roha_query.onoff.cpu.unreturned} ) #======================================================= : Update DLPAR and needed accordingly. #======================================================= (( roha_identify.dlpar.cpu += ${roha_identify.onoff.cpu} )) (( needed -= ${roha_identify.onoff.cpu} )) #======================================================= : Then, always activate whole amount of On/Off CoD : resources, rounded up. #======================================================= roha_identify.onoff.cpu=$(print ${roha_identify.onoff.cpu} | awk '{printf "%0.4f\n",int($0+0.9999)}') #======================================================= : Compute number of days in the request. It may modify : the amount of resources requested if always start rg. #======================================================= roha_identify_onoff_days "roha_identify.onoff.cpu" "roha_identify.onoff.cpu_days" "${roha_query.onoff.cpu.days_avail}" "${roha_query.onoff.cpu.days_left}" #======================================================= : Update realtime inactive accordingly. #======================================================= (( roha_query.cec.cpu.realtime_inactive -= $(min ${roha_identify.onoff.cpu} ${needed}) )) fi fi } # End of "roha_identify_onoff_ded_cpu_to_acquire()" [[ $VERBOSE_LOGGING == high ]] && set -x typeset -i rc=$RC_SUCCESS typeset -F4 needed=0.00 typeset -i balance_epcod_unreturned=0 # initialization roha_identify.dlpar.cpu=0 (( needed = ${roha_compute.cpu} )) if (( $(roha_session_read_odm_rohaparam "resource_allocation_order") == 1 )); then #================================================================== : Before trying to get Enterprise Pool, if ever there are : unreturned resources then they must be added to the amount : of resources necessary to get. #================================================================== if (( $needed > 0.00 )); then (( balance_epcod_unreturned = 1 )) (( needed += ${roha_query.codpool.cpu.unreturned})) fi # first epcod normal roha_identify_epcod_ded_cpu_to_acquire needed # get previous active CEC resources either compliantly or uncompliantly roha_identify_epcod_from_previous_active_ded_cpu_to_acquire needed # get Freepool resources roha_identify_dlpar_ded_cpu_to_acquire needed # get other active CEC resources either compliantly or uncompliantly roha_identify_epcod_from_active_ded_cpu_to_acquire needed elif (( $(roha_session_read_odm_rohaparam "resource_allocation_order") == 2 )); then #================================================================== : Before trying to get Enterprise Pool, if ever there are : unreturned resources then they must be added to the amount : of resources necessary to get. #================================================================== if (( $needed > 0.00 )); then (( balance_epcod_unreturned = 1 )) (( needed += ${roha_query.codpool.cpu.unreturned})) fi # first epcod normal roha_identify_epcod_ded_cpu_to_acquire needed # get previous active CEC resources either compliantly or uncompliantly roha_identify_epcod_from_previous_active_ded_cpu_to_acquire needed # get other active CEC resources either compliantly or uncompliantly roha_identify_epcod_from_active_ded_cpu_to_acquire needed # get Freepool resources roha_identify_dlpar_ded_cpu_to_acquire needed else # first dlpar roha_identify_dlpar_ded_cpu_to_acquire needed #================================================================== : Before trying to get Enterprise Pool, if ever there are : unreturned resources then they must be added to the amount : of resources necessary to get. #================================================================== if (( $needed > 0.00 )); then (( balance_epcod_unreturned = 1 )) (( needed += ${roha_query.codpool.cpu.unreturned} )) fi # then epcod normal, then epcod yank roha_identify_epcod_ded_cpu_to_acquire needed # get previous active CEC resources either compliantly or uncompliantly roha_identify_epcod_from_previous_active_ded_cpu_to_acquire needed # then epcod yank force roha_identify_epcod_from_active_ded_cpu_to_acquire needed fi # then onoff roha_identify_onoff_ded_cpu_to_acquire needed #==================================================================== : If Enterprise Pool unreturned resources were considered, they were not : acquired for the LPAR, so remove them. Also we cannot acquire : less than 0. #==================================================================== if (( $balance_epcod_unreturned == 1 )); then (( roha_identify.dlpar.cpu -= ${roha_query.codpool.cpu.unreturned} )) roha_identify.dlpar.cpu=$(max ${roha_identify.dlpar.cpu} 0.00) fi if (( $needed > 0.00 )) ; then #======================================================= : There are still some needed resources. : Check if SystemMirror should always : start RGs or not. #======================================================= if (( $(roha_session_read_odm_rohaparam "always_start_rg") == 0 )) ; then #======================================================= : Notify user. #======================================================= roha_session_log "$(dspmsg -s $ROHA_SET $ROHA_MSGS 118 \ "%1\$s: ERROR: %2\$d CPU(s) needed will exceed available resources. %3\$d CPU(s) cannot be satisfied by On/Off CoD nor Enterprise Pool resources.\n" \ "$PROGNAME" "${roha_compute.cpu}" "$needed")" #======================================================= : There are not enough free resources. Do not acquire : any. #======================================================= roha_identify.dlpar.cpu=0 roha_identify.codpool.cpu=0 roha_identify.onoff.cpu=0 roha_identify.onoff.cpu_days=0 typeset SYS_NAME="" for SYS_NAME in ${roha_query_codpool_members_names}; do roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]=0.00 roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]=0.00 done rc=$RC_IDENTIFY_CPU_ERROR_RESOURCES fi fi return $rc } # End of "roha_identify_ded_cpu_to_acquire()" #============================================================================= # # Name: roha_identify_ded_cpu_to_acquire_report # # Description: Displays computation results. # # Inputs: None # # Outputs: None # # Globals: roha_query # roha_identify # # Returns: None # #============================================================================= function roha_identify_ded_cpu_to_acquire_report { roha_session_log "$(print "========== Identify ROHA Processor ==========")" roha_session_log "$(print "Remaining available PU(s) for partition: \t${roha_query.cec.cpu.free} Processing Unit(s)")" typeset -F4 total_epcod_to_acquire=${roha_identify.codpool.cpu} if [[ -n ${roha_session.other_lpar} ]] ; then roha_session_log "$(print "Total Enterprise Pool CPU(s) to yank normal from" )" roha_session_log "$(print "\t${roha_session.other_cec}: \t${roha_identify.codpool.cpu_to_yank} CPU(s)")" (( total_epcod_to_acquire += ${roha_identify.codpool.cpu_to_yank} )) fi typeset SYS_NAME="" for SYS_NAME in ${roha_query_codpool_members_names}; do if [[ $SYS_NAME == ${roha_query.cec.name} ]]; then continue fi roha_session_log "$(print "Total Enterprise Pool CPU(s) to yank compliantly from" )" roha_session_log "$(print "\t $SYS_NAME MS: \t${roha_identify.codpool.cpu_to_yank_compliant[$SYS_NAME]}:-0.00 CPU(s)")" roha_session_log "$(print "Total Enterprise Pool CPU(s) to yank uncompliantly from" )" roha_session_log "$(print "\t $SYS_NAME MS: \t${roha_identify.codpool.cpu_to_yank_uncompliant[$SYS_NAME]}:-0.00 CPU(s)")" done roha_session_log "$(print "Total Enterprise Pool CPU(s) to acquire including all yanked amounts: \t${total_epcod_to_acquire} CPU(s)")" roha_session_log "$(print "Total On/Off CoD CPU(s) to activate: \t${roha_identify.onoff.cpu} CPU(s) for ${roha_identify.onoff.cpu_days} days")" roha_session_log "$(print "Total DLPAR CPU(s) to allocate: \t${roha_identify.dlpar.cpu} CPU(s)")" if (( ${roha_compute.cpu} != ${roha_identify.dlpar.cpu} )) && (( $(roha_session_read_odm_rohaparam "always_start_rg") == 1 )) ; then roha_session_log "$(print "Total DLPAR CPU(s) computed to be allocated was ${roha_compute.cpu}, but as always_start_rg=1, acquisition is performed at best, rather than failing.")" fi roha_session_log "$(print "=================== End =====================\n")" } # End of "roha_identify_ded_cpu_to_acquire_report()" #============================================================================= # # Name: roha_identify_shd_cpu_to_release # # Description: Find out how much this LPAR could possibly release in terms of # On/Off or Enterprise Pool CoD. First, consider On/Off CoD # resources. Then, consider Enterprise Pool CoD. # # Inputs: None # # Outputs: None # # Globals: roha_query # roha_compute # roha_identify # # Returns: RC_SUCCESS # #============================================================================= function roha_identify_shd_cpu_to_release { [[ $VERBOSE_LOGGING == high ]] && set -x # Total to be released for this LPAR, for the DLPAR release. # This was computed by taking into account what workload # remains to be run on this LPAR, and taking into account # as a base level, either the 'min' level of the LPAR, or the # 'desired' level of the LPAR, depending on type of ROHA # configuration set on Application Controllers (if there # are any 'use_desired' ROHA or not). typeset -F4 to_release=0.00 # This is computed by taking into account what is free at the CEC level # and this amount evolves to store what remains to be released # on Enterprise Pool after release of On/Off CoD. typeset -F4 temp_to_release=0.00 (( to_release = ${roha_compute.pu} )) (( temp_to_release = ${to_release} )) #======================================================= : Find out how much this LPAR could possibly release in : terms of On/Off CoD or Enterprise Pool CoD or DLPAR. : First, try to release them back from On/Off CoD. #======================================================= if (( $temp_to_release > 0.00 && $(roha_session_read_odm_rohaparam "agree_to_cod_costs") == 1 )) ; then typeset -F4 odm_onoff_cpu=$(roha_session_read_odm_dynresop "ONOFF_CPU") if (( ${roha_query.onoff.cpu.activated} >= 0.00 )) ; then #======================================================= : There were some On/Off CoD activated. : Do not release more than what needs to be : released, no more than the amount activated, : and no more than the value stored in ODM. : Always release whole amount of On/Off CoD resources. : Either rounded up or down depending on : what has to be released and what is available. #======================================================= roha_identify.onoff.cpu=$(min ${temp_to_release} ${roha_query.onoff.cpu.activated}) roha_identify.onoff.cpu=$(min ${roha_identify.onoff.cpu} $odm_onoff_cpu) typeset -F4 round_up=$(print ${roha_identify.onoff.cpu} | awk '{printf "%0.4f\n",int($0+0.9999)}') typeset -F4 round_down=$(print ${roha_identify.onoff.cpu} | awk '{printf "%0.4f\n",int($0)}') if (( ${roha_query.cec.cpu.available} + ${roha_identify.onoff.cpu} >= $round_up )) ; then roha_identify.onoff.cpu=$round_up else roha_identify.onoff.cpu=$round_down fi #=========================================================================================== : Reset the resource value in ODM if there are no OnOff COD CPU resources to be released. #=========================================================================================== if (( ${roha_identify.onoff.cpu} == 0.00 && $odm_onoff_cpu > 0.00 )) ; then roha_session_write_odm_dynresop ONOFF_CPU 0 fi #======================================================= : What remains to be released is what has not been : de-activated on On/Off CoD. #======================================================= (( temp_to_release -= ${roha_identify.onoff.cpu} )) fi fi #======================================================= : If there are still some resources to be released : and we are not in async, try to release them back from : the Enterprise Pool CoD. #======================================================= rel_apps=$(ODMDIR=/etc/es/objrepos clodmget -q "key=REL_APPS" -nf value HACMPdynresop 2>/dev/null) if (( $temp_to_release > 0.00 )) && [[ -z ${rel_apps} ]] ; then typeset -F4 odm_codpool_cpu=$(roha_session_read_odm_dynresop "CODPOOL_CPU") if (( ${roha_query.codpool.cpu.mobile} >= 0.00 )) ; then #======================================================= : There were some Enterprise Pool acquired. : Do not release more than what needs to be released, : no more than the amount acquired, : and no more than the value stored in ODM. : Always release whole amount of Enterprise Pool resources. : Either rounded up or down depending on what has to be : released and what is available. #======================================================= roha_identify.codpool.cpu=$(min ${temp_to_release} ${roha_query.codpool.cpu.mobile}) roha_identify.codpool.cpu=$(min ${roha_identify.codpool.cpu} $odm_codpool_cpu) typeset -F4 round_up=$(print ${roha_identify.codpool.cpu} | awk '{printf "%0.4f\n",int($0+0.9999)}') typeset -F4 round_down=$(print ${roha_identify.codpool.cpu} | awk '{printf "%0.4f\n",int($0)}') if (( ${roha_query.cec.cpu.available} + ${roha_identify.codpool.cpu} >= $round_up )) ; then roha_identify.codpool.cpu=$round_up else roha_identify.codpool.cpu=$round_down fi #=========================================================================================== : Reset the resource value in ODM if there are no EPCOD CPU resources to be released. #=========================================================================================== if (( ${roha_identify.codpool.cpu} == 0.00 && $odm_codpool_cpu > 0.00 )) ; then roha_session_write_odm_dynresop CODPOOL_CPU 0 fi fi fi #========================================================================= : Reduce unreturned from identified codpool #========================================================================= if (( ${roha_identify.codpool.cpu} > 0.00 )) && (( ${roha_query.codpool.cpu.unreturned} > 0.00 )) ; then (( roha_identify.codpool.cpu=${roha_identify.codpool.cpu} - ${roha_query.codpool.cpu.unreturned} )) if (( ${roha_identify.codpool.cpu} < 0.00 )) ; then roha_identify.codpool.cpu=0 fi fi #========================================================================= : Finally, dlpar to be relased is what was computed to be released at : LPAR level #========================================================================= roha_identify.dlpar.pu=${to_release} roha_identify.dlpar.vp=${roha_compute.vp} return $RC_SUCCESS } # End of "roha_identify_shd_cpu_to_release()" #============================================================================= # # Name: roha_identify_shd_cpu_to_release_report # # Description: Displays computation results. # # Inputs: None # # Outputs: None # # Globals: roha_identify # # Returns: None # #============================================================================= function roha_identify_shd_cpu_to_release_report { roha_session_log "$(print "=========== Identify ROHA Processor =========")" roha_session_log "$(print "Total Enterprise Pool CPU(s) to return back: \t${roha_identify.codpool.cpu} CPU(s)")" roha_session_log "$(print "Total On/Off CoD CPU(s) to de-activate: \t${roha_identify.onoff.cpu} CPU(s)")" roha_session_log "$(print "Total DLPAR PU(s)/VP(s) to release: \t${roha_identify.dlpar.vp} Virtual Processor(s) and ${roha_identify.dlpar.pu} Processing Unit(s)")" roha_session_log "$(print "=================== End =====================\n")" } # End of "roha_identify_shd_cpu_to_release_report()" #============================================================================= # # Name: roha_identify_ded_cpu_to_release # # Description: Find out how much this LPAR could possibly release in terms of # On/Off or Enterprise Pool CoD. First, consider On/Off CoD # resources. Then, consider Enterprise Pool CoD. # # Inputs: None # # Outputs: None # # Globals: roha_compute # roha_identify # # Returns: RC_SUCCESS # #============================================================================= function roha_identify_ded_cpu_to_release { [[ $VERBOSE_LOGGING == high ]] && set -x # Total to be released for this LPAR, for the DLPAR release. # This was computed by taking into account what workload # remains to be run on this LPAR, and taking into account # as a base level, either the 'min' level of the LPAR, or the # 'desired' level of the LPAR, depending on type of ROHA # configuration set on Application Controllers (if there # are any 'use_desired' ROHA or not). typeset -F4 to_release=0.00 # This is computed by taking into account what is free at the CEC level # and this amount evolves to store what remains to be released # on Enterprise Pool after release of On/Off CoD. typeset -F4 temp_to_release=0.00 (( to_release = ${roha_compute.cpu} )) (( temp_to_release = ${to_release} )) #======================================================= : Find out how much this LPAR could possibly release in : terms of On/Off CoD or Enterprise Pool CoD or DLPAR. : First, try to release them back from On/Off CoD. #======================================================= if (( $temp_to_release > 0.00 && $(roha_session_read_odm_rohaparam "agree_to_cod_costs") == 1 )) ; then typeset -F4 odm_onoff_cpu=$(roha_session_read_odm_dynresop "ONOFF_CPU") if (( ${roha_query.onoff.cpu.activated} >= 0.00 )) ; then #======================================================= : There were some On/Off CoD activated. : Do not release more than what needs to be : released, no more than the amount activated, : and no more than the value stored in ODM. : Always release whole amount of On/Off CoD resources. : Either rounded up or down depending on : what has to be released and what is available. #======================================================= roha_identify.onoff.cpu=$(min ${temp_to_release} ${roha_query.onoff.cpu.activated}) roha_identify.onoff.cpu=$(min ${roha_identify.onoff.cpu} $odm_onoff_cpu) typeset -F4 round_up=$(print ${roha_identify.onoff.cpu} | awk '{printf "%0.4f\n",int($0+0.9999)}') typeset -F4 round_down=$(print ${roha_identify.onoff.cpu} | awk '{printf "%0.4f\n",int($0)}') if (( ${roha_query.cec.cpu.available} + ${roha_identify.onoff.cpu} >= $round_up )) ; then roha_identify.onoff.cpu=$round_up else roha_identify.onoff.cpu=$round_down fi #=========================================================================================== : Reset the resource value in ODM if there are no OnOff COD CPU resources to be released. #=========================================================================================== if (( ${roha_identify.onoff.cpu} == 0.00 && $odm_onoff_cpu > 0.00 )) ; then roha_session_write_odm_dynresop ONOFF_CPU 0 fi #======================================================= : What remains to be released is what has not been : de-activated on On/Off CoD. #======================================================= (( temp_to_release -= ${roha_identify.onoff.cpu} )) fi fi #======================================================= : If there are still some resources to be released : and we are not in async, try to release them back from : the Enterprise Pool CoD. #======================================================= rel_apps=$(ODMDIR=/etc/es/objrepos clodmget -q "key=REL_APPS" -nf value HACMPdynresop 2>/dev/null) if (( $temp_to_release > 0.00 )) && [[ -z ${rel_apps} ]] ; then typeset -F4 odm_codpool_cpu=$(roha_session_read_odm_dynresop "CODPOOL_CPU") if (( ${roha_query.codpool.cpu.mobile} >= 0.00 )) ; then #======================================================= : There were some Enterprise Pool acquired. : Do not release more than what needs to be released, : no more than the amount acquired, : and no more than the value stored in ODM. : Always release whole amount of Enterprise Pool resources. : Either rounded up or down depending on what has to be : released and what is available. #======================================================= roha_identify.codpool.cpu=$(min ${temp_to_release} ${roha_query.codpool.cpu.mobile}) roha_identify.codpool.cpu=$(min ${roha_identify.codpool.cpu} $odm_codpool_cpu) typeset -F4 round_up=$(print ${roha_identify.codpool.cpu} | awk '{printf "%0.4f\n",int($0+0.9999)}') typeset -F4 round_down=$(print ${roha_identify.codpool.cpu} | awk '{printf "%0.4f\n",int($0)}') if (( ${roha_query.cec.cpu.available} + ${roha_identify.codpool.cpu} >= $round_up )) ; then roha_identify.codpool.cpu=$round_up else roha_identify.codpool.cpu=$round_down fi #=========================================================================================== : Reset the resource value in ODM if there are no EPCOD CPU resources to be released. #=========================================================================================== if (( ${roha_identify.codpool.cpu} == 0.00 && $odm_codpool_cpu > 0.00 )) ; then roha_session_write_odm_dynresop CODPOOL_CPU 0 fi fi fi #========================================================================= : Reduce unreturned from identified codpool #========================================================================= if (( ${roha_identify.codpool.cpu} > 0.00 )) && (( ${roha_query.codpool.cpu.unreturned} > 0.00 )) ; then (( roha_identify.codpool.cpu=${roha_identify.codpool.cpu} - ${roha_query.codpool.cpu.unreturned} )) if (( ${roha_identify.codpool.cpu} < 0.00 )) ; then roha_identify.codpool.cpu=0 fi fi #========================================================================= : Finally, dlpar to be relased is what was computed to be released at : LPAR level #========================================================================= (( roha_identify.dlpar.cpu = ${to_release} )) return $RC_SUCCESS } # End of "roha_identify_ded_cpu_to_release()" #============================================================================= # # Name: roha_identify_ded_cpu_to_release_report # # Description: Displays computation results. # # Inputs: None # # Outputs: None # # Globals: roha_identify # # Returns: None # #============================================================================= function roha_identify_ded_cpu_to_release_report { roha_session_log "$(print "========== Identify ROHA Processor ==========")" roha_session_log "$(print "Total Enterprise Pool CPU(s) to return back: \t${roha_identify.codpool.cpu} CPU(s)")" roha_session_log "$(print "Total On/Off CoD CPU(s) to de-activate: \t${roha_identify.onoff.cpu} CPU(s)")" roha_session_log "$(print "Total DLPAR CPU(s) to release: \t${roha_identify.dlpar.cpu} CPU(s)")" roha_session_log "$(print "=================== End =====================\n")" } # End of "roha_identify_ded_cpu_to_release_report()"