Page MenuHomeClusterLabs Projects

No OneTemporary

diff --git a/extra/resources/Dummy b/extra/resources/Dummy
index a344deac0b..56584e5647 100755
--- a/extra/resources/Dummy
+++ b/extra/resources/Dummy
@@ -1,324 +1,323 @@
#!/bin/sh
#
# ocf:pacemaker:Dummy resource agent
#
# Original copyright 2004 SUSE LINUX AG, Lars Marowsky-Br<E9>e
# Later changes copyright 2008-2021 the Pacemaker project contributors
#
# The version control history for this file may have further details.
#
# This source code is licensed under the GNU General Public License version 2
# (GPLv2) WITHOUT ANY WARRANTY.
#
# The Dummy agent is intended primarily for testing, and has various options to
# make actions intentionally fail or take a long time. It may also be used as a
# template for resource agent writers, in which case:
#
# - Replace all occurrences of "dummy" and "Dummy" with your agent name.
# - Update the meta-data appropriately for your agent, such as the description
# and supported options. Pay particular attention to the timeouts specified in
# the actions section; they should be meaningful for the kind of service the
# agent manages. They should be the minimum advised timeouts, but shouldn't
# try to cover _all_ possible instances. So, try to be neither overly generous
# nor too stingy, but moderate. The minimum timeouts should never be below 10
# seconds.
# - Don't copy the stuff here that is just for testing, such as the
# sigterm_handler() or dump_env().
# - You don't need the state file stuff here if you have a better way of
# determining whether your service is running. It's only useful for agents
# such as health agents that don't actually correspond to a running service.
# - Implement the actions appropriately for your service. Your monitor action
# must differentiate correctly between running, not running, and failed (that
# is THREE states, not just yes/no). The migrate_to, migrate_from, and reload
# actions are optional and not appropriate to all services.
#
#######################################################################
# Initialization:
: ${OCF_FUNCTIONS:="${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs"}
. "${OCF_FUNCTIONS}"
: ${__OCF_ACTION:="$1"}
# Explicitly list all environment variables used, to make static analysis happy
: ${OCF_RESKEY_fake:="dummy"}
: ${OCF_RESKEY_op_sleep:=0}
: ${OCF_RESKEY_CRM_meta_interval:=0}
: ${OCF_RESKEY_CRM_meta_globally_unique:="false"}
: ${OCF_RESKEY_envfile:=""}
: ${OCF_RESKEY_fail_start_on:=""}
: ${OCF_RESKEY_migrate_source:=""}
: ${OCF_RESKEY_migrate_target:=""}
: ${OCF_RESKEY_envfile:=""}
: ${OCF_RESKEY_state:=""}
#######################################################################
meta_data() {
cat <<END
<?xml version="1.0"?>
-<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
-<resource-agent name="Dummy" version="2.0">
+<resource-agent name="Dummy" version="2.1">
<version>1.1</version>
<longdesc lang="en">
This is a dummy OCF resource agent. It does absolutely nothing except keep track
of whether it is running or not, and can be configured so that actions fail or
take a long time. Its purpose is primarily for testing, and to serve as a
template for resource agent writers.
</longdesc>
<shortdesc lang="en">Example stateless resource agent</shortdesc>
<parameters>
<parameter name="state" unique-group="state">
<longdesc lang="en">
Location to store the resource state in.
</longdesc>
<shortdesc lang="en">State file</shortdesc>
<content type="string" default="${HA_VARRUN%%/}/Dummy-${OCF_RESOURCE_INSTANCE}.state" />
</parameter>
<parameter name="passwd" reloadable="1">
<longdesc lang="en">
Fake password field
</longdesc>
<shortdesc lang="en">Password</shortdesc>
<content type="string" default="" />
</parameter>
<parameter name="fake" reloadable="1">
<longdesc lang="en">
Fake attribute that can be changed to cause an agent reload
</longdesc>
<shortdesc lang="en">Fake attribute that can be changed to cause an agent reload</shortdesc>
<content type="string" default="dummy" />
</parameter>
<parameter name="op_sleep" reloadable="1">
<longdesc lang="en">
Number of seconds to sleep during operations. This can be used to test how
the cluster reacts to operation timeouts.
</longdesc>
<shortdesc lang="en">Operation sleep duration in seconds.</shortdesc>
<content type="string" default="0" />
</parameter>
<parameter name="fail_start_on" reloadable="1">
<longdesc lang="en">
Start, migrate_from, and reload-agent actions will return failure if running on
the host specified here, but the resource will run successfully anyway (future
monitor calls will find it running). This can be used to test on-fail=ignore.
</longdesc>
<shortdesc lang="en">Report bogus start failure on specified host</shortdesc>
<content type="string" default="" />
</parameter>
<parameter name="envfile" reloadable="1">
<longdesc lang="en">
If this is set, the environment will be dumped to this file for every call.
</longdesc>
<shortdesc lang="en">Environment dump file</shortdesc>
<content type="string" default="" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="20s" />
<action name="stop" timeout="20s" />
<action name="monitor" timeout="20s" interval="10s" depth="0"/>
<action name="reload" timeout="20s" />
<action name="reload-agent" timeout="20s" />
<action name="migrate_to" timeout="20s" />
<action name="migrate_from" timeout="20s" />
<action name="validate-all" timeout="20s" />
<action name="meta-data" timeout="5s" />
</actions>
</resource-agent>
END
}
#######################################################################
# don't exit on TERM, to test that pacemaker-execd makes sure that we do exit
trap sigterm_handler TERM
sigterm_handler() {
ocf_log info "They use TERM to bring us down. No such luck."
# Since we're likely going to get KILLed, clean up any monitor
# serialization in progress, so the next probe doesn't return an error.
rm -f "${VERIFY_SERIALIZED_FILE}"
return
}
dummy_usage() {
cat <<END
usage: $0 {start|stop|monitor|reload|reload-agent|migrate_to|migrate_from|validate-all|meta-data}
Expects to have a fully populated OCF RA-compliant environment set.
END
}
dump_env() {
if [ "${OCF_RESKEY_envfile}" != "" ]; then
echo "### ${__OCF_ACTION} @ $(date) ###
$(env | sort)
###" >> "${OCF_RESKEY_envfile}"
fi
}
dummy_start() {
dummy_monitor
DS_RETVAL=$?
if [ $DS_RETVAL -eq $OCF_SUCCESS ]; then
if [ "$(uname -n)" = "${OCF_RESKEY_fail_start_on}" ]; then
DS_RETVAL=$OCF_ERR_GENERIC
fi
return $DS_RETVAL
fi
touch "${OCF_RESKEY_state}"
DS_RETVAL=$?
if [ "$(uname -n)" = "${OCF_RESKEY_fail_start_on}" ]; then
DS_RETVAL=$OCF_ERR_GENERIC
fi
return $DS_RETVAL
}
dummy_stop() {
dummy_monitor --force
if [ $? -eq $OCF_SUCCESS ]; then
rm "${OCF_RESKEY_state}"
fi
rm -f "${VERIFY_SERIALIZED_FILE}"
return $OCF_SUCCESS
}
dummy_monitor() {
if [ $OCF_RESKEY_op_sleep -ne 0 ]; then
if [ "$1" = "" ] && [ -f "${VERIFY_SERIALIZED_FILE}" ]; then
# two monitor ops have occurred at the same time.
# This verifies a condition in pacemaker-execd regression tests.
ocf_log err "$VERIFY_SERIALIZED_FILE exists already"
ocf_exit_reason "alternate universe collision"
return $OCF_ERR_GENERIC
fi
touch "${VERIFY_SERIALIZED_FILE}"
sleep ${OCF_RESKEY_op_sleep}
rm "${VERIFY_SERIALIZED_FILE}"
fi
if [ -f "${OCF_RESKEY_state}" ]; then
# Multiple monitor levels are defined to support various tests
case "$OCF_CHECK_LEVEL" in
10)
# monitor level with delay, useful for testing timeouts
sleep 30
;;
20)
# monitor level that fails intermittently
n=$(expr "$(dd if=/dev/urandom bs=1 count=1 2>/dev/null | od | head -1 | cut -f2 -d' ')" % 5)
if [ $n -eq 1 ]; then
ocf_exit_reason "smoke detected near CPU fan"
return $OCF_ERR_GENERIC
fi
;;
30)
# monitor level that always fails
ocf_exit_reason "hyperdrive quota reached"
return $OCF_ERR_GENERIC
;;
40)
# monitor level that returns error code from state file
rc=$(cat ${OCF_RESKEY_state})
[ -n "$rc" ] && ocf_exit_reason "CPU ejected. Observed leaving the Kronosnet galaxy at $rc times the speed of light." && return $rc
;;
*)
;;
esac
return $OCF_SUCCESS
fi
return $OCF_NOT_RUNNING
}
dummy_validate() {
# If specified, is op_sleep an integer?
case "$OCF_RESKEY_op_sleep" in
""|*[0-9]*) ;;
*) return $OCF_ERR_CONFIGURED ;;
esac
# Host-specific checks
if [ "$OCF_CHECK_LEVEL" = "10" ]; then
# Is the state directory writable?
state_dir=$(dirname "$OCF_RESKEY_state")
[ -d "$state_dir" ] && [ -w "$state_dir" ] && [ -x "$state_dir" ]
if [ $? -ne 0 ]; then
return $OCF_ERR_ARGS
fi
# If specified, is the environment file directory writable?
if [ -n "$OCF_RESKEY_envfile" ]; then
envfile_dir=$(dirname "$OCF_RESKEY_envfile")
[ -d "$envfile_dir" ] && [ -w "$envfile_dir" ] && [ -x "$envfile_dir" ]
if [ $? -ne 0 ]; then
return $OCF_ERR_ARGS
fi
fi
fi
return $OCF_SUCCESS
}
if [ -z "$OCF_RESKEY_state" ]; then
OCF_RESKEY_state="${HA_VARRUN%%/}/Dummy-${OCF_RESOURCE_INSTANCE}.state"
if [ "${OCF_RESKEY_CRM_meta_globally_unique}" = "false" ]; then
# Strip off the trailing clone marker (note + is not portable in sed)
OCF_RESKEY_state=$(echo $OCF_RESKEY_state | sed s/:[0-9][0-9]*\.state/.state/)
fi
fi
VERIFY_SERIALIZED_FILE="${OCF_RESKEY_state}.serialized"
dump_env
case "$__OCF_ACTION" in
meta-data) meta_data
exit $OCF_SUCCESS
;;
start) dummy_start;;
stop) dummy_stop;;
monitor) dummy_monitor;;
migrate_to) ocf_log info "Migrating ${OCF_RESOURCE_INSTANCE} to ${OCF_RESKEY_CRM_meta_migrate_target}."
dummy_stop
;;
migrate_from) ocf_log info "Migrating ${OCF_RESOURCE_INSTANCE} from ${OCF_RESKEY_CRM_meta_migrate_source}."
dummy_start
;;
reload) ocf_log debug "Reloading $OCF_RESOURCE_INSTANCE (service)"
exit $OCF_SUCCESS
;;
reload-agent) ocf_log err "Reloading $OCF_RESOURCE_INSTANCE (agent)"
dummy_start
;;
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
# vim: set filetype=sh expandtab tabstop=4 softtabstop=4 shiftwidth=4 textwidth=80:
diff --git a/extra/resources/HealthIOWait b/extra/resources/HealthIOWait
index 43a8b70c4d..5f1483ef74 100755
--- a/extra/resources/HealthIOWait
+++ b/extra/resources/HealthIOWait
@@ -1,198 +1,197 @@
#!/bin/sh
#
# ocf:pacemaker:HealthIOWait resource agent
#
# Copyright 2004-2021 the Pacemaker project contributors
#
# The version control history for this file may have further details.
#
# This source code is licensed under the GNU General Public License version 2
# (GPLv2) WITHOUT ANY WARRANTY.
#
#
# Measures CPU iowait % via top and writes #health-iowait status into the CIB
#
#######################################################################
# Initialization:
: ${OCF_FUNCTIONS:="${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs"}
. "${OCF_FUNCTIONS}"
: ${__OCF_ACTION:="$1"}
#######################################################################
meta_data() {
cat <<END
<?xml version="1.0"?>
-<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
-<resource-agent name="HealthIOWait" version="1.1">
+<resource-agent name="HealthIOWait" version="1.2">
<version>1.1</version>
<longdesc lang="en">
System health agent that measures the CPU iowait via top and updates the #health-iowait attribute.
</longdesc>
<shortdesc lang="en">System health based on CPU iowait measurement</shortdesc>
<parameters>
<parameter name="state" unique-group="state">
<longdesc lang="en">
Location to store the resource state in.
</longdesc>
<shortdesc lang="en">State file</shortdesc>
<content type="string" default="${HA_VARRUN%%/}/health-iowait-${OCF_RESOURCE_INSTANCE}.state" />
</parameter>
<parameter name="yellow_limit">
<longdesc lang="en">
Upper limit of iowait percentage to switch the health attribute to yellow. I.e.
the #health-iowait will go yellow if the %iowait of the CPU gets higher than 10%.
</longdesc>
<shortdesc lang="en">Upper limit for yellow health attribute</shortdesc>
<content type="integer" default="10"/>
</parameter>
<parameter name="red_limit">
<longdesc lang="en">
Upper limit of iowait percentage to switch the health attribute to red. I.e.
the #health-iowait will go red if the %iowait of the CPU get higher than 15%.
</longdesc>
<shortdesc lang="en">Upper limit for red health attribute</shortdesc>
<content type="integer" default="15"/>
</parameter>
</parameters>
<actions>
<action name="start" timeout="10s" />
<action name="stop" timeout="10s" />
<action name="monitor" timeout="10s" interval="10s" start-delay="0s" />
<action name="meta-data" timeout="5s" />
<action name="validate-all" timeout="10s" />
</actions>
</resource-agent>
END
}
#######################################################################
agent_usage() {
cat <<END
usage: $0 {start|stop|monitor|validate-all|meta-data}
Expects to have a fully populated OCF RA-compliant environment set.
END
}
agent_start() {
agent_monitor
if [ $? -eq $OCF_SUCCESS ]; then
return $OCF_SUCCESS
fi
touch "${OCF_RESKEY_state}"
}
agent_stop() {
agent_monitor
if [ $? -eq $OCF_SUCCESS ]; then
rm "${OCF_RESKEY_state}"
fi
return $OCF_SUCCESS
}
agent_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
WAIT=$(top -b -n2 | grep Cpu | tail -1 | awk -F",|.[0-9][ %]wa" '{ print $5 }')
# echo "System iowait: " $WAIT
# echo $OCF_RESKEY_yellow_limit
if [ $WAIT -gt ${OCF_RESKEY_red_limit} ] ; then
# echo "System state RED!"
attrd_updater -n "#health-iowait" -U "red" -d "5s"
return $OCF_SUCCESS
fi
if [ $WAIT -gt ${OCF_RESKEY_yellow_limit} ] ; then
# echo "System state yellow."
attrd_updater -n "#health-iowait" -U "yellow" -d "5s"
else
# echo "System state green."
attrd_updater -n "#health-iowait" -U "green" -d "5s"
fi
return $OCF_SUCCESS
fi
return $OCF_NOT_RUNNING
}
is_integer() {
case "$1" in
""|*[0-9]*) return 0 ;;
*) return 1 ;;
esac
}
is_writable_dir() {
dir=$(dirname "$1")
[ -d "$dir" ] && [ -w "$dir" ] && [ -x "$dir" ]
}
agent_validate() {
is_integer "$OCF_RESKEY_yellow_limit" && is_integer "$OCF_RESKEY_red_limit"
if [ $? -ne 0 ]; then
return $OCF_ERR_CONFIGURED
fi
if [ "$OCF_CHECK_LEVEL" = "10" ]; then
is_writable_dir "$OCF_RESKEY_state"
if [ $? -ne 0 ]; then
return $OCF_ERR_ARGS
fi
fi
return $OCF_SUCCESS
}
: ${OCF_RESKEY_CRM_meta_interval:=0}
: ${OCF_RESKEY_CRM_meta_globally_unique:="false"}
if [ -z "$OCF_RESKEY_state" ]; then
if [ "${OCF_RESKEY_CRM_meta_globally_unique}" = "false" ]; then
state="${HA_VARRUN%%/}/HealthIoWait-${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%%/}/HealthIoWait-${OCF_RESOURCE_INSTANCE}.state"
fi
fi
if [ -z "${OCF_RESKEY_red_limit}" ] ; then
OCF_RESKEY_red_limit=15
fi
if [ -z "${OCF_RESKEY_yellow_limit}" ] ; then
OCF_RESKEY_yellow_limit=10
fi
case $__OCF_ACTION in
meta-data) meta_data
exit $OCF_SUCCESS
;;
start) agent_start;;
stop) agent_stop;;
monitor) agent_monitor;;
validate-all) agent_validate;;
usage|help) agent_usage
exit $OCF_SUCCESS
;;
*) agent_usage
exit $OCF_ERR_UNIMPLEMENTED
;;
esac
rc=$?
ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"
exit $rc
# vim: set filetype=sh expandtab tabstop=4 softtabstop=4 shiftwidth=4 textwidth=80:
diff --git a/extra/resources/Stateful b/extra/resources/Stateful
index ae3424bbf1..0d2062d512 100755
--- a/extra/resources/Stateful
+++ b/extra/resources/Stateful
@@ -1,268 +1,267 @@
#!/bin/sh
#
# ocf:pacemaker:Stateful resource agent
#
# Copyright 2006-2021 the Pacemaker project contributors
#
# The version control history for this file may have further details.
#
# This source code is licensed under the GNU General Public License version 2
# or later (GPLv2+) WITHOUT ANY WARRANTY.
#
#
# Example of a stateful OCF Resource Agent
#
#######################################################################
# Initialization:
: ${OCF_FUNCTIONS:="${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs"}
. "${OCF_FUNCTIONS}"
: ${__OCF_ACTION:="$1"}
# Explicitly list all environment variables used, to make static analysis happy
: ${OCF_RESKEY_CRM_meta_interval:=0}
: ${OCF_RESKEY_CRM_meta_globally_unique:="false"}
: ${OCF_RESKEY_notify_delay:=0}
: ${OCF_RESKEY_envfile:=""}
: ${OCF_RESKEY_state:=""}
# Until we can assume the new name is available ...
: ${OCF_RUNNING_PROMOTED:=$OCF_RUNNING_MASTER}
SCORE_UNPROMOTED=5
SCORE_PROMOTED=10
#######################################################################
meta_data() {
cat <<END
<?xml version="1.0"?>
-<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
-<resource-agent name="Stateful" version="1.1">
+<resource-agent name="Stateful" version="1.2">
<version>1.1</version>
<longdesc lang="en">
This is an example resource agent that implements Promoted and Unpromoted roles
</longdesc>
<shortdesc lang="en">Example stateful resource agent</shortdesc>
<parameters>
<parameter name="state" unique-group="state">
<longdesc lang="en">
Location to store the resource state in
</longdesc>
<shortdesc lang="en">State file</shortdesc>
<content type="string" default="${HA_VARRUN%%/}/Stateful-${OCF_RESOURCE_INSTANCE}.state" />
</parameter>
<parameter name="envfile" reloadable="true">
<longdesc lang="en">
If this is set, the environment will be dumped to this file for every call.
</longdesc>
<shortdesc lang="en">Environment dump file</shortdesc>
<content type="string" default="" />
</parameter>
<parameter name="notify_delay" reloadable="true">
<longdesc lang="en">
The notify action will sleep for this many seconds before returning,
to simulate a long-running notify.
</longdesc>
<shortdesc lang="en">Notify delay in seconds</shortdesc>
<content type="string" default="" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="20s" />
<action name="stop" timeout="20s" />
<action name="monitor" depth="0" timeout="20s" interval="10s" role="Promoted"/>
<action name="monitor" depth="0" timeout="20s" interval="11s" role="Unpromoted"/>
<action name="promote" timeout="10s" />
<action name="demote" timeout="10s" />
<action name="notify" timeout="5s" />
<action name="meta-data" timeout="5s" />
<action name="reload-agent" timeout="10s" />
<action name="validate-all" timeout="30s" />
</actions>
</resource-agent>
END
exit $OCF_SUCCESS
}
#######################################################################
stateful_usage() {
cat <<END
Usage: $0 <action>
where <action> is one of: meta-data validate-all start stop monitor
promote demote notify reload-agent
This conforms to the OCF Resource Agent API version 1.1, and expects
to have OCF-compliant environment variables provided.
END
exit $1
}
stateful_update() {
echo $1 > "${OCF_RESKEY_state}"
}
stateful_check_state() {
target="$1"
if [ -f "${OCF_RESKEY_state}" ]; then
state=$(cat "${OCF_RESKEY_state}")
if [ "$target" = "$state" ]; then
return 0
fi
else
if [ -z "$target" ]; then
return 0
fi
fi
return 1
}
dump_env() {
if [ "${OCF_RESKEY_envfile}" != "" ]; then
echo "### ${__OCF_ACTION} @ $(date) ###
$(env | sort)
###" >> "${OCF_RESKEY_envfile}"
fi
}
set_promotion_score() {
"${HA_SBIN_DIR}/crm_attribute" --promotion -v "$1"
}
stateful_start() {
stateful_check_state Promoted
if [ $? -eq 0 ]; then
# CRM Error - Should never happen
return $OCF_RUNNING_PROMOTED
fi
stateful_update Unpromoted
set_promotion_score $SCORE_UNPROMOTED
return 0
}
stateful_demote() {
stateful_check_state
if [ $? -eq 0 ]; then
# CRM Error - Should never happen
return $OCF_NOT_RUNNING
fi
stateful_update Unpromoted
set_promotion_score $SCORE_UNPROMOTED
return 0
}
stateful_promote() {
stateful_check_state
if [ $? -eq 0 ]; then
return $OCF_NOT_RUNNING
fi
stateful_update Promoted
set_promotion_score $SCORE_PROMOTED
return 0
}
stateful_stop() {
"${HA_SBIN_DIR}/crm_attribute" --promotion -D
stateful_check_state Promoted
if [ $? -eq 0 ]; then
# CRM Error - Should never happen
return $OCF_RUNNING_PROMOTED
fi
if [ -f "${OCF_RESKEY_state}" ]; then
rm "${OCF_RESKEY_state}"
fi
return 0
}
stateful_monitor() {
# for testing
if [ -f "${OCF_RESKEY_state}.rc" ]; then
rc=$(cat "${OCF_RESKEY_state}.rc")
ocf_exit_reason "$rc GB redirected to /dev/null"
exit $rc
fi
stateful_check_state Promoted
if [ $? -eq 0 ]; then
if [ $OCF_RESKEY_CRM_meta_interval -eq 0 ]; then
# Restore the promotion score during probes
set_promotion_score $SCORE_PROMOTED
fi
return $OCF_RUNNING_PROMOTED
fi
stateful_check_state Unpromoted
if [ $? -eq 0 ]; then
if [ $OCF_RESKEY_CRM_meta_interval -eq 0 ]; then
# Restore the promotion score during probes
set_promotion_score $SCORE_UNPROMOTED
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
fi
return 7
}
stateful_notify() {
if [ "${OCF_RESKEY_notify_delay}" != "0" ]; then
sleep "${OCF_RESKEY_notify_delay}"
fi
return $OCF_SUCCESS
}
stateful_validate() {
exit $OCF_SUCCESS
}
stateful_reload_agent() {
return $OCF_SUCCESS
}
if [ -z "$OCF_RESKEY_state" ]; 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/)
else
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;;
notify) stateful_notify ;;
stop) stateful_stop;;
monitor) stateful_monitor;;
validate-all) stateful_validate;;
reload-agent) stateful_reload_agent;;
usage|help) stateful_usage $OCF_SUCCESS;;
*) stateful_usage $OCF_ERR_UNIMPLEMENTED;;
esac
exit $?
# vim: set filetype=sh expandtab tabstop=4 softtabstop=4 shiftwidth=4 textwidth=80:
diff --git a/extra/resources/attribute b/extra/resources/attribute
index 1800dff8f8..a2bd353e07 100755
--- a/extra/resources/attribute
+++ b/extra/resources/attribute
@@ -1,241 +1,240 @@
#!/bin/sh
#
# ocf:pacemaker:attribute resource agent
#
# Copyright 2016-2021 the Pacemaker project contributors
#
# The version control history for this file may have further details.
#
# This source code is licensed under the GNU General Public License version 2
# or later (GPLv2+) WITHOUT ANY WARRANTY.
#
USAGE="Usage: $0 {start|stop|monitor|migrate_to|migrate_from|validate-all|meta-data}
Expects to have a fully populated OCF RA-compliant environment set."
# Load OCF helper functions
: ${OCF_FUNCTIONS:="${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs"}
. "${OCF_FUNCTIONS}"
: ${__OCF_ACTION:="$1"}
# Ensure certain variables are set and not empty
: ${HA_VARRUN:="/var/run"}
: ${OCF_RESKEY_CRM_meta_globally_unique:="false"}
: ${OCF_RESOURCE_INSTANCE:="undef"}
DEFAULT_STATE_FILE="${HA_VARRUN%%/}/opa-${OCF_RESOURCE_INSTANCE}.state"
if [ "${OCF_RESKEY_CRM_meta_globally_unique}" = "false" ]; then
# Strip off any trailing clone marker (note + is not portable in sed)
DEFAULT_STATE_FILE=$(echo "$DEFAULT_STATE_FILE" | sed s/:[0-9][0-9]*\.state/.state/)
fi
DEFAULT_ATTR_NAME="opa-${OCF_RESOURCE_INSTANCE}"
DEFAULT_ACTIVE_VALUE="1"
DEFAULT_INACTIVE_VALUE="0"
: ${OCF_RESKEY_state:="$DEFAULT_STATE_FILE"}
: ${OCF_RESKEY_name:="$DEFAULT_ATTR_NAME"}
# If the user did not set a value, use the default. If the user explicitly set
# a value to the empty string, use that (-z "${V+x}" tests whether $V was set).
if [ -z "${OCF_RESKEY_active_value+x}" ]; then
OCF_RESKEY_active_value="$DEFAULT_ACTIVE_VALUE"
fi
if [ -z "${OCF_RESKEY_inactive_value+x}" ]; then
OCF_RESKEY_inactive_value="$DEFAULT_INACTIVE_VALUE"
fi
usage() {
USAGE_RC=$1
cat <<END
$USAGE
END
return $USAGE_RC
}
meta_data() {
cat <<END
<?xml version="1.0"?>
-<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
-<resource-agent name="attribute" version="1.1">
+<resource-agent name="attribute" version="1.2">
<version>1.1</version>
<shortdesc lang="en">Manages a node attribute</shortdesc>
<longdesc lang="en">
This resource agent controls a node attribute for the node it's running on.
It sets the attribute one way when started, and another way when stopped,
according to the configuration parameters.
</longdesc>
<parameters>
<parameter name="state" unique-group="state">
<longdesc lang="en">
Full path of a temporary file to store the resource state in
</longdesc>
<shortdesc lang="en">State file</shortdesc>
<content type="string" default="${DEFAULT_STATE_FILE}" />
</parameter>
<parameter name="name" unique-group="name">
<longdesc lang="en">
Name of node attribute to manage
</longdesc>
<shortdesc lang="en">Attribute name</shortdesc>
<content type="string" default="${DEFAULT_ATTR_NAME}" />
</parameter>
<parameter name="active_value">
<longdesc lang="en">
Value to use for node attribute when resource becomes active (empty string is
discouraged, because monitor cannot distinguish it from a query error)
</longdesc>
<shortdesc lang="en">Attribute value when active</shortdesc>
<content type="string" default="$DEFAULT_ACTIVE_VALUE" />
</parameter>
<parameter name="inactive_value">
<longdesc lang="en">
Value to use for node attribute when resource becomes inactive
</longdesc>
<shortdesc lang="en">Attribute value when inactive</shortdesc>
<content type="string" default="$DEFAULT_INACTIVE_VALUE" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="20s" />
<action name="stop" timeout="20s" />
<action name="monitor" timeout="20s" interval="10s" depth="0"/>
<action name="reload" timeout="20s" />
<action name="migrate_to" timeout="20s" />
<action name="migrate_from" timeout="20s" />
<action name="validate-all" timeout="20s" />
<action name="meta-data" timeout="5s" />
</actions>
</resource-agent>
END
return $OCF_SUCCESS
}
validate() {
# Host-specific checks
if [ "$OCF_CHECK_LEVEL" = "10" ]; then
VALIDATE_DIR=$(dirname "${OCF_RESKEY_state}")
if [ ! -d "$VALIDATE_DIR" ]; then
ocf_exit_reason "state file '$OCF_RESKEY_state' does not have a valid directory"
return $OCF_ERR_PERM
fi
if [ ! -w "$VALIDATE_DIR" ] || [ ! -x "$VALIDATE_DIR" ]; then
ocf_exit_reason "insufficient privileges on directory of state file '$OCF_RESKEY_state'"
return $OCF_ERR_PERM
fi
fi
if [ "$OCF_RESKEY_active_value" = "$OCF_RESKEY_inactive_value" ]; then
ocf_exit_reason "active value '%s' must be different from inactive value '%s'" \
"$OCF_RESKEY_active_value" "$OCF_RESKEY_inactive_value"
return $OCF_ERR_CONFIGURED
fi
return $OCF_SUCCESS
}
get_attribute() {
GET_LINE=$(attrd_updater -n "$OCF_RESKEY_name" -Q 2>/dev/null)
if [ $? -ne 0 ]; then
echo ""
else
echo "$GET_LINE" | sed -e "s/.* value=\"\(.*\)\"$/\1/"
fi
}
set_attribute() {
attrd_updater -n "$OCF_RESKEY_name" -U "$1" 2>/dev/null
# TODO if above call is async, loop until get_attribute returns expected value
}
check_attribute() {
CHECK_VALUE=$(get_attribute)
CHECK_REASON=""
if [ ! -f "$OCF_RESKEY_state" ]; then
if [ "$CHECK_VALUE" != "" ] && [ "$CHECK_VALUE" != "$OCF_RESKEY_inactive_value" ]; then
CHECK_REASON="Node attribute $OCF_RESKEY_name='$CHECK_VALUE' differs from expected value '$OCF_RESKEY_inactive_value'"
return $OCF_ERR_GENERIC
fi
return $OCF_NOT_RUNNING
fi
if [ "$CHECK_VALUE" != "$OCF_RESKEY_active_value" ]; then
CHECK_REASON="Node attribute $OCF_RESKEY_name='$CHECK_VALUE' differs from expected value '$OCF_RESKEY_active_value'"
return $OCF_ERR_GENERIC
fi
return $OCF_SUCCESS
}
monitor() {
check_attribute
MONITOR_RC=$?
if [ $MONITOR_RC -eq $OCF_ERR_GENERIC ]; then
ocf_exit_reason "$CHECK_REASON"
fi
return $MONITOR_RC
}
start() {
check_attribute
if [ $? -eq $OCF_SUCCESS ]; then
return $OCF_SUCCESS
fi
touch "${OCF_RESKEY_state}" 2>/dev/null
if [ $? -ne 0 ]; then
ocf_exit_reason "Unable to manage state file $OCF_RESKEY_state"
return $OCF_ERR_GENERIC
fi
set_attribute "${OCF_RESKEY_active_value}"
if [ $? -ne 0 ]; then
rm -f "${OCF_RESKEY_state}"
ocf_exit_reason "Unable to set node attribute $OCF_RESKEY_name='$OCF_RESKEY_active_value'"
return $OCF_ERR_GENERIC
fi
return $OCF_SUCCESS
}
stop() {
check_attribute
if [ $? -eq $OCF_NOT_RUNNING ]; then
return $OCF_SUCCESS
fi
rm -f ${OCF_RESKEY_state}
set_attribute "${OCF_RESKEY_inactive_value}"
if [ $? -ne 0 ]; then
ocf_exit_reason "Unable to set node attribute $OCF_RESKEY_name='$OCF_RESKEY_inactive_value'"
return $OCF_ERR_GENERIC
fi
return $OCF_SUCCESS
}
case $__OCF_ACTION in
meta-data) meta_data ;;
start) start ;;
stop) stop ;;
monitor) monitor ;;
# We don't do anything special for live migration, but we support it so that
# other resources that live migrate can depend on this one.
migrate_to) stop ;;
migrate_from) start ;;
reload) start ;;
validate-all) validate ;;
usage|help) usage $OCF_SUCCESS ;;
*) usage $OCF_ERR_UNIMPLEMENTED ;;
esac
exit $?
# vim: set filetype=sh expandtab tabstop=4 softtabstop=4 shiftwidth=4 textwidth=80:
diff --git a/extra/resources/ping b/extra/resources/ping
index 6e296979f1..7cc6b802d9 100755
--- a/extra/resources/ping
+++ b/extra/resources/ping
@@ -1,437 +1,436 @@
#!/bin/sh
#
# ocf:pacemaker:ping resource agent
#
# Copyright 2009-2021 the Pacemaker project contributors
#
# The version control history for this file may have further details.
#
# This source code is licensed under the GNU General Public License version 2
# or later (GPLv2+) WITHOUT ANY WARRANTY.
#
#######################################################################
# Initialization:
: ${OCF_FUNCTIONS:="${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs"}
. "${OCF_FUNCTIONS}"
: ${__OCF_ACTION:="$1"}
# Explicitly list all environment variables used, to make static analysis happy
: ${OCF_RESKEY_CRM_meta_timeout:="20000"}
: ${OCF_RESKEY_CRM_meta_globally_unique:="false"}
: ${OCF_RESKEY_name:="pingd"}
: ${OCF_RESKEY_dampen:="5s"}
: ${OCF_RESKEY_attempts:="3"}
: ${OCF_RESKEY_multiplier:="1"}
: ${OCF_RESKEY_debug:="0"}
: ${OCF_RESKEY_failure_score:="0"}
: ${OCF_RESKEY_use_fping:="1"}
: ${OCF_RESKEY_host_list:=""}
: ${OCF_RESKEY_options:=""}
: ${OCF_RESKEY_timeout:=""}
#######################################################################
meta_data() {
cat <<END
<?xml version="1.0"?>
-<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
-<resource-agent name="ping" version="1.1">
+<resource-agent name="ping" version="1.2">
<version>1.1</version>
<longdesc lang="en">
Every time the monitor action is run, this resource agent records (in the CIB) the current number of nodes the host can connect to using the system fping (preferred) or ping tool.
</longdesc>
<shortdesc lang="en">node connectivity</shortdesc>
<parameters>
<parameter name="pidfile" unique-group="pidfile">
<longdesc lang="en">PID file</longdesc>
<shortdesc lang="en">PID file</shortdesc>
<content type="string" default="${HA_VARRUN%%/}/ping-${OCF_RESOURCE_INSTANCE}" />
</parameter>
<parameter name="dampen" reloadable="1">
<longdesc lang="en">
The time to wait (dampening) further changes occur
</longdesc>
<shortdesc lang="en">Dampening interval</shortdesc>
<content type="integer" default="5s"/>
</parameter>
<parameter name="name" unique-group="name">
<longdesc lang="en">
The name of the attributes to set. This is the name to be used in the constraints.
</longdesc>
<shortdesc lang="en">Attribute name</shortdesc>
<content type="string" default="pingd"/>
</parameter>
<parameter name="multiplier">
<longdesc lang="en">
The number by which to multiply the number of connected ping nodes by
</longdesc>
<shortdesc lang="en">Value multiplier</shortdesc>
<content type="integer" default="1"/>
</parameter>
<parameter name="host_list" required="1">
<longdesc lang="en">
A space separated list of ping nodes to count.
</longdesc>
<shortdesc lang="en">Host list</shortdesc>
<content type="string" default=""/>
</parameter>
<parameter name="attempts" reloadable="1">
<longdesc lang="en">
Number of ping attempts, per host, before declaring it dead
</longdesc>
<shortdesc lang="en">no. of ping attempts</shortdesc>
<content type="integer" default="3"/>
</parameter>
<parameter name="timeout" reloadable="1">
<longdesc lang="en">
How long, in seconds, to wait before declaring a ping lost
</longdesc>
<shortdesc lang="en">ping timeout in seconds</shortdesc>
<content type="integer" default="2"/>
</parameter>
<parameter name="options">
<longdesc lang="en">
A catch all for any other options that need to be passed to ping.
</longdesc>
<shortdesc lang="en">Extra Options</shortdesc>
<content type="string" default=""/>
</parameter>
<parameter name="failure_score">
<longdesc lang="en">
Resource is failed if the score is less than failure_score.
Default never fails.
</longdesc>
<shortdesc lang="en">failure_score</shortdesc>
<content type="integer" default=""/>
</parameter>
<parameter name="use_fping">
<longdesc lang="en">
Use fping rather than ping, if found. If set to 0, fping
will not be used even if present.
</longdesc>
<shortdesc lang="en">Use fping if available</shortdesc>
<content type="boolean" default="1"/>
</parameter>
<parameter name="debug" reloadable="1">
<longdesc lang="en">
Enables to use default attrd_updater verbose logging on every call.
</longdesc>
<shortdesc lang="en">Verbose logging</shortdesc>
<content type="string" default="false"/>
</parameter>
</parameters>
<actions>
<action name="start" timeout="60s" />
<action name="stop" timeout="20s" />
<action name="monitor" depth="0" timeout="60s" interval="10s"/>
<action name="meta-data" timeout="5s" />
<action name="validate-all" timeout="30s" />
<action name="reload-agent" timeout="20s" />
</actions>
</resource-agent>
END
}
#######################################################################
ping_conditional_log() {
level="$1"; shift
if [ $OCF_RESKEY_debug -gt 0 ]; then
ocf_log "$level" "$*"
fi
}
ping_usage() {
cat <<END
usage: $0 {start|stop|monitor|validate-all|reload-agent|meta-data}
Expects to have a fully populated OCF RA-compliant environment set.
END
}
ping_start() {
ping_monitor
if [ $? -eq $OCF_SUCCESS ]; then
return $OCF_SUCCESS
fi
touch "${OCF_RESKEY_pidfile}"
ping_update
}
ping_stop() {
rm -f "${OCF_RESKEY_pidfile}"
attrd_updater -D -n "$OCF_RESKEY_name" -d "$OCF_RESKEY_dampen"
return $OCF_SUCCESS
}
ping_monitor() {
if [ -f "${OCF_RESKEY_pidfile}" ]; then
ping_update
if [ $? -eq 0 ]; then
return $OCF_SUCCESS
fi
return $OCF_ERR_GENERIC
fi
return $OCF_NOT_RUNNING
}
ping_validate() {
# Host-specific checks
if [ "$OCF_CHECK_LEVEL" = "10" ]; then
# Is the state directory writable?
state_dir=$(dirname "$OCF_RESKEY_pidfile")
touch "$state_dir/$$"
if [ $? -ne 0 ]; then
ocf_log err "Invalid location for 'state': $state_dir is not writable"
return $OCF_ERR_ARGS
fi
rm "$state_dir/$$"
# Does the ping binary exist?
check_binary ping
fi
# 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" ;;
esac
# Check the host list
if [ -z "$OCF_RESKEY_host_list" ]; then
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
if use_fping; then
hosts_family
if [ $? -eq 99 ]; then
ocf_log err "host_list can contain only host with same IP versions for fping"
exit $OCF_ERR_CONFIGURED
fi
fi
return $OCF_SUCCESS
}
ping_reload_agent() {
# No action required
:;
}
fping_check() {
p_exe=fping
hosts_family
case $? in
6) p_exe=fping6 ;;
99) ocf_log err "Ambiguous IP versions in host_list: '$OCF_RESKEY_host_list'"; exit $OCF_ERR_CONFIGURED;;
esac
active=0
timeout=$(expr $OCF_RESKEY_timeout \* 1000 / $OCF_RESKEY_attempts)
cmd="$p_exe -r $OCF_RESKEY_attempts -t $timeout -B 1.0 $OCF_RESKEY_options $OCF_RESKEY_host_list"
fping_output=$($cmd 2>&1); rc=$?
active=$(echo "$fping_output" | grep "is alive" | wc -l)
case $rc in
0)
if [ $OCF_RESKEY_debug -gt 1 ]; then
ping_conditional_log info "$fping_output"
fi
;;
1)
for h in $(echo "$fping_output" | grep "is unreachable" | awk '{print $1}'); do
ping_conditional_log warn "$h is inactive: $fping_output"
done
;;
*)
ocf_log err "Unexpected result for '$cmd' $rc: $(echo "$fping_output" | tr '\n' ';')"
;;
esac
return $active
}
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
ping_output=$($p_exe $p_args $OCF_RESKEY_options $host 2>&1); rc=$?
case $rc in
0)
active=$(expr $active + 1)
if [ $OCF_RESKEY_debug -gt 1 ]; then
ping_conditional_log info "$ping_output"
fi
;;
1) ping_conditional_log warn "$host is inactive: $ping_output";;
*) ocf_log err "Unexpected result for '$p_exe $p_args $OCF_RESKEY_options $host' $rc: $ping_output";;
esac
done
return $active
}
ping_update() {
if use_fping; then
fping_check
active=$?
else
ping_check
active=$?
fi
score=$(expr $active \* $OCF_RESKEY_multiplier)
if [ "$__OCF_ACTION" = "start" ] ; then
attrd_updater -n "$OCF_RESKEY_name" -B "$score" -d "$OCF_RESKEY_dampen"
else
attrd_updater -n "$OCF_RESKEY_name" -v "$score" -d "$OCF_RESKEY_dampen"
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";;
esac
if [ $rc -ne 0 ]; then
return $rc
fi
if [ -n "$OCF_RESKEY_failure_score" ] && [ "$score" -lt "$OCF_RESKEY_failure_score" ]; then
ocf_log warn "$OCF_RESKEY_name is less than failure_score($OCF_RESKEY_failure_score)"
return 1
fi
return 0
}
use_fping() {
ocf_is_true "$OCF_RESKEY_use_fping" && have_binary fping;
}
# return values:
# 4 IPv4
# 6 IPv6
# 0 indefinite (i.e. hostname)
host_family() {
case $1 in
*[0-9].*[0-9].*[0-9].*[0-9]) return 4 ;;
*:*) return 6 ;;
*) return 0 ;;
esac
}
# return values same as host_family plus
# 99 ambiguous families
hosts_family() {
# For fping allow only same IP versions or hostnames
family=0
for host in $OCF_RESKEY_host_list; do
host_family "$host"
f=$?
if [ $family -ne 0 ] && [ $f -ne 0 ] && [ $f -ne $family ] ; then
family=99
break
fi
[ $f -ne 0 ] && family=$f
done
return $family
}
integer=$(echo ${OCF_RESKEY_timeout} | egrep -o '[0-9]*')
case "${OCF_RESKEY_timeout}" in
*[0-9]ms|*[0-9]msec) OCF_RESKEY_timeout=$(expr $integer / 1000);;
*[0-9]m|*[0-9]min) OCF_RESKEY_timeout=$(expr $integer \* 60);;
*[0-9]h|*[0-9]hr) OCF_RESKEY_timeout=$(expr $integer \* 60 \* 60);;
*) OCF_RESKEY_timeout=$integer;;
esac
if [ -z "${OCF_RESKEY_timeout}" ]; then
if [ -n "$OCF_RESKEY_host_list" ]; 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
else
OCF_RESKEY_timeout=5
fi
fi
if [ ${OCF_RESKEY_timeout} -lt 1 ]; then
OCF_RESKEY_timeout=5
elif [ ${OCF_RESKEY_timeout} -gt 1000 ]; then
# ping actually complains if this value is too high, 5 minutes is plenty
OCF_RESKEY_timeout=300
fi
if [ "${OCF_RESKEY_CRM_meta_globally_unique}" = "false" ]; then
: ${OCF_RESKEY_pidfile:="${HA_VARRUN%%/}/ping-${OCF_RESKEY_name}"}
else
: ${OCF_RESKEY_pidfile:="${HA_VARRUN%%/}/ping-${OCF_RESOURCE_INSTANCE}"}
fi
# Check the debug option
case "${OCF_RESKEY_debug}" in
true|True|TRUE|1) OCF_RESKEY_debug=1;;
false|False|FALSE|0) OCF_RESKEY_debug=0;;
verbose|Verbose|VERBOSE|2) OCF_RESKEY_debug=2;;
*)
ocf_log warn "Value for 'debug' is incorrect. Please specify 'true', 'false', or 'verbose', not: ${OCF_RESKEY_debug}"
OCF_RESKEY_debug=false
;;
esac
case "$__OCF_ACTION" in
meta-data) meta_data
exit $OCF_SUCCESS
;;
start) ping_start;;
stop) ping_stop;;
monitor) ping_monitor;;
validate-all) ping_validate;;
reload-agent) ping_reload_agent;;
usage|help) ping_usage
exit $OCF_SUCCESS
;;
*) ping_usage
exit $OCF_ERR_UNIMPLEMENTED
;;
esac
exit $?
# vim: set filetype=sh expandtab tabstop=4 softtabstop=4 shiftwidth=4 textwidth=80:
diff --git a/extra/resources/remote b/extra/resources/remote
index a53262bb69..f7e40dc81d 100755
--- a/extra/resources/remote
+++ b/extra/resources/remote
@@ -1,107 +1,106 @@
#!/bin/sh
#
# ocf:pacemaker:remote OCF resource agent
#
# Copyright 2013-2021 the Pacemaker project contributors
#
# The version control history for this file may have further details.
#
# This source code is licensed under the GNU General Public License version 2
# (GPLv2) WITHOUT ANY WARRANTY.
#
# This script provides metadata for Pacemaker's internal remote agent.
# Outside of acting as a placeholder so the agent can be indexed, and
# providing metadata, this script should never be invoked. The actual
# functionality behind the remote connection lives within Pacemaker's
# controller daemon.
#
: ${OCF_FUNCTIONS:="${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs"}
. "${OCF_FUNCTIONS}"
: ${__OCF_ACTION:="$1"}
meta_data() {
cat <<END
<?xml version="1.0"?>
-<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
-<resource-agent name="remote" version="1.0">
+<resource-agent name="remote" version="1.1">
<version>1.1</version>
<shortdesc lang="en">Pacemaker Remote connection</shortdesc>
<parameters>
<parameter name="server" unique-group="address">
<longdesc lang="en">
Server location to connect to (IP address or resolvable host name)
</longdesc>
<shortdesc lang="en">Remote hostname</shortdesc>
<content type="string"/>
</parameter>
<parameter name="port" unique-group="address">
<longdesc lang="en">
TCP port at which to contact Pacemaker Remote executor
</longdesc>
<shortdesc lang="en">Remote port</shortdesc>
<content type="integer" default="3121"/>
</parameter>
<parameter name="reconnect_interval" reloadable="1">
<longdesc lang="en">
If this is a positive time interval, the cluster will attempt to
reconnect to a remote node after an active connection has been
lost at this interval. Otherwise, the cluster will attempt to
reconnect immediately (after any fencing needed).
</longdesc>
<shortdesc lang="en">reconnect interval</shortdesc>
<content type="string" default="0"/>
</parameter>
</parameters>
<actions>
<action name="start" timeout="60s" />
<action name="stop" timeout="60s" />
<action name="monitor" timeout="30s" />
<action name="migrate_to" timeout="60s" />
<action name="migrate_from" timeout="60s" />
<action name="reload" timeout="60s" />
<action name="reload-agent" timeout="60s" />
<action name="meta-data" timeout="5s" />
</actions>
</resource-agent>
END
return $OCF_SUCCESS
}
remote_usage() {
EXITSTATUS="$1"
cat <<END
Usage: $0 <action>
This conforms to the OCF Resource Agent API version 1.1, and expects
to have OCF-compliant environment variables provided.
END
return $EXITSTATUS
}
remote_unsupported() {
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 ;;
start) remote_unsupported ;;
stop) remote_unsupported ;;
monitor) remote_unsupported ;;
migrate_to) remote_unsupported ;;
migrate_from) remote_unsupported ;;
reload) remote_unsupported ;;
reload-agent) remote_unsupported ;;
validate-all) remote_unsupported ;;
usage|help) remote_usage $OCF_SUCCESS ;;
*) remote_usage $OCF_ERR_UNIMPLEMENTED ;;
esac
rc=$?
ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"
exit $rc
# vim: set filetype=sh expandtab tabstop=4 softtabstop=4 shiftwidth=4 textwidth=80:

File Metadata

Mime Type
text/x-diff
Expires
Sat, Nov 23, 4:48 PM (17 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1018967
Default Alt Text
(48 KB)

Event Timeline