Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Step:FrontRunner
pacemaker.21298
bsc#1175557-0002-Refactor-extra-use-4-space-ind...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File bsc#1175557-0002-Refactor-extra-use-4-space-indents-in-resource-agent.patch of Package pacemaker.21298
From 7ada60cc2ab542d00da5d52c78abca969deb9aba Mon Sep 17 00:00:00 2001 From: Ken Gaillot <kgaillot@redhat.com> Date: Tue, 16 Jul 2019 16:48:14 -0500 Subject: [PATCH 2/6] Refactor: extra: use 4-space indents in resource agent code They previously used a mix of spaces and tabs that was difficult to edit. --- extra/resources/ClusterMon.in | 146 +++++++++++----------- extra/resources/HealthCPU | 117 +++++++++--------- extra/resources/HealthSMART.in | 142 ++++++++++----------- extra/resources/Stateful | 98 +++++++-------- extra/resources/SysInfo.in | 218 ++++++++++++++++----------------- extra/resources/SystemHealth | 144 +++++++++++----------- extra/resources/o2cb.in | 150 +++++++++++------------ extra/resources/ping | 139 +++++++++++---------- extra/resources/pingd | 68 +++++----- extra/resources/remote | 42 +++---- 10 files changed, 630 insertions(+), 634 deletions(-) diff --git a/extra/resources/ClusterMon.in b/extra/resources/ClusterMon.in index db397c2a4..b381c83b6 100755 --- a/extra/resources/ClusterMon.in +++ b/extra/resources/ClusterMon.in @@ -3,7 +3,7 @@ # ocf:pacemaker:ClusterMon resource agent # # Original copyright 2004 SUSE LINUX AG, Lars Marowsky-Br<E9>e -# Later changes copyright 2008-2018 the Pacemaker project contributors +# Later changes copyright 2008-2019 the Pacemaker project contributors # # The version control history for this file may have further details. # @@ -11,15 +11,15 @@ # (GPLv2) WITHOUT ANY WARRANTY. # -# Starts crm_mon in background which logs cluster status as -# html to the specified file. +# Starts crm_mon in background which logs cluster status as +# html to the specified file. # # OCF instance parameters: -# OCF_RESKEY_user -# OCF_RESKEY_pidfile -# OCF_RESKEY_update -# OCF_RESKEY_extra_options -# OCF_RESKEY_htmlfile +# OCF_RESKEY_user +# OCF_RESKEY_pidfile +# OCF_RESKEY_update +# OCF_RESKEY_extra_options +# OCF_RESKEY_htmlfile ####################################################################### # Initialization: @@ -30,7 +30,7 @@ ####################################################################### meta_data() { - cat <<END + cat <<END <?xml version="1.0"?> <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd"> <resource-agent name="ClusterMon" version="1.0"> @@ -101,7 +101,7 @@ END ####################################################################### ClusterMon_usage() { - cat <<END + cat <<END usage: $0 {start|stop|monitor|validate-all|meta-data} Expects to have a fully populated OCF RA-compliant environment set. @@ -109,47 +109,47 @@ END } ClusterMon_exit() { - if [ $1 != 0 ]; then - exit $OCF_ERR_GENERIC - else - exit $OCF_SUCCESS - fi + if [ $1 != 0 ]; then + exit $OCF_ERR_GENERIC + else + exit $OCF_SUCCESS + fi } ClusterMon_start() { if [ ! -z $OCF_RESKEY_user ]; then - su - $OCF_RESKEY_user -c "$CMON_CMD" + su - $OCF_RESKEY_user -c "$CMON_CMD" else - $CMON_CMD + $CMON_CMD fi ClusterMon_exit $? } ClusterMon_stop() { if [ -f $OCF_RESKEY_pidfile ]; then - pid=`cat $OCF_RESKEY_pidfile` - if [ ! -z $pid ]; then - kill -s 9 $pid - rm -f $OCF_RESKEY_pidfile - fi + pid=`cat $OCF_RESKEY_pidfile` + if [ ! -z $pid ]; then + kill -s 9 $pid + rm -f $OCF_RESKEY_pidfile + fi fi ClusterMon_exit 0 } ClusterMon_monitor() { if [ -f $OCF_RESKEY_pidfile ]; then - pid=`cat $OCF_RESKEY_pidfile` - if [ ! -z $pid ]; then - str=$(echo "su - $OCF_RESKEY_user -c \"$CMON_CMD\"" | tr 'crmon, \t' 'xxxxxxxx') - ps -o "args=${str}" -p $pid 2>/dev/null | \ - grep -qE "[c]rm_mon.*${OCF_RESKEY_pidfile}" - rc=$? - case $rc in - 0) exit $OCF_SUCCESS;; - 1) exit $OCF_NOT_RUNNING;; - *) exit $OCF_ERR_GENERIC;; - esac - fi + pid=`cat $OCF_RESKEY_pidfile` + if [ ! -z $pid ]; then + str=$(echo "su - $OCF_RESKEY_user -c \"$CMON_CMD\"" | tr 'crmon, \t' 'xxxxxxxx') + ps -o "args=${str}" -p $pid 2>/dev/null | \ + grep -qE "[c]rm_mon.*${OCF_RESKEY_pidfile}" + rc=$? + case $rc in + 0) exit $OCF_SUCCESS;; + 1) exit $OCF_NOT_RUNNING;; + *) exit $OCF_ERR_GENERIC;; + esac + fi fi exit $OCF_NOT_RUNNING } @@ -159,12 +159,12 @@ while getopts Vi:nrh:cdp: OPTION do case $OPTION in V|n|r|c|d);; - i) ocf_log warn "You should not have specified the -i option, since OCF_RESKEY_update is set already!";; - h) ocf_log warn "You should not have specified the -h option, since OCF_RESKEY_htmlfile is set already!";; - p) ocf_log warn "You should not have specified the -p option, since OCF_RESKEY_pidfile is set already!";; + i) ocf_log warn "You should not have specified the -i option, since OCF_RESKEY_update is set already!";; + h) ocf_log warn "You should not have specified the -h option, since OCF_RESKEY_htmlfile is set already!";; + p) ocf_log warn "You should not have specified the -p option, since OCF_RESKEY_pidfile is set already!";; *) return $OCF_ERR_ARGS;; esac -done +done if [ $? -ne 0 ]; then return $OCF_ERR_ARGS @@ -182,40 +182,40 @@ fi ClusterMon_validate() { # Existence of the user if [ ! -z $OCF_RESKEY_user ]; then - getent passwd "$OCF_RESKEY_user" >/dev/null - if [ $? -eq 0 ]; then - : Yes, user exists. We can further check his permission on crm_mon if necessary - else - ocf_log err "The user $OCF_RESKEY_user does not exist!" - exit $OCF_ERR_ARGS - fi + getent passwd "$OCF_RESKEY_user" >/dev/null + if [ $? -eq 0 ]; then + : Yes, user exists. We can further check his permission on crm_mon if necessary + else + ocf_log err "The user $OCF_RESKEY_user does not exist!" + exit $OCF_ERR_ARGS + fi fi # Pidfile better be an absolute path case $OCF_RESKEY_pidfile in - /*) ;; - *) ocf_log warn "You should have pidfile($OCF_RESKEY_pidfile) of absolute path!" ;; + /*) ;; + *) ocf_log warn "You should have pidfile($OCF_RESKEY_pidfile) of absolute path!" ;; esac # Check the update interval if ocf_is_decimal "$OCF_RESKEY_update" && [ $OCF_RESKEY_update -gt 0 ]; then - : + : else - ocf_log err "Invalid update interval $OCF_RESKEY_update. It should be positive integer!" - exit $OCF_ERR_ARGS + ocf_log err "Invalid update interval $OCF_RESKEY_update. It should be positive integer!" + exit $OCF_ERR_ARGS fi if CheckOptions $OCF_RESKEY_extra_options; then - : + : else - ocf_log err "Invalid options $OCF_RESKEY_extra_options!" - exit $OCF_ERR_ARGS + ocf_log err "Invalid options $OCF_RESKEY_extra_options!" + exit $OCF_ERR_ARGS fi # Htmlfile better be an absolute path case $OCF_RESKEY_htmlfile in - /*) ;; - *) ocf_log warn "You should have htmlfile($OCF_RESKEY_htmlfile) of absolute path!" ;; + /*) ;; + *) ocf_log warn "You should have htmlfile($OCF_RESKEY_htmlfile) of absolute path!" ;; esac @@ -233,29 +233,29 @@ fi : ${OCF_RESKEY_htmlfile:="/tmp/ClusterMon_${OCF_RESOURCE_INSTANCE}.html"} if [ ${OCF_RESKEY_update} -ge 1000 ]; then - OCF_RESKEY_update=$(( $OCF_RESKEY_update / 1000 )) + OCF_RESKEY_update=$(( $OCF_RESKEY_update / 1000 )) fi CMON_CMD="${HA_SBIN_DIR}/crm_mon -p $OCF_RESKEY_pidfile -d -i $OCF_RESKEY_update $OCF_RESKEY_extra_options -h $OCF_RESKEY_htmlfile" case $__OCF_ACTION in -meta-data) meta_data - exit $OCF_SUCCESS - ;; -start) ClusterMon_start - ;; -stop) ClusterMon_stop - ;; -monitor) ClusterMon_monitor - ;; -validate-all) ClusterMon_validate - ;; -usage|help) ClusterMon_usage - exit $OCF_SUCCESS - ;; -*) ClusterMon_usage - exit $OCF_ERR_UNIMPLEMENTED - ;; +meta-data) meta_data + exit $OCF_SUCCESS + ;; +start) ClusterMon_start + ;; +stop) ClusterMon_stop + ;; +monitor) ClusterMon_monitor + ;; +validate-all) ClusterMon_validate + ;; +usage|help) ClusterMon_usage + exit $OCF_SUCCESS + ;; +*) ClusterMon_usage + exit $OCF_ERR_UNIMPLEMENTED + ;; esac exit $? diff --git a/extra/resources/HealthCPU b/extra/resources/HealthCPU index 82ba597e4..379b9e81e 100755 --- a/extra/resources/HealthCPU +++ b/extra/resources/HealthCPU @@ -2,7 +2,7 @@ # # ocf:pacemaker:HealthCPU resource agent # -# Copyright 2004-2018 the Pacemaker project contributors +# Copyright 2004-2019 the Pacemaker project contributors # # The version control history for this file may have further details. # @@ -15,8 +15,8 @@ # ################################ # -# TODO: Enter default values -# Error handling in getting uptime +# TODO: Enter default values +# Error handling in getting uptime # ################################## @@ -30,7 +30,7 @@ ####################################################################### meta_data() { - cat <<END + cat <<END <?xml version="1.0"?> <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd"> <resource-agent name="HealthCPU" version="0.1"> @@ -84,7 +84,7 @@ END ####################################################################### dummy_usage() { - cat <<END + cat <<END usage: $0 {start|stop|monitor|validate-all|meta-data} Expects to have a fully populated OCF RA-compliant environment set. @@ -94,7 +94,7 @@ END dummy_start() { dummy_monitor if [ $? = $OCF_SUCCESS ]; then - return $OCF_SUCCESS + return $OCF_SUCCESS fi touch ${OCF_RESKEY_state} } @@ -102,46 +102,44 @@ dummy_start() { dummy_stop() { dummy_monitor if [ $? = $OCF_SUCCESS ]; then - rm ${OCF_RESKEY_state} + rm ${OCF_RESKEY_state} fi return $OCF_SUCCESS } dummy_monitor() { - # Monitor _MUST!_ differentiate correctly between running - # (SUCCESS), failed (ERROR) or _cleanly_ stopped (NOT RUNNING). - # That is THREE states, not just yes/no. - - if [ -f ${OCF_RESKEY_state} ]; then - - IDLE=`top -b -n2 | grep Cpu | tail -1 | awk -F",|.[0-9][ %]id" '{ print $4 }'` - # echo "System idle: " $IDLE - # echo "$OCF_RESKEY_red_limit" - # echo $OCF_RESKEY_yellow_limit - - if [ $IDLE -lt ${OCF_RESKEY_red_limit} ] ; then - # echo "System state RED!" - attrd_updater -n "#health-cpu" -U "red" -d "30s" - return $OCF_SUCCESS - fi - - if [ $IDLE -lt ${OCF_RESKEY_yellow_limit} ] ; then - # echo "System state yellow." - attrd_updater -n "#health-cpu" -U "yellow" -d "30s" - else - # echo "System state green." - attrd_updater -n "#health-cpu" -U "green" -d "30s" - - fi - - return $OCF_SUCCESS - fi + # Monitor _MUST!_ differentiate correctly between running + # (SUCCESS), failed (ERROR) or _cleanly_ stopped (NOT RUNNING). + # That is THREE states, not just yes/no. + + if [ -f ${OCF_RESKEY_state} ]; then + + IDLE=`top -b -n2 | grep Cpu | tail -1 | awk -F",|.[0-9][ %]id" '{ print $4 }'` + # echo "System idle: " $IDLE + # echo "$OCF_RESKEY_red_limit" + # echo $OCF_RESKEY_yellow_limit + + if [ $IDLE -lt ${OCF_RESKEY_red_limit} ] ; then + # echo "System state RED!" + attrd_updater -n "#health-cpu" -U "red" -d "30s" + return $OCF_SUCCESS + fi - if false ; then - return $OCF_ERR_GENERIC + if [ $IDLE -lt ${OCF_RESKEY_yellow_limit} ] ; then + # echo "System state yellow." + attrd_updater -n "#health-cpu" -U "yellow" -d "30s" + else + # echo "System state green." + attrd_updater -n "#health-cpu" -U "green" -d "30s" fi - return $OCF_NOT_RUNNING + + return $OCF_SUCCESS + fi + if false ; then + return $OCF_ERR_GENERIC + fi + return $OCF_NOT_RUNNING } dummy_validate() { @@ -150,7 +148,7 @@ dummy_validate() { state_dir=`dirname "$OCF_RESKEY_state"` touch "$state_dir/$$" if [ $? != 0 ]; then - return $OCF_ERR_ARGS + return $OCF_ERR_ARGS fi rm "$state_dir/$$" @@ -162,39 +160,38 @@ dummy_validate() { if [ "x$OCF_RESKEY_state" = "x" ]; then if [ ${OCF_RESKEY_CRM_meta_globally_unique} = "false" ]; then - state="${HA_VARRUN%%/}/Dummy-${OCF_RESOURCE_INSTANCE}.state" - - # Strip off the trailing clone marker - OCF_RESKEY_state=`echo $state | sed s/:[0-9][0-9]*\.state/.state/` + state="${HA_VARRUN%%/}/Dummy-${OCF_RESOURCE_INSTANCE}.state" + + # Strip off the trailing clone marker + OCF_RESKEY_state=`echo $state | sed s/:[0-9][0-9]*\.state/.state/` else - OCF_RESKEY_state="${HA_VARRUN%%/}/Dummy-${OCF_RESOURCE_INSTANCE}.state" + OCF_RESKEY_state="${HA_VARRUN%%/}/Dummy-${OCF_RESOURCE_INSTANCE}.state" fi fi if [ "x${OCF_RESKEY_red_limit}" = "x" ] ; then - OCF_RESKEY_red_limit=10 + OCF_RESKEY_red_limit=10 fi if [ "x${OCF_RESKEY_yellow_limit}" = "x" ] ; then - OCF_RESKEY_yellow_limit=50 + OCF_RESKEY_yellow_limit=50 fi case $__OCF_ACTION in -meta-data) meta_data - exit $OCF_SUCCESS - ;; -start) dummy_start;; -stop) dummy_stop;; -monitor) dummy_monitor;; -validate-all) dummy_validate;; -usage|help) dummy_usage - exit $OCF_SUCCESS - ;; -*) dummy_usage - exit $OCF_ERR_UNIMPLEMENTED - ;; +meta-data) meta_data + exit $OCF_SUCCESS + ;; +start) dummy_start;; +stop) dummy_stop;; +monitor) dummy_monitor;; +validate-all) dummy_validate;; +usage|help) dummy_usage + exit $OCF_SUCCESS + ;; +*) dummy_usage + exit $OCF_ERR_UNIMPLEMENTED + ;; esac rc=$? ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc" exit $rc - diff --git a/extra/resources/HealthSMART.in b/extra/resources/HealthSMART.in index 344cb1418..f4aad16b4 100755 --- a/extra/resources/HealthSMART.in +++ b/extra/resources/HealthSMART.in @@ -2,7 +2,7 @@ # # ocf:pacemaker:HealthSMART resource agent # -# Copyright 2009-2018 the Pacemaker project contributors +# Copyright 2009-2019 the Pacemaker project contributors # # The version control history for this file may have further details. # @@ -109,27 +109,27 @@ END check_temperature() { if [ $1 -lt ${lower_red_limit} ] ; then - ocf_log info "Drive ${DRIVE} ${DEVICE} too cold: ${1} C" - $ATTRDUP -n "#health-smart" -U "red" -d "5s" - return 1 + ocf_log info "Drive ${DRIVE} ${DEVICE} too cold: ${1} C" + $ATTRDUP -n "#health-smart" -U "red" -d "5s" + return 1 fi if [ $1 -gt ${upper_red_limit} ] ; then - ocf_log info "Drive ${DRIVE} ${DEVICE} too hot: ${1} C" - $ATTRDUP -n "#health-smart" -U "red" -d "5s" - return 1 + ocf_log info "Drive ${DRIVE} ${DEVICE} too hot: ${1} C" + $ATTRDUP -n "#health-smart" -U "red" -d "5s" + return 1 fi if [ $1 -lt ${lower_yellow_limit} ] ; then - ocf_log info "Drive ${DRIVE} ${DEVICE} quite cold: ${1} C" - $ATTRDUP -n "#health-smart" -U "yellow" -d "5s" - return 1 + ocf_log info "Drive ${DRIVE} ${DEVICE} quite cold: ${1} C" + $ATTRDUP -n "#health-smart" -U "yellow" -d "5s" + return 1 fi if [ $1 -gt ${upper_yellow_limit} ] ; then - ocf_log info "Drive ${DRIVE} ${DEVICE} quite hot: ${1} C" - $ATTRDUP -n "#health-smart" -U "yellow" -d "5s" - return 1 + ocf_log info "Drive ${DRIVE} ${DEVICE} quite hot: ${1} C" + $ATTRDUP -n "#health-smart" -U "yellow" -d "5s" + return 1 fi } @@ -137,7 +137,7 @@ check_temperature() { init_smart() { #Set temperature defaults if [ -z ${OCF_RESKEY_temp_warning} ]; then - yellow_threshold=5 + yellow_threshold=5 else yellow_threshold=${OCF_RESKEY_temp_warning} fi @@ -170,21 +170,21 @@ init_smart() { fi for DRIVE in $DRIVES; do - if [ "${OCF_RESKEY_devices}" ]; then - for DEVICE in ${OCF_RESKEY_devices}; do - $SMARTCTL -d $DEVICE -i ${DRIVE} | grep -q "SMART support is: Enabled" - if [ $? -ne "0" ] ; then - ocf_log err "S.M.A.R.T. not enabled for drive "${DRIVE} - exit $OCF_ERR_INSTALLED - fi - done - else - $SMARTCTL -i ${DRIVE} | grep -q "SMART support is: Enabled" - if [ $? -ne "0" ] ; then - ocf_log err "S.M.A.R.T. not enabled for drive "${DRIVE} - exit $OCF_ERR_INSTALLED - fi - fi + if [ "${OCF_RESKEY_devices}" ]; then + for DEVICE in ${OCF_RESKEY_devices}; do + $SMARTCTL -d $DEVICE -i ${DRIVE} | grep -q "SMART support is: Enabled" + if [ $? -ne "0" ] ; then + ocf_log err "S.M.A.R.T. not enabled for drive "${DRIVE} + exit $OCF_ERR_INSTALLED + fi + done + else + $SMARTCTL -i ${DRIVE} | grep -q "SMART support is: Enabled" + if [ $? -ne "0" ] ; then + ocf_log err "S.M.A.R.T. not enabled for drive "${DRIVE} + exit $OCF_ERR_INSTALLED + fi + fi done } @@ -224,36 +224,36 @@ HealthSMART_monitor() { # Check overall S.M.A.R.T. status for DRIVE in $DRIVES; do - if [ "${OCF_RESKEY_devices}" ]; then - for DEVICE in ${OCF_RESKEY_devices}; do - $SMARTCTL -d $DEVICE -H ${DRIVE} | grep -q "SMART overall-health self-assessment test result: PASSED" - if [ $? -ne "0" ]; then - $ATTRDUP -n "#health-smart" -U "red" -d "5s" - return $OCF_SUCCESS - fi - done - else - $SMARTCTL -H ${DRIVE} | grep -q "SMART overall-health self-assessment test result: PASSED" - if [ $? -ne "0" ]; then - $ATTRDUP -n "#health-smart" -U "red" -d "5s" - return $OCF_SUCCESS - fi - fi - + if [ "${OCF_RESKEY_devices}" ]; then + for DEVICE in ${OCF_RESKEY_devices}; do + $SMARTCTL -d $DEVICE -H ${DRIVE} | grep -q "SMART overall-health self-assessment test result: PASSED" + if [ $? -ne "0" ]; then + $ATTRDUP -n "#health-smart" -U "red" -d "5s" + return $OCF_SUCCESS + fi + done + else + $SMARTCTL -H ${DRIVE} | grep -q "SMART overall-health self-assessment test result: PASSED" + if [ $? -ne "0" ]; then + $ATTRDUP -n "#health-smart" -U "red" -d "5s" + return $OCF_SUCCESS + fi + fi + # Check drive temperature(s) - if [ "${OCF_RESKEY_devices}" ]; then - for DEVICE in ${OCF_RESKEY_devices}; do - check_temperature "$("$SMARTCTL" -d "$DEVICE" -A "${DRIVE}" | awk '/^194/ { print $10 }')" - if [ $? -ne 0 ]; then - return $OCF_SUCCESS - fi - done - else - check_temperature "$("$SMARTCTL" -A "${DRIVE}" | awk '/^194/ { print $10 }')" - if [ $? -ne 0 ]; then - return $OCF_SUCCESS - fi - fi + if [ "${OCF_RESKEY_devices}" ]; then + for DEVICE in ${OCF_RESKEY_devices}; do + check_temperature "$("$SMARTCTL" -d "$DEVICE" -A "${DRIVE}" | awk '/^194/ { print $10 }')" + if [ $? -ne 0 ]; then + return $OCF_SUCCESS + fi + done + else + check_temperature "$("$SMARTCTL" -A "${DRIVE}" | awk '/^194/ { print $10 }')" + if [ $? -ne 0 ]; then + return $OCF_SUCCESS + fi + fi done $ATTRDUP -n "#health-smart" -U "green" -d "5s" @@ -268,7 +268,7 @@ HealthSMART_validate() { init_smart - # Is the state directory writable? + # Is the state directory writable? state_dir=`dirname "$OCF_RESKEY_state"` touch "$state_dir/$$" if [ $? != 0 ]; then @@ -286,7 +286,7 @@ if [ "x$OCF_RESKEY_state" = "x" ]; then if [ ${OCF_RESKEY_CRM_meta_globally_unique} = "false" ]; then state="${HA_VARRUN%%/}/HealthSMART-${OCF_RESOURCE_INSTANCE}.state" - # Strip off the trailing clone marker + # Strip off the trailing clone marker OCF_RESKEY_state=`echo $state | sed s/:[0-9][0-9]*\.state/.state/` else OCF_RESKEY_state="${HA_VARRUN%%/}/HealthSMART-${OCF_RESOURCE_INSTANCE}.state" @@ -294,21 +294,21 @@ if [ "x$OCF_RESKEY_state" = "x" ]; then fi case $__OCF_ACTION in - start) HealthSMART_start;; - stop) HealthSMART_stop;; - monitor) HealthSMART_monitor;; + start) HealthSMART_start;; + stop) HealthSMART_stop;; + monitor) HealthSMART_monitor;; validate-all) HealthSMART_validate;; meta-data) - meta_data - exit $OCF_SUCCESS - ;; + meta_data + exit $OCF_SUCCESS + ;; usage|help) - HealthSMART_usage - exit $OCF_SUCCESS - ;; + HealthSMART_usage + exit $OCF_SUCCESS + ;; *) HealthSMART_usage - exit $OCF_ERR_UNIMPLEMENTED - ;; + exit $OCF_ERR_UNIMPLEMENTED + ;; esac rc=$? ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc" diff --git a/extra/resources/Stateful b/extra/resources/Stateful index 2450a801f..da776ebe4 100755 --- a/extra/resources/Stateful +++ b/extra/resources/Stateful @@ -2,7 +2,7 @@ # # ocf:pacemaker:Stateful resource agent # -# Copyright 2006-2018 the Pacemaker project contributors +# Copyright 2006-2019 the Pacemaker project contributors # # The version control history for this file may have further details. # @@ -25,7 +25,7 @@ CRM_MASTER="${HA_SBIN_DIR}/crm_master -l reboot" ####################################################################### meta_data() { - cat <<END + cat <<END <?xml version="1.0"?> <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd"> <resource-agent name="Stateful" version="1.1"> @@ -76,36 +76,36 @@ to simulate a long-running notify. </actions> </resource-agent> END - exit $OCF_SUCCESS + exit $OCF_SUCCESS } ####################################################################### stateful_usage() { - cat <<END + cat <<END usage: $0 {start|stop|promote|demote|monitor|validate-all|meta-data} Expects to have a fully populated OCF RA-compliant environment set. END - exit $1 + exit $1 } stateful_update() { - echo $1 > ${OCF_RESKEY_state} + echo $1 > ${OCF_RESKEY_state} } stateful_check_state() { target=$1 if [ -f ${OCF_RESKEY_state} ]; then - state=`cat ${OCF_RESKEY_state}` - if [ "x$target" = "x$state" ]; then - return 0 - fi + state=`cat ${OCF_RESKEY_state}` + if [ "x$target" = "x$state" ]; then + return 0 + fi else - if [ "x$target" = "x" ]; then - return 0 - fi + if [ "x$target" = "x" ]; then + return 0 + fi fi return 1 @@ -122,8 +122,8 @@ $(env | sort) stateful_start() { stateful_check_state master if [ $? = 0 ]; then - # CRM Error - Should never happen - return $OCF_RUNNING_MASTER + # CRM Error - Should never happen + return $OCF_RUNNING_MASTER fi stateful_update slave $CRM_MASTER -v ${slave_score} @@ -133,8 +133,8 @@ stateful_start() { stateful_demote() { stateful_check_state if [ $? = 0 ]; then - # CRM Error - Should never happen - return $OCF_NOT_RUNNING + # CRM Error - Should never happen + return $OCF_NOT_RUNNING fi stateful_update slave $CRM_MASTER -v ${slave_score} @@ -144,7 +144,7 @@ stateful_demote() { stateful_promote() { stateful_check_state if [ $? = 0 ]; then - return $OCF_NOT_RUNNING + return $OCF_NOT_RUNNING fi stateful_update master $CRM_MASTER -v ${master_score} @@ -155,11 +155,11 @@ stateful_stop() { $CRM_MASTER -D stateful_check_state master if [ $? = 0 ]; then - # CRM Error - Should never happen - return $OCF_RUNNING_MASTER + # CRM Error - Should never happen + return $OCF_RUNNING_MASTER fi if [ -f ${OCF_RESKEY_state} ]; then - rm ${OCF_RESKEY_state} + rm ${OCF_RESKEY_state} fi return 0 } @@ -167,26 +167,26 @@ stateful_stop() { stateful_monitor() { stateful_check_state "master" if [ $? = 0 ]; then - if [ $OCF_RESKEY_CRM_meta_interval = 0 ]; then - # Restore the master setting during probes - $CRM_MASTER -v ${master_score} - fi - return $OCF_RUNNING_MASTER + if [ $OCF_RESKEY_CRM_meta_interval = 0 ]; then + # Restore the master setting during probes + $CRM_MASTER -v ${master_score} + fi + return $OCF_RUNNING_MASTER fi stateful_check_state "slave" if [ $? = 0 ]; then - if [ $OCF_RESKEY_CRM_meta_interval = 0 ]; then - # Restore the master setting during probes - $CRM_MASTER -v ${slave_score} - fi - return $OCF_SUCCESS + if [ $OCF_RESKEY_CRM_meta_interval = 0 ]; then + # Restore the master setting during probes + $CRM_MASTER -v ${slave_score} + fi + return $OCF_SUCCESS fi if [ -f ${OCF_RESKEY_state} ]; then - echo "File '${OCF_RESKEY_state}' exists but contains unexpected contents" - cat ${OCF_RESKEY_state} - return $OCF_ERR_GENERIC + echo "File '${OCF_RESKEY_state}' exists but contains unexpected contents" + cat ${OCF_RESKEY_state} + return $OCF_ERR_GENERIC fi return 7 } @@ -199,7 +199,7 @@ stateful_notify() { } stateful_validate() { - exit $OCF_SUCCESS + exit $OCF_SUCCESS } : ${slave_score=5} @@ -211,28 +211,28 @@ stateful_validate() { if [ "x$OCF_RESKEY_state" = "x" ]; then if [ ${OCF_RESKEY_CRM_meta_globally_unique} = "false" ]; then - state="${HA_VARRUN%%/}/Stateful-${OCF_RESOURCE_INSTANCE}.state" - - # Strip off the trailing clone marker - OCF_RESKEY_state=`echo $state | sed s/:[0-9][0-9]*\.state/.state/` + state="${HA_VARRUN%%/}/Stateful-${OCF_RESOURCE_INSTANCE}.state" + + # Strip off the trailing clone marker + OCF_RESKEY_state=`echo $state | sed s/:[0-9][0-9]*\.state/.state/` else - OCF_RESKEY_state="${HA_VARRUN%%/}/Stateful-${OCF_RESOURCE_INSTANCE}.state" + OCF_RESKEY_state="${HA_VARRUN%%/}/Stateful-${OCF_RESOURCE_INSTANCE}.state" fi fi dump_env case $__OCF_ACTION in -meta-data) meta_data;; -start) stateful_start;; -promote) stateful_promote;; -demote) stateful_demote;; +meta-data) meta_data;; +start) stateful_start;; +promote) stateful_promote;; +demote) stateful_demote;; notify) stateful_notify ;; -stop) stateful_stop;; -monitor) stateful_monitor;; -validate-all) stateful_validate;; -usage|help) stateful_usage $OCF_SUCCESS;; -*) stateful_usage $OCF_ERR_UNIMPLEMENTED;; +stop) stateful_stop;; +monitor) stateful_monitor;; +validate-all) stateful_validate;; +usage|help) stateful_usage $OCF_SUCCESS;; +*) stateful_usage $OCF_ERR_UNIMPLEMENTED;; esac exit $? diff --git a/extra/resources/SysInfo.in b/extra/resources/SysInfo.in index 40400719c..bd6ce48e2 100755 --- a/extra/resources/SysInfo.in +++ b/extra/resources/SysInfo.in @@ -3,7 +3,7 @@ # ocf:pacemaker:SysInfo resource agent # # Original copyright 2004 SUSE LINUX AG, Lars Marowsky-Br<E9>e -# Later changes copyright 2008-2018 the Pacemaker project contributors +# Later changes copyright 2008-2019 the Pacemaker project contributors # # The version control history for this file may have further details. # @@ -12,7 +12,7 @@ # # -# This agent records (in the CIB) various attributes of a node +# This agent records (in the CIB) various attributes of a node # ####################################################################### # Initialization: @@ -24,7 +24,7 @@ ####################################################################### meta_data() { - cat <<END + cat <<END <?xml version="1.0"?> <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd"> <resource-agent name="SysInfo" version="1.0"> @@ -150,101 +150,101 @@ SysInfoStats() { UpdateStat os "`uname -s`-`uname -r`" case `uname -s` in - "Darwin") - mem=`top -l 1 | grep Mem: | awk '{print $10}'` - mem_used=`top -l 1 | grep Mem: | awk '{print $8}'` - mem=`SysInfo_mem_units $mem` - mem_used=`SysInfo_mem_units $mem_used` - mem_total=`expr $mem_used + $mem` - cpu_type=`system_profiler SPHardwareDataType | awk -F': ' '/^CPU Type/ {print $2; exit}'` - cpu_speed=`system_profiler SPHardwareDataType | awk -F': ' '/^CPU Speed/ {print $2; exit}'` - cpu_cores=`system_profiler SPHardwareDataType | awk -F': ' '/^Number Of/ {print $2; exit}'` - cpu_load=`uptime | awk '{ print $10 }'` - ;; - "FreeBSD") - cpu_type=`sysctl -in hw.model` - cpu_speed=`sysctl -in dev.cpu.0.freq` - cpu_cores=`sysctl -in hw.ncpu` - cpu_load=`sysctl -in vm.loadavg | awk '{ print $4 }'` - - free_pages=`sysctl -in vm.stats.vm.v_free_count` - page_count=`sysctl -in vm.stats.vm.v_page_count` - page_size=`sysctl -in vm.stats.vm.v_page_size` - - mem=`expr $free_pages \* $page_size / 1024 / 1024`M - mem_total=`expr $page_count \* $page_size / 1024 / 1024`M - ;; - "Linux") - if [ -f /proc/cpuinfo ]; then - cpu_type=`awk -F': ' '/model name/ {print $2; exit}' /proc/cpuinfo` - cpu_speed=`awk -F': ' '/bogomips/ {print $2; exit}' /proc/cpuinfo` - cpu_cores=`grep "^processor" /proc/cpuinfo | wc -l` - fi - cpu_load=`uptime | awk '{ print $10 }'` - - if [ -f /proc/meminfo ]; then - # meminfo results are in kB - mem=`grep "SwapFree" /proc/meminfo | awk '{print $2"k"}'` - if [ ! -z $mem ]; then - UpdateStat free_swap "$(SysInfo_mem_units "$mem")" - fi - mem=`grep "Inactive" /proc/meminfo | awk '{print $2"k"}'` - mem_total=`grep "MemTotal" /proc/meminfo | awk '{print $2"k"}'` - else - mem=`top -n 1 | grep Mem: | awk '{print $7}'` - fi - ;; - *) + "Darwin") + mem=`top -l 1 | grep Mem: | awk '{print $10}'` + mem_used=`top -l 1 | grep Mem: | awk '{print $8}'` + mem=`SysInfo_mem_units $mem` + mem_used=`SysInfo_mem_units $mem_used` + mem_total=`expr $mem_used + $mem` + cpu_type=`system_profiler SPHardwareDataType | awk -F': ' '/^CPU Type/ {print $2; exit}'` + cpu_speed=`system_profiler SPHardwareDataType | awk -F': ' '/^CPU Speed/ {print $2; exit}'` + cpu_cores=`system_profiler SPHardwareDataType | awk -F': ' '/^Number Of/ {print $2; exit}'` + cpu_load=`uptime | awk '{ print $10 }'` + ;; + "FreeBSD") + cpu_type=`sysctl -in hw.model` + cpu_speed=`sysctl -in dev.cpu.0.freq` + cpu_cores=`sysctl -in hw.ncpu` + cpu_load=`sysctl -in vm.loadavg | awk '{ print $4 }'` + + free_pages=`sysctl -in vm.stats.vm.v_free_count` + page_count=`sysctl -in vm.stats.vm.v_page_count` + page_size=`sysctl -in vm.stats.vm.v_page_size` + + mem=`expr $free_pages \* $page_size / 1024 / 1024`M + mem_total=`expr $page_count \* $page_size / 1024 / 1024`M + ;; + "Linux") + if [ -f /proc/cpuinfo ]; then + cpu_type=`awk -F': ' '/model name/ {print $2; exit}' /proc/cpuinfo` + cpu_speed=`awk -F': ' '/bogomips/ {print $2; exit}' /proc/cpuinfo` + cpu_cores=`grep "^processor" /proc/cpuinfo | wc -l` + fi + cpu_load=`uptime | awk '{ print $10 }'` + + if [ -f /proc/meminfo ]; then + # meminfo results are in kB + mem=`grep "SwapFree" /proc/meminfo | awk '{print $2"k"}'` + if [ ! -z $mem ]; then + UpdateStat free_swap "$(SysInfo_mem_units "$mem")" + fi + mem=`grep "Inactive" /proc/meminfo | awk '{print $2"k"}'` + mem_total=`grep "MemTotal" /proc/meminfo | awk '{print $2"k"}'` + else + mem=`top -n 1 | grep Mem: | awk '{print $7}'` + fi + ;; + *) esac if [ x != x"$cpu_type" ]; then - UpdateStat cpu_info "$cpu_type" + UpdateStat cpu_info "$cpu_type" fi if [ x != x"$cpu_speed" ]; then - UpdateStat cpu_speed "$cpu_speed" + UpdateStat cpu_speed "$cpu_speed" fi if [ x != x"$cpu_cores" ]; then - UpdateStat cpu_cores "$cpu_cores" + UpdateStat cpu_cores "$cpu_cores" fi if [ x != x"$cpu_load" ]; then - UpdateStat cpu_load "$cpu_load" + UpdateStat cpu_load "$cpu_load" fi if [ ! -z "$mem" ]; then # Massage the memory values - UpdateStat ram_total "$(SysInfo_mem_units "$mem_total")" - UpdateStat ram_free "$(SysInfo_mem_units "$mem")" + UpdateStat ram_total "$(SysInfo_mem_units "$mem_total")" + UpdateStat ram_free "$(SysInfo_mem_units "$mem")" fi # Portability notes: # o tail: explicit "-n" not available in Solaris; instead simplify - # 'tail -n <c>' to the equivalent 'tail -<c>'. + # 'tail -n <c>' to the equivalent 'tail -<c>'. for disk in "/" ${OCF_RESKEY_disks}; do - unset disk_free disk_label - disk_free=`df -h ${disk} | tail -1 | awk '{print $4}'` - if [ x != x"$disk_free" ]; then - disk_label=`echo $disk | sed -e 's#^/$#root#;s#^/*##;s#/#_#g'` - disk_free=`SysInfo_hdd_units $disk_free` - UpdateStat ${disk_label}_free $disk_free - if [ -n "$MIN_FREE" ]; then - if [ $disk_free -le $MIN_FREE ]; then - UpdateStat "#health_disk" "red" - else - UpdateStat "#health_disk" "green" - fi - fi - fi + unset disk_free disk_label + disk_free=`df -h ${disk} | tail -1 | awk '{print $4}'` + if [ x != x"$disk_free" ]; then + disk_label=`echo $disk | sed -e 's#^/$#root#;s#^/*##;s#/#_#g'` + disk_free=`SysInfo_hdd_units $disk_free` + UpdateStat ${disk_label}_free $disk_free + if [ -n "$MIN_FREE" ]; then + if [ $disk_free -le $MIN_FREE ]; then + UpdateStat "#health_disk" "red" + else + UpdateStat "#health_disk" "green" + fi + fi + fi done } SysInfo_megabytes() { # Size in megabytes echo $1 | awk '{ n = $0; - sub(/[0-9]+(.[0-9]+)?/, ""); - split(n, a, $0); + sub(/[0-9]+(.[0-9]+)?/, ""); + split(n, a, $0); n=a[1]; if ($0 == "G" || $0 == "") { n *= 1024 }; if (/^kB?/) { n /= 1024 }; @@ -255,14 +255,14 @@ SysInfo_mem_units() { mem=$1 if [ -z $1 ]; then - return + return fi mem=$(SysInfo_megabytes "$1") # Round to the next multiple of 50 r=$(($mem % 50)) if [ $r != 0 ]; then - mem=$(($mem + 50 - $r)) + mem=$(($mem + 50 - $r)) fi echo $mem @@ -272,20 +272,20 @@ SysInfo_hdd_units() { # Defauts to size in gigabytes case $OCF_RESKEY_disk_unit in - [Pp]) echo $(($(SysInfo_megabytes "$1") / 1024 / 1024 / 1024));; - [Tt]) echo $(($(SysInfo_megabytes "$1") / 1024 / 1024));; - [Gg]) echo $(($(SysInfo_megabytes "$1") / 1024));; - [Mm]) echo "$(SysInfo_megabytes "$1")" ;; - [Kk]) echo $(($(SysInfo_megabytes "$1") * 1024));; - [Bb]) echo $(($(SysInfo_megabytes "$1") * 1024 * 1024));; - *) - ocf_log err "Invalid value for disk_unit: $OCF_RESKEY_disk_unit" - echo $(($(SysInfo_megabytes "$1") / 1024));; + [Pp]) echo $(($(SysInfo_megabytes "$1") / 1024 / 1024 / 1024));; + [Tt]) echo $(($(SysInfo_megabytes "$1") / 1024 / 1024));; + [Gg]) echo $(($(SysInfo_megabytes "$1") / 1024));; + [Mm]) echo "$(SysInfo_megabytes "$1")" ;; + [Kk]) echo $(($(SysInfo_megabytes "$1") * 1024));; + [Bb]) echo $(($(SysInfo_megabytes "$1") * 1024 * 1024));; + *) + ocf_log err "Invalid value for disk_unit: $OCF_RESKEY_disk_unit" + echo $(($(SysInfo_megabytes "$1") / 1024));; esac } SysInfo_usage() { - cat <<END + cat <<END usage: $0 {start|stop|monitor|validate-all|meta-data} Expects to have a fully populated OCF RA-compliant environment set. @@ -305,20 +305,20 @@ SysInfo_stop() { SysInfo_monitor() { if [ -f $OCF_RESKEY_pidfile ]; then - clone=`cat $OCF_RESKEY_pidfile` + clone=`cat $OCF_RESKEY_pidfile` fi if [ x$clone = x ]; then - rm $OCF_RESKEY_pidfile - exit $OCF_NOT_RUNNING + rm $OCF_RESKEY_pidfile + exit $OCF_NOT_RUNNING elif [ $clone = $OCF_RESKEY_clone ]; then - SysInfoStats - exit $OCF_SUCCESS + SysInfoStats + exit $OCF_SUCCESS elif ocf_is_true "$OCF_RESKEY_CRM_meta_globally_unique"; then - SysInfoStats - exit $OCF_SUCCESS + SysInfoStats + exit $OCF_SUCCESS fi exit $OCF_NOT_RUNNING } @@ -342,29 +342,29 @@ else fi MIN_FREE="" if [ -n "$OCF_RESKEY_min_disk_free" ]; then - ocf_is_decimal "$OCF_RESKEY_min_disk_free" && - OCF_RESKEY_min_disk_free="$OCF_RESKEY_min_disk_free$OCF_RESKEY_disk_unit" + ocf_is_decimal "$OCF_RESKEY_min_disk_free" && + OCF_RESKEY_min_disk_free="$OCF_RESKEY_min_disk_free$OCF_RESKEY_disk_unit" MIN_FREE=`SysInfo_hdd_units $OCF_RESKEY_min_disk_free` fi case $__OCF_ACTION in -meta-data) meta_data - exit $OCF_SUCCESS - ;; -start) SysInfo_start - ;; -stop) SysInfo_stop - ;; -monitor) SysInfo_monitor - ;; -validate-all) SysInfo_validate - ;; -usage|help) SysInfo_usage - exit $OCF_SUCCESS - ;; -*) SysInfo_usage - exit $OCF_ERR_UNIMPLEMENTED - ;; +meta-data) meta_data + exit $OCF_SUCCESS + ;; +start) SysInfo_start + ;; +stop) SysInfo_stop + ;; +monitor) SysInfo_monitor + ;; +validate-all) SysInfo_validate + ;; +usage|help) SysInfo_usage + exit $OCF_SUCCESS + ;; +*) SysInfo_usage + exit $OCF_ERR_UNIMPLEMENTED + ;; esac exit $? diff --git a/extra/resources/SystemHealth b/extra/resources/SystemHealth index 499f95936..ef05e2d11 100755 --- a/extra/resources/SystemHealth +++ b/extra/resources/SystemHealth @@ -2,7 +2,7 @@ # # ocf:pacemaker:SystemHealth resource agent # -# Copyright 2009-2018 the Pacemaker project contributors +# Copyright 2009-2019 the Pacemaker project contributors # # The version control history for this file may have further details. # @@ -20,7 +20,7 @@ ####################################################################### meta_data() { - cat <<END + cat <<END <?xml version="1.0"?> <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd"> <resource-agent name="SystemHealth" version="0.1"> @@ -36,12 +36,12 @@ the health of a system via IPMI. </parameters> <actions> -<action name="start" timeout="20s" /> -<action name="stop" timeout="20s" /> -<action name="monitor" timeout="20s" /> -<action name="reload" timeout="20s" /> -<action name="meta-data" timeout="5s" /> -<action name="validate-all" timeout="20s" /> +<action name="start" timeout="20s" /> +<action name="stop" timeout="20s" /> +<action name="monitor" timeout="20s" /> +<action name="reload" timeout="20s" /> +<action name="meta-data" timeout="5s" /> +<action name="validate-all" timeout="20s" /> </actions> </resource-agent> END @@ -50,7 +50,7 @@ END ####################################################################### SystemHealth_usage() { - cat <<END + cat <<END usage: $0 {start|stop|monitor|validate-all|meta-data} Expects to have a fully populated OCF RA-compliant environment set. @@ -62,24 +62,24 @@ SystemHealth_check_tools() { RC=$? if [ $RC != 0 ]; then - ocf_log err "servicelog_notify not found!" - return $OCF_ERR_INSTALLED + ocf_log err "servicelog_notify not found!" + return $OCF_ERR_INSTALLED fi which ipmiservicelogd > /dev/null 2>&1 RC=$? if [ $RC != 0 ]; then - ocf_log err "ipmiservicelogd not found!" - return $OCF_ERR_INSTALLED + ocf_log err "ipmiservicelogd not found!" + return $OCF_ERR_INSTALLED fi test -x $OCF_RESKEY_program RC=$? if [ $RC != 0 ]; then - ocf_log err "$OCF_RESKEY_program not found!" - return $OCF_ERR_INSTALLED + ocf_log err "$OCF_RESKEY_program not found!" + return $OCF_ERR_INSTALLED fi } @@ -88,34 +88,34 @@ SystemHealth_start() { RC=$? if [ $RC = $OCF_ERR_GENERIC ]; then - return $OCF_ERR_GENERIC + return $OCF_ERR_GENERIC elif [ $RC = $OCF_SUCCESS ]; then - ocf_log warn "starting an already started SystemHealth" - return $OCF_SUCCESS + ocf_log warn "starting an already started SystemHealth" + return $OCF_SUCCESS fi service ipmi start > /dev/null 2>&1 RC=$? if [ $RC != 0 ]; then - ocf_log err "Could not start service IPMI!" - return $OCF_ERR_GENERIC + ocf_log err "Could not start service IPMI!" + return $OCF_ERR_GENERIC fi ipmiservicelogd smi 0 > /dev/null 2>&1 & RC=$? if [ $RC != 0 ]; then - ocf_log err "Could not start ipmiservicelogd!" - return $OCF_ERR_GENERIC + ocf_log err "Could not start ipmiservicelogd!" + return $OCF_ERR_GENERIC fi servicelog_notify --add --type=EVENT --command="$OCF_RESKEY_program" --method=num_arg --match='type=4' > /dev/null 2>&1 RC=$? if [ $RC != 0 ]; then - ocf_log err "servicelog_notify register handler failed!" - return $OCF_ERR_GENERIC + ocf_log err "servicelog_notify register handler failed!" + return $OCF_ERR_GENERIC fi return $OCF_SUCCESS @@ -126,33 +126,33 @@ SystemHealth_stop() { RC=$? if [ $RC = $OCF_ERR_GENERIC ]; then - return $OCF_ERR_GENERIC + return $OCF_ERR_GENERIC elif [ $RC = $OCF_SUCCESS ]; then - killall ipmiservicelogd - RC1=$? + killall ipmiservicelogd + RC1=$? - if [ $RC1 != 0 ]; then - ocf_log err "Could not stop ipmiservicelogd!" - fi + if [ $RC1 != 0 ]; then + ocf_log err "Could not stop ipmiservicelogd!" + fi - servicelog_notify --remove --command="$OCF_RESKEY_program" > /dev/null 2>&1 - RC2=$? + servicelog_notify --remove --command="$OCF_RESKEY_program" > /dev/null 2>&1 + RC2=$? - if [ $RC2 != 0 ]; then - ocf_log err "servicelog_notify remove handler failed!" - fi + if [ $RC2 != 0 ]; then + ocf_log err "servicelog_notify remove handler failed!" + fi - if [ $RC1 -eq 0 ] && [ $RC2 -eq 0 ]; then - return $OCF_SUCCESS - else - return $OCF_ERR_GENERIC - fi + if [ $RC1 -eq 0 ] && [ $RC2 -eq 0 ]; then + return $OCF_SUCCESS + else + return $OCF_ERR_GENERIC + fi elif [ $RC = $OCF_NOT_RUNNING ]; then - ocf_log warn "stopping an already stopped SystemHealth" - return $OCF_SUCCESS + ocf_log warn "stopping an already stopped SystemHealth" + return $OCF_SUCCESS else - ocf_log err "SystemHealth_stop: should not be here!" - return $OCF_ERR_GENERIC + ocf_log err "SystemHealth_stop: should not be here!" + return $OCF_ERR_GENERIC fi } @@ -162,28 +162,28 @@ SystemHealth_monitor() { # That is THREE states, not just yes/no. if [ ! -f /var/run/ipmiservicelogd.pid0 ]; then - ocf_log debug "ipmiservicelogd is not running!" - return $OCF_NOT_RUNNING + ocf_log debug "ipmiservicelogd is not running!" + return $OCF_NOT_RUNNING fi ps -p "$(cat /var/run/ipmiservicelogd.pid0)" >/dev/null 2>&1 RC=$? if [ $RC != 0 ]; then - ocf_log debug "ipmiservicelogd's pid `cat /var/run/ipmiservicelogd.pid0` is not running!" + ocf_log debug "ipmiservicelogd's pid `cat /var/run/ipmiservicelogd.pid0` is not running!" - rm /var/run/ipmiservicelogd.pid0 + rm /var/run/ipmiservicelogd.pid0 - return $OCF_ERR_GENERIC + return $OCF_ERR_GENERIC fi servicelog_notify --list --command="$OCF_RESKEY_program" > /dev/null 2>&1 RC=$? if [ $RC = 0 ]; then - return $OCF_SUCCESS + return $OCF_SUCCESS else - return $OCF_NOT_RUNNING + return $OCF_NOT_RUNNING fi } @@ -193,7 +193,7 @@ SystemHealth_validate() { RC=$? if [ $RC != 0 ]; then - return $RC + return $RC fi return $OCF_SUCCESS @@ -202,35 +202,35 @@ SystemHealth_validate() { : ${OCF_RESKEY_program=/usr/sbin/notifyServicelogEvent} case $__OCF_ACTION in -meta-data) meta_data - exit $OCF_SUCCESS - ;; -usage|help) SystemHealth_usage - exit $OCF_SUCCESS - ;; +meta-data) meta_data + exit $OCF_SUCCESS + ;; +usage|help) SystemHealth_usage + exit $OCF_SUCCESS + ;; esac SystemHealth_check_tools RC=$? if [ $RC != 0 ]; then - case $__OCF_ACTION in - stop) exit $OCF_SUCCESS;; - *) exit $RC;; - esac + case $__OCF_ACTION in + stop) exit $OCF_SUCCESS;; + *) exit $RC;; + esac fi case $__OCF_ACTION in -start) SystemHealth_start;; -stop) SystemHealth_stop;; -monitor) SystemHealth_monitor;; -reload) ocf_log info "Reloading..." - SystemHealth_start - ;; -validate-all) ;; -*) SystemHealth_usage - exit $OCF_ERR_UNIMPLEMENTED - ;; +start) SystemHealth_start;; +stop) SystemHealth_stop;; +monitor) SystemHealth_monitor;; +reload) ocf_log info "Reloading..." + SystemHealth_start + ;; +validate-all) ;; +*) SystemHealth_usage + exit $OCF_ERR_UNIMPLEMENTED + ;; esac rc=$? ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc" diff --git a/extra/resources/o2cb.in b/extra/resources/o2cb.in index b71cc6f1a..db3ad1bae 100755 --- a/extra/resources/o2cb.in +++ b/extra/resources/o2cb.in @@ -3,7 +3,7 @@ # ocf:pacemaker:o2cb resource agent # # Original copyright 2005-2008 Oracle -# Later changes copyright 2008-2018 the Pacemaker project contributors +# Later changes copyright 2008-2019 the Pacemaker project contributors # # The version control history for this file may have further details. # @@ -118,7 +118,7 @@ status_daemon() { PID=`pidof "$DAEMON"` if [ -n "$PID" ]; then - return $OCF_SUCCESS + return $OCF_SUCCESS fi return $OCF_NOT_RUNNING } @@ -126,14 +126,14 @@ status_daemon() bringup_daemon() { if [ ! -e "$DAEMON" ]; then - ocf_log err "Required binary not found: $DAEMON" - return $OCF_ERR_INSTALLED + ocf_log err "Required binary not found: $DAEMON" + return $OCF_ERR_INSTALLED fi "$DAEMON"; rc=$? if [ $rc != 0 ]; then - ocf_log err "Could not start $DAEMON" - return $OCF_ERR_GENERIC + ocf_log err "Could not start $DAEMON" + return $OCF_ERR_GENERIC fi sleep 1 @@ -143,10 +143,10 @@ bringup_daemon() while [ $rc = $OCF_NOT_RUNNING ]; do COUNT=`expr $COUNT + 1` if [ $COUNT -gt $OCF_RESKEY_daemon_timeout ]; then - ocf_log err "`basename $DAEMON` did not come up" - return $OCF_ERR_GENERIC + ocf_log err "`basename $DAEMON` did not come up" + return $OCF_ERR_GENERIC fi - status_daemon; rc=$? + status_daemon; rc=$? sleep 1 done @@ -157,7 +157,7 @@ kill_daemon() { status_daemon; rc=$? if [ $rc != $OCF_SUCCESS ]; then - return $rc + return $rc fi ocf_log info "Stopping `basename "$DAEMON"`" @@ -165,7 +165,7 @@ kill_daemon() while [ $rc = $OCF_NOT_RUNNING ]; do sleep 1 - status_daemon; rc=$? + status_daemon; rc=$? done return $OCF_SUCCESS @@ -179,7 +179,7 @@ unload_module() { if [ "$#" -lt "1" -o -z "$1" ] then - ocf_log err "unload_module(): Requires an argument" + ocf_log err "unload_module(): Requires an argument" return 1 fi MODNAME="$1" @@ -197,14 +197,14 @@ unload_module() return 2 ;; *) - ocf_log err "Invalid module parsing!" + ocf_log err "Invalid module parsing!" return 1 ;; esac modprobe -rs "$MODNAME" if [ "$?" != 0 ]; then - ocf_log err "Unable to unload module \"$MODNAME\"" + ocf_log err "Unable to unload module \"$MODNAME\"" return 1 fi @@ -215,53 +215,53 @@ o2cb_start() { o2cb_monitor; rc=$? if [ $rc != $OCF_NOT_RUNNING ]; then - return $rc + return $rc fi ocf_log info "Starting $OCF_RESOURCE_INSTANCE" if [ ! -e "$CLUSTER_STACK_FILE" ]; then - modprobe -s ocfs2_stackglue - if [ $? != 0 ]; then - ocf_log err "Could not load ocfs2_stackglue" - return $OCF_ERR_INSTALLED - fi + modprobe -s ocfs2_stackglue + if [ $? != 0 ]; then + ocf_log err "Could not load ocfs2_stackglue" + return $OCF_ERR_INSTALLED + fi fi SP_OUT="$(awk '/^'user'$/{print; exit}' "$LOADED_PLUGINS_FILE" 2>/dev/null)" if [ -z "$SP_OUT" ] then modprobe -s ocfs2_stack_user - if [ $? != 0 ]; then - ocf_log err "Could not load ocfs2_stack_user" - return $OCF_ERR_INSTALLED - fi + if [ $? != 0 ]; then + ocf_log err "Could not load ocfs2_stack_user" + return $OCF_ERR_INSTALLED + fi fi SP_OUT="$(awk '/^'user'$/{print; exit}' "$LOADED_PLUGINS_FILE" 2>/dev/null)" if [ -z "$SP_OUT" ]; then - ocf_log err "Switch to userspace stack unsuccessful" - return $OCF_ERR_INSTALLED + ocf_log err "Switch to userspace stack unsuccessful" + return $OCF_ERR_INSTALLED fi if [ -f "$CLUSTER_STACK_FILE" ]; then echo "$OCF_RESKEY_stack" >"$CLUSTER_STACK_FILE" if [ $? != 0 ]; then - ocf_log err "Userspace stack '$OCF_RESKEY_stack' not supported" - return $OCF_ERR_INSTALLED - fi + ocf_log err "Userspace stack '$OCF_RESKEY_stack' not supported" + return $OCF_ERR_INSTALLED + fi else - ocf_log err "Switch to userspace stack not supported" - return $OCF_ERR_INSTALLED + ocf_log err "Switch to userspace stack not supported" + return $OCF_ERR_INSTALLED fi driver_filesystem ocfs2; rc=$? if [ $rc != 0 ]; then - modprobe -s ocfs2 - if [ "$?" != 0 ]; then + modprobe -s ocfs2 + if [ "$?" != 0 ]; then ocf_log err "Unable to load ocfs2 module" return $OCF_ERR_INSTALLED - fi + fi fi bringup_daemon @@ -271,7 +271,7 @@ o2cb_start() { o2cb_stop() { o2cb_monitor; rc=$? case $rc in - $OCF_NOT_RUNNING) return $OCF_SUCCESS;; + $OCF_NOT_RUNNING) return $OCF_SUCCESS;; esac ocf_log info "Stopping $OCF_RESOURCE_INSTANCE" @@ -279,13 +279,13 @@ o2cb_stop() { kill_daemon if [ $? != 0 ]; then ocf_log err "Unable to unload modules: the cluster is still online" - return $OCF_ERR_GENERIC + return $OCF_ERR_GENERIC fi unload_filesystem ocfs2 if [ $? = 1 ]; then - ocf_log err "Unable to unload ocfs2 module" - return $OCF_ERR_GENERIC + ocf_log err "Unable to unload ocfs2 module" + return $OCF_ERR_GENERIC fi # If we can't find the stack glue, we have nothing to do. @@ -295,15 +295,15 @@ o2cb_stop() { do unload_module "ocfs2_stack_${plugin}" if [ $? = 1 ]; then - ocf_log err "Unable to unload ocfs2_stack_${plugin}" - return $OCF_ERR_GENERIC - fi + ocf_log err "Unable to unload ocfs2_stack_${plugin}" + return $OCF_ERR_GENERIC + fi done <"$LOADED_PLUGINS_FILE" unload_module "ocfs2_stackglue" if [ $? = 1 ]; then - ocf_log err "Unable to unload ocfs2_stackglue" - return $OCF_ERR_GENERIC + ocf_log err "Unable to unload ocfs2_stackglue" + return $OCF_ERR_GENERIC fi # Don't unmount configfs - it's always in use by libdlm @@ -316,31 +316,31 @@ o2cb_monitor() { driver_filesystem configfs; rc=$? if [ $rc != 0 ]; then - ocf_log info "configfs not loaded" - return $OCF_NOT_RUNNING + ocf_log info "configfs not loaded" + return $OCF_NOT_RUNNING fi check_filesystem configfs "${OCF_RESKEY_configfs}"; rc=$? if [ $rc != 0 ]; then - ocf_log info "configfs not mounted" - return $OCF_NOT_RUNNING + ocf_log info "configfs not mounted" + return $OCF_NOT_RUNNING fi if [ ! -e "$LOADED_PLUGINS_FILE" ]; then - ocf_log info "Stack glue driver not loaded" - return $OCF_NOT_RUNNING + ocf_log info "Stack glue driver not loaded" + return $OCF_NOT_RUNNING fi grep user "$LOADED_PLUGINS_FILE" >/dev/null 2>&1; rc=$? if [ $rc != 0 ]; then - ocf_log err "Wrong stack `cat $LOADED_PLUGINS_FILE`" - return $OCF_ERR_INSTALLED + ocf_log err "Wrong stack `cat $LOADED_PLUGINS_FILE`" + return $OCF_ERR_INSTALLED fi driver_filesystem ocfs2; rc=$? if [ $rc != 0 ]; then - ocf_log info "ocfs2 not loaded" - return $OCF_NOT_RUNNING + ocf_log info "ocfs2 not loaded" + return $OCF_NOT_RUNNING fi status_daemon @@ -357,17 +357,17 @@ o2cb_validate() { check_binary ${DAEMON} case ${OCF_RESKEY_CRM_meta_globally_unique} in - yes|Yes|true|True|1) - ocf_log err "$OCF_RESOURCE_INSTANCE must be configured with the globally_unique=false meta attribute" - exit $OCF_ERR_CONFIGURED - ;; + yes|Yes|true|True|1) + ocf_log err "$OCF_RESOURCE_INSTANCE must be configured with the globally_unique=false meta attribute" + exit $OCF_ERR_CONFIGURED + ;; esac return $OCF_SUCCESS } meta_data() { - cat <<END + cat <<END <?xml version="1.0"?> <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd"> <resource-agent name="o2cb" version="1.0"> @@ -423,23 +423,23 @@ END } case $__OCF_ACTION in -meta-data) meta_data - exit $OCF_SUCCESS - ;; -start) o2cb_start - ;; -stop) o2cb_stop - ;; -monitor) o2cb_monitor - ;; -validate-all) o2cb_validate - ;; -usage|help) o2cb_usage - exit $OCF_SUCCESS - ;; -*) o2cb_usage - exit $OCF_ERR_UNIMPLEMENTED - ;; +meta-data) meta_data + exit $OCF_SUCCESS + ;; +start) o2cb_start + ;; +stop) o2cb_stop + ;; +monitor) o2cb_monitor + ;; +validate-all) o2cb_validate + ;; +usage|help) o2cb_usage + exit $OCF_SUCCESS + ;; +*) o2cb_usage + exit $OCF_ERR_UNIMPLEMENTED + ;; esac exit $? diff --git a/extra/resources/ping b/extra/resources/ping index 81c76868c..19d383915 100755 --- a/extra/resources/ping +++ b/extra/resources/ping @@ -2,7 +2,7 @@ # # ocf:pacemaker:ping resource agent # -# Copyright 2009-2018 the Pacemaker project contributors +# Copyright 2009-2019 the Pacemaker project contributors # # The version control history for this file may have further details. # @@ -20,7 +20,7 @@ ####################################################################### meta_data() { - cat <<END + cat <<END <?xml version="1.0"?> <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd"> <resource-agent name="ping" version="1.0"> @@ -139,12 +139,12 @@ END ping_conditional_log() { level=$1; shift if [ ${OCF_RESKEY_debug} = "true" ]; then - ocf_log $level "$*" + ocf_log $level "$*" fi } ping_usage() { - cat <<END + cat <<END usage: $0 {start|stop|monitor|validate-all|meta-data} Expects to have a fully populated OCF RA-compliant environment set. @@ -154,7 +154,7 @@ END ping_start() { ping_monitor if [ $? = $OCF_SUCCESS ]; then - return $OCF_SUCCESS + return $OCF_SUCCESS fi touch ${OCF_RESKEY_pidfile} ping_update @@ -162,7 +162,7 @@ ping_start() { ping_stop() { - rm -f ${OCF_RESKEY_pidfile} + rm -f ${OCF_RESKEY_pidfile} attrd_updater -D -n $OCF_RESKEY_name -d $OCF_RESKEY_dampen $attrd_options @@ -171,7 +171,7 @@ ping_stop() { ping_monitor() { if [ -f ${OCF_RESKEY_pidfile} ]; then - ping_update + ping_update if [ $? -eq 0 ]; then return $OCF_SUCCESS fi @@ -185,21 +185,21 @@ ping_validate() { state_dir=`dirname "$OCF_RESKEY_pidfile"` touch "$state_dir/$$" if [ $? != 0 ]; then - ocf_log err "Invalid location for 'state': $state_dir is not writable" - return $OCF_ERR_ARGS + ocf_log err "Invalid location for 'state': $state_dir is not writable" + return $OCF_ERR_ARGS fi rm "$state_dir/$$" # Pidfile better be an absolute path case $OCF_RESKEY_pidfile in - /*) ;; - *) ocf_log warn "You should use an absolute path for pidfile not: $OCF_RESKEY_pidfile" ;; + /*) ;; + *) ocf_log warn "You should use an absolute path for pidfile not: $OCF_RESKEY_pidfile" ;; esac # Check the host list if [ "x" = "x$OCF_RESKEY_host_list" ]; then - ocf_log err "Empty host_list. Please specify some nodes to ping" - exit $OCF_ERR_CONFIGURED + ocf_log err "Empty host_list. Please specify some nodes to ping" + exit $OCF_ERR_CONFIGURED fi # For fping allow only same IP versions or hostnames @@ -234,16 +234,16 @@ fping_check() { active=`echo "$output" | grep "is alive" | wc -l` case $rc in - 0) - ;; - 1) - for h in `echo "$output" | grep "is unreachable" | awk '{print $1}'`; do - ping_conditional_log warn "$h is inactive" - done - ;; - *) - ocf_log err "Unexpected result for '$cmd' $rc: `echo "$output" | tr '\n' ';'`" - ;; + 0) + ;; + 1) + for h in `echo "$output" | grep "is unreachable" | awk '{print $1}'`; do + ping_conditional_log warn "$h is inactive" + done + ;; + *) + ocf_log err "Unexpected result for '$cmd' $rc: `echo "$output" | tr '\n' ';'`" + ;; esac return $active @@ -252,26 +252,26 @@ fping_check() { ping_check() { active=0 for host in $OCF_RESKEY_host_list; do - p_exe=ping - - case `uname` in - Linux) p_args="-n -q -W $OCF_RESKEY_timeout -c $OCF_RESKEY_attempts";; - Darwin) p_args="-n -q -t $OCF_RESKEY_timeout -c $OCF_RESKEY_attempts -o";; - FreeBSD) p_args="-n -q -t $OCF_RESKEY_timeout -c $OCF_RESKEY_attempts -o";; - *) ocf_log err "Unknown host type: `uname`"; exit $OCF_ERR_INSTALLED;; - esac - - case $host in - *:*) p_exe=ping6 - esac - - p_out=`$p_exe $p_args $OCF_RESKEY_options $host 2>&1`; rc=$? - - case $rc in - 0) active=`expr $active + 1`;; - 1) ping_conditional_log warn "$host is inactive: $p_out";; - *) ocf_log err "Unexpected result for '$p_exe $p_args $OCF_RESKEY_options $host' $rc: $p_out";; - esac + p_exe=ping + + case `uname` in + Linux) p_args="-n -q -W $OCF_RESKEY_timeout -c $OCF_RESKEY_attempts";; + Darwin) p_args="-n -q -t $OCF_RESKEY_timeout -c $OCF_RESKEY_attempts -o";; + FreeBSD) p_args="-n -q -t $OCF_RESKEY_timeout -c $OCF_RESKEY_attempts -o";; + *) ocf_log err "Unknown host type: `uname`"; exit $OCF_ERR_INSTALLED;; + esac + + case $host in + *:*) p_exe=ping6 + esac + + p_out=`$p_exe $p_args $OCF_RESKEY_options $host 2>&1`; rc=$? + + case $rc in + 0) active=`expr $active + 1`;; + 1) ping_conditional_log warn "$host is inactive: $p_out";; + *) ocf_log err "Unexpected result for '$p_exe $p_args $OCF_RESKEY_options $host' $rc: $p_out";; + esac done return $active } @@ -279,11 +279,11 @@ ping_check() { ping_update() { if use_fping; then - fping_check - active=$? + fping_check + active=$? else - ping_check - active=$? + ping_check + active=$? fi score=`expr $active \* $OCF_RESKEY_multiplier` @@ -294,8 +294,8 @@ ping_update() { fi rc=$? case $rc in - 0) ping_conditional_log debug "Updated $OCF_RESKEY_name = $score" ;; - *) ocf_log warn "Could not update $OCF_RESKEY_name = $score: rc=$rc";; + 0) ping_conditional_log debug "Updated $OCF_RESKEY_name = $score" ;; + *) ocf_log warn "Could not update $OCF_RESKEY_name = $score: rc=$rc";; esac if [ $rc -ne 0 ]; then return $rc @@ -318,9 +318,9 @@ use_fping() { # 0 indefinite (i.e. hostname) host_family() { case $1 in - *[0-9].*[0-9].*[0-9].*[0-9]) return 4 ;; - *:*) return 6 ;; - *) return 0 ;; + *[0-9].*[0-9].*[0-9].*[0-9]) return 4 ;; + *:*) return 6 ;; + *) return 0 ;; esac } @@ -362,11 +362,11 @@ esac if [ -z ${OCF_RESKEY_timeout} ]; then if [ x"$OCF_RESKEY_host_list" != x ]; then - host_count=`echo $OCF_RESKEY_host_list | awk '{print NF}'` - OCF_RESKEY_timeout=`expr $OCF_RESKEY_CRM_meta_timeout / $host_count / $OCF_RESKEY_attempts` - OCF_RESKEY_timeout=`expr $OCF_RESKEY_timeout / 1100` # Convert to seconds and finish 10% early + host_count=`echo $OCF_RESKEY_host_list | awk '{print NF}'` + OCF_RESKEY_timeout=`expr $OCF_RESKEY_CRM_meta_timeout / $host_count / $OCF_RESKEY_attempts` + OCF_RESKEY_timeout=`expr $OCF_RESKEY_timeout / 1100` # Convert to seconds and finish 10% early else - OCF_RESKEY_timeout=5 + OCF_RESKEY_timeout=5 fi fi @@ -399,19 +399,18 @@ if [ ${OCF_RESKEY_debug} = "true" ]; then fi case $__OCF_ACTION in -meta-data) meta_data - exit $OCF_SUCCESS - ;; -start) ping_start;; -stop) ping_stop;; -monitor) ping_monitor;; -validate-all) ping_validate;; -usage|help) ping_usage - exit $OCF_SUCCESS - ;; -*) ping_usage - exit $OCF_ERR_UNIMPLEMENTED - ;; +meta-data) meta_data + exit $OCF_SUCCESS + ;; +start) ping_start;; +stop) ping_stop;; +monitor) ping_monitor;; +validate-all) ping_validate;; +usage|help) ping_usage + exit $OCF_SUCCESS + ;; +*) ping_usage + exit $OCF_ERR_UNIMPLEMENTED + ;; esac exit $? - diff --git a/extra/resources/pingd b/extra/resources/pingd index 7649bd360..468429768 100755 --- a/extra/resources/pingd +++ b/extra/resources/pingd @@ -2,7 +2,7 @@ # # ocf:pacemaker:pingd resource agent # -# Copyright 2006-2018 the Pacemaker project contributors +# Copyright 2006-2019 the Pacemaker project contributors # # The version control history for this file may have further details. # @@ -11,8 +11,8 @@ # # -# Records (in the CIB) the current number of ping nodes a -# cluster node can connect to. +# Records (in the CIB) the current number of ping nodes a cluster node can +# connect to. # ####################################################################### # Initialization: @@ -31,36 +31,36 @@ upgrade3="You will need to remove the existing resource and replace it with one case $__OCF_ACTION in start|monitor) - if [ "x" != "x$OCF_RESKEY_host_list" ]; then - ocf_log err "$upgrade1" - ocf_log err "$upgrade2" - ocf_log err "Automatic conversion to ocf:pacemaker:ping failed: no hosts were configured to check for connectivity" - ocf_log err "$upgrade3" - exit $OCF_ERR_ARGS - fi - - recurring=`crm configure show $OCF_RESOURCE_INSTANCE | grep "op monitor.*interval=\"[1-9]" | sed s/.*interval=// | awk -F\" '{print $2}' | sed s/.*interval=// | awk -F\" '{print $2}' | sort | head -n 1` - - if [ -z $recurring ]; then - ocf_log err "$upgrade1" - ocf_log err "$upgrade2" - ocf_log err "Automatic conversion to ocf:pacemaker:ping failed: no monitor operation configured" - ocf_log err "Without an explicit monitor operation for '$OCF_RESOURCE_INSTANCE', connectivity changes will not be noticed" - ocf_log err "Preventing startup to ensure the issue is addressed before it matters" - exit $OCF_ERR_ARGS - fi - - if [ $OCF_RESKEY_CRM_meta_interval = 0 ]; then - ocf_log warn "$upgrade1" - ocf_log warn "$upgrade2" - if [ $recurring != $OCF_RESKEY_interval ]; then - ocf_log warn "Your monitor operation happens every $recurring, which means that the $OCF_RESKEY_name attribute will be updated with a different frequency than the previously configured ( $OCF_RESKEY_interval )" - ocf_log warn "Either change the monitor interval to match or, ideally, switch to the ocf:pacemaker:ping agent and avoid all this compatibility nonsense." - fi - fi - ;; + if [ "x" != "x$OCF_RESKEY_host_list" ]; then + ocf_log err "$upgrade1" + ocf_log err "$upgrade2" + ocf_log err "Automatic conversion to ocf:pacemaker:ping failed: no hosts were configured to check for connectivity" + ocf_log err "$upgrade3" + exit $OCF_ERR_ARGS + fi + + recurring=`crm configure show $OCF_RESOURCE_INSTANCE | grep "op monitor.*interval=\"[1-9]" | sed s/.*interval=// | awk -F\" '{print $2}' | sed s/.*interval=// | awk -F\" '{print $2}' | sort | head -n 1` + + if [ -z $recurring ]; then + ocf_log err "$upgrade1" + ocf_log err "$upgrade2" + ocf_log err "Automatic conversion to ocf:pacemaker:ping failed: no monitor operation configured" + ocf_log err "Without an explicit monitor operation for '$OCF_RESOURCE_INSTANCE', connectivity changes will not be noticed" + ocf_log err "Preventing startup to ensure the issue is addressed before it matters" + exit $OCF_ERR_ARGS + fi + + if [ $OCF_RESKEY_CRM_meta_interval = 0 ]; then + ocf_log warn "$upgrade1" + ocf_log warn "$upgrade2" + if [ $recurring != $OCF_RESKEY_interval ]; then + ocf_log warn "Your monitor operation happens every $recurring, which means that the $OCF_RESKEY_name attribute will be updated with a different frequency than the previously configured ( $OCF_RESKEY_interval )" + ocf_log warn "Either change the monitor interval to match or, ideally, switch to the ocf:pacemaker:ping agent and avoid all this compatibility nonsense." + fi + fi + ;; meta-data) - cat <<END + cat <<END <?xml version="1.0"?> <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd"> <resource-agent name="pingd" version="1.0"> @@ -179,8 +179,8 @@ A catch all for any other options that need to be passed to pingd. </actions> </resource-agent> END - exit $OCF_SUCCESS - ;; + exit $OCF_SUCCESS + ;; esac ${OCF_ROOT}/resource.d/pacemaker/ping $1 diff --git a/extra/resources/remote b/extra/resources/remote index aa85b9ab5..9112bbfcd 100755 --- a/extra/resources/remote +++ b/extra/resources/remote @@ -2,7 +2,7 @@ # # ocf:pacemaker:remote OCF resource agent # -# Copyright 2013-2018 the Pacemaker project contributors +# Copyright 2013-2019 the Pacemaker project contributors # # The version control history for this file may have further details. # @@ -26,7 +26,7 @@ ####################################################################### meta_data() { - cat <<END + cat <<END <?xml version="1.0"?> <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd"> <resource-agent name="remote" version="0.1"> @@ -76,7 +76,7 @@ END ####################################################################### remote_usage() { - cat <<END + cat <<END usage: $0 {meta-data} Expects to have a fully populated OCF RA-compliant environment set. @@ -84,27 +84,27 @@ END } remote_unsupported() { - ocf_log info "The ocf:pacemaker:remote agent should not be directly invoked except for meta-data action" - return $OCF_ERR_GENERIC + ocf_log info "The ocf:pacemaker:remote agent should not be directly invoked except for meta-data action" + return $OCF_ERR_GENERIC } case $__OCF_ACTION in -meta-data) meta_data - exit $OCF_SUCCESS - ;; -start) remote_unsupported;; -stop) remote_unsupported;; -monitor) remote_unsupported;; -migrate_to) remote_unsupported;; -migrate_from) remote_unsupported;; -reload) remote_unsupported;; -validate-all) remote_unsupported;; -usage|help) remote_usage - exit $OCF_SUCCESS - ;; -*) remote_usage - exit $OCF_ERR_UNIMPLEMENTED - ;; +meta-data) meta_data + exit $OCF_SUCCESS + ;; +start) remote_unsupported;; +stop) remote_unsupported;; +monitor) remote_unsupported;; +migrate_to) remote_unsupported;; +migrate_from) remote_unsupported;; +reload) remote_unsupported;; +validate-all) remote_unsupported;; +usage|help) remote_usage + exit $OCF_SUCCESS + ;; +*) remote_usage + exit $OCF_ERR_UNIMPLEMENTED + ;; esac rc=$? ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc" -- 2.26.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor