The ha_get_info() and ha_get_info_debug()functions read resource information. $1 is the resource type and $2 is the resource name, and $3 is an optional parameter of any value that specifies a request for resource dependency information . Resource information is stored in the HA_STRING variable. The return value of the query is passed back to the caller, 0 indicates success. All errors are logged. If the resourceQuery command fails, the HA_STRING is set to an invalid string, and future calls to ha_get_info() or ha_get_info_debug() return errors.
The function ha_get_info_debug() differs from ha_get_info in that it will attempt the resource query a single time, instead of retrying as ha_get_info() would do. This is likely to be useful for testing due to faster returns and less complexity. You can call this function directly, or you can create the file /var/run/failsafe/resourceQuery.debug which will cause all invocations of ha_get_info() in all scripts on the node to be diverted to ha_get_info_debug() until the file is removed.
ha_get_info()
{
if [ -f /var/run/failsafe/resourceQuery.debug ]; then
ha_get_info_debug $1 $2 $3
return;
fi
if [ -n "$3" ]; then
ha_doall="_ALL=true"
else
ha_doall=""
fi
# Retry resourceQuery command $HA_RETRY_CMD_MAX times if $HA_RETRY_CMD_ERR
# is returned.
ha_retry_count=1
while [ $ha_retry_count -le $HA_RETRY_CMD_MAX ];
do
if [ -n "${HA_CLUSTERNAME}" ]; then
HA_STRING=`${HA_PRIVCMDSPATH}/${HA_RESOURCEQUERYCMD} \
_CDB_DB=$HA_CDB _RESOURCE=$2 _RESOURCE_TYPE=$1 \
$ha_doall _NO_LOGGING=true _CLUSTER=${HA_CLUSTERNAME}`
else
HA_STRING=`${HA_PRIVCMDSPATH}/${HA_RESOURCEQUERYCMD} \
_CDB_DB=$HA_CDB _RESOURCE=$2 _RESOURCE_TYPE=$1 \
$ha_doall _NO_LOGGING=true`
fi
ha_exit_code=$?
if [ $ha_exit_code -ne 0 ]; then
${HA_LOG} "${HA_RESOURCEQUERYCMD}: resource name $2 resource type $1"
${HA_LOG} "Failed with error: ${HA_STRING}";
fi
if [ $ha_exit_code -ne $HA_RETRY_CMD_ERR ]; then
break;
fi
ha_retry_count=`expr $ha_retry_count + 1`
done
if [ -n "$ha_doall" ]; then
echo $HA_STRING \
| grep "No resource dependencies" > /dev/null 2>&1
if [ $? -eq 0 ]; then
HA_STRING=
else
HA_STRING=`echo $HA_STRING | /bin/sed -e "s/^.*Resource dependencies
//"`
fi
fi
return ${ha_exit_code};
}
ha_get_info_debug()
{
if [ -n "$3" ]; then
ha_doall="_ALL=true"
else
ha_doall=""
fi
if [ -n "${HA_CLUSTERNAME}" ]; then
HA_STRING=`${HA_PRIVCMDSPATH}/${HA_RESOURCEQUERYCMD} \
_CDB_DB=$HA_CDB _RESOURCE=$2 _RESOURCE_TYPE=$1 \
$ha_doall _CLUSTER=${HA_CLUSTERNAME}`
else
HA_STRING=`${HA_PRIVCMDSPATH}/${HA_RESOURCEQUERYCMD} \
_CDB_DB=$HA_CDB _RESOURCE=$2 _RESOURCE_TYPE=$1 $ha_doall`
fi
ha_exit_code=$?
if [ $? -ne 0 ]; then
${HA_LOG} "${HA_RESOURCEQUERYCMD}: resource name $2 resource type $1"
${HA_LOG} "Failed with error: ${HA_STRING}";
fi
if [ -n "$ha_doall" ]; then
echo $HA_STRING \
| grep "No resource dependencies" > /dev/null 2>&1
if [ $? -eq 0 ]; then
HA_STRING=
else
HA_STRING=`echo $HA_STRING | /bin/sed -e "s/^.*Resource dependencies
//"`
fi
fi
return ${ha_exit_code};
} |