<!-- Fragment document type declaration subset:
ArborText, Inc., 1988-1997, v.4001
<!DOCTYPE SET PUBLIC "-//Davenport//DTD DocBook V3.0//EN" [
<!ENTITY scriptlib.sgml SYSTEM "scriptlib.sgml">
<!ENTITY startgui.sgml SYSTEM "startgui.sgml">
<!ENTITY preface.sgml SYSTEM "preface.sgml">
<!ENTITY overview.sgml SYSTEM "overview.sgml">
<!ENTITY action.sgml SYSTEM "action.sgml">
<!ENTITY failover.sgml SYSTEM "failover.sgml">
<!ENTITY database.sgml SYSTEM "database.sgml">
<!ENTITY install.sgml SYSTEM "install.sgml">
<!ENTITY gloss.sgml SYSTEM "gloss.sgml">
<!ENTITY index.sgml SYSTEM "index.sgml">
<!ENTITY monitor SYSTEM "figures/monitor.eps" NDATA eps>
<!ENTITY resource.ai SYSTEM "figures/resource.ai.eps" NDATA eps>
<!ENTITY optional.ai SYSTEM "figures/optional.ai.eps" NDATA eps>
<!ENTITY manager.ai SYSTEM "figures/manager.ai.eps" NDATA eps>
<!ENTITY depend.ai SYSTEM "figures/depend.ai.eps" NDATA eps>
<!ENTITY type.ai SYSTEM "figures/type.ai.eps" NDATA eps>
<!ENTITY attrib.ai SYSTEM "figures/attrib.ai.eps" NDATA eps>
<!ENTITY action.ai SYSTEM "figures/action.ai.eps" NDATA eps>
<!ENTITY star.configuration SYSTEM "figures/star.configuration.eps" NDATA eps>
<!ENTITY n.plus.2.configuration SYSTEM "figures/n.plus.2.configuration.eps" NDATA eps>
<!ENTITY square.configuration SYSTEM "figures/square.configuration.eps" NDATA eps>
]>
-->
<appendix id="Z944252972lhj">
<title>Using the SRM Script Library</title>
<para>The <filename>/usr/lib/failsafe/common_scripts/scriptlib</filename>
file contains the library of environment variables (beginning with uppercase <literal>
HA_</literal>) and functions (beginning with lowercase <literal>ha_</literal>)
available for use in your action scripts. <indexterm id="ITscriptlib-0"><primary>
script library</primary></indexterm> <indexterm id="ITscriptlib-1"><primary><literal>
scriptlib</literal> file</primary></indexterm></para>
<note>
<para>Do not change the contents of the <filename>scriptlib</filename> file.
</para>
</note>
<para>This chapter describes functions that perform the following tasks, using
samples from the <filename>scriptlib</filename> file:</para>
<itemizedlist>
<listitem><para>Linux FailSafe application interfaces</para>
</listitem>
<listitem><para>Set global definitions</para>
</listitem>
<listitem><para>Check arguments</para>
</listitem>
<listitem><para>Read an input file</para>
</listitem>
<listitem><para>Execute a command</para>
</listitem>
<listitem><para>Write status for a resource</para>
</listitem>
<listitem><para>Get the value for a field</para>
</listitem>
<listitem><para>Get resource information</para>
</listitem>
<listitem><para>Print exclusivity check messages</para>
</listitem>
</itemizedlist>
<sect1>
<title>Linux FailSafe application interfaces</title>
<para>The Linux FailSafe application interface identifies resources by two
strings: <itemizedlist>
<listitem><para>Resource name</para>
</listitem>
<listitem><para>Resource type</para>
</listitem>
</itemizedlist></para>
<para>For example, a resource named <literal>vol1</literal> of resource type <literal>
volumes</literal> is identified by the following: <literal>vol1 volumes</literal>.
</para>
<para>Using the script library simplifies interaction with the interface.
If you do not use the script library, you must understand the following file
formats used by action scripts:</para>
<itemizedlist>
<listitem><para>Input file, which contains the list of resources that must
be acted on by the executable; each resource must be specified on a separate
line in the file. SRMD can also pass action flags for each resource in the
input file. The format of a line in the input file is as follows (fields separated
by white space): </para>
<literallayout><replaceable>resource_name action_flags</replaceable></literallayout>
</listitem>
<listitem><para>Output file, in which the executable writes the return the
status of the each resource on a separate line using the following format
(fields separated by white space): </para>
<literallayout><replaceable>resource_name resource_status</replaceable></literallayout>
</listitem>
<listitem><para>(optional) Input parameters file, which contains the name
of the cluster:</para>
<literallayout>ClusterName <replaceable>clustername</replaceable></literallayout>
</listitem>
</itemizedlist>
<para> The following codes are defined in <?Pub _nolinebreak><literal>/usr/lib/failsafe/common_scripts/scriptlib
</literal><?Pub /_nolinebreak><?Pub Caret>: </para>
<itemizedlist>
<listitem><para><literal>HA_SUCCESS</literal></para>
</listitem>
<listitem><para><literal>HA_NOT_RUNNING</literal></para>
</listitem>
<listitem><para><literal>HA_INVAL_ARGS</literal></para>
</listitem>
<listitem><para><literal>HA_CMD_FAILED</literal></para>
</listitem>
<listitem><para><literal>HA_RUNNING</literal></para>
</listitem>
<listitem><para><literal>HA_NOTSUPPORTED</literal></para>
</listitem>
<listitem><para><literal>HA_NOCFGINFO</literal></para>
</listitem>
</itemizedlist>
</sect1>
<sect1>
<title>Set Global Definitions</title>
<para>The <command>ha_set_global_defs()</command> function sets the global
definitions for the environment variables<indexterm id="ITscriptlib-2"><primary>
environment variables</primary></indexterm> shown in this section. <indexterm
id="ITscriptlib-3"><primary>global definition setting</primary></indexterm>
</para>
<para>The <literal>HA_INFILE</literal> and <literal>HA_OUTFILE</literal> variables
set the input and output files for a script. These variables do not have global
definitions, and are not set by the <command>ha_set_global_defs()</command>
function.</para>
<sect2>
<title>Global Variable</title>
<sect3>
<title><literal>HA_HOSTNAME</literal></title>
<para>The output of the <literal>uname</literal> command with the <command>
-n</command> option, which is the host name or nodename. The nodename is the
name by which the system is known to communications networks. <indexterm id="ITscriptlib-4">
<primary>HA_HOSTNAME environment variable</primary></indexterm></para>
<para>Default: <filename>`uname -n`</filename></para>
</sect3>
</sect2>
<sect2>
<title>Command Location Variables</title>
<sect3>
<title><literal>HA_CMDSPATH</literal></title>
<para>Path to user commands.<indexterm id="ITscriptlib-5"><primary>HA_CMDSPATH
environment variable</primary></indexterm> <indexterm id="ITscriptlib-6">
<primary>path to user commands</primary></indexterm> <indexterm id="ITscriptlib-7">
<primary>command path</primary></indexterm> <indexterm id="ITscriptlib-8">
<primary>user command path</primary></indexterm> <indexterm id="ITscriptlib-9">
<primary><literal>uname</literal> command</primary></indexterm> <indexterm
id="ITscriptlib-10"><primary>hostname</primary></indexterm> <indexterm id="ITscriptlib-11">
<primary>nodename output</primary></indexterm></para>
<para>Default: <filename>/usr/lib/failsafe/bin</filename></para>
</sect3>
<sect3>
<title><literal>HA_PRIVCMDSPATH</literal></title>
<para>Path to privileged commands (those that can only be run by <literal>
root</literal>).<indexterm id="ITscriptlib-12"><primary>HA_PRIVCMDSPATH environment
variable</primary></indexterm> <indexterm id="ITscriptlib-13"><primary>privileged
command path</primary></indexterm> <indexterm id="ITscriptlib-14"><primary>
root command path</primary></indexterm></para>
<para>Default: <filename>/usr/lib/sysadm/privbin</filename></para>
</sect3>
<sect3>
<title><literal>HA_LOGCMD</literal></title>
<para>Command used to log information.<indexterm id="ITscriptlib-15"><primary>
HA_LOGCMD environment variable</primary></indexterm></para>
<para>Default: <filename>ha_cilog</filename></para>
</sect3>
<sect3>
<title><literal>HA_RESOURCEQUERYCMD</literal></title>
<para>Resource query command. This is an internal command that is not meant
for direct use in scripts; use the <command>ha_get_info()</command> function
of <literal>scriptlib</literal> instead.<indexterm id="ITscriptlib-16"><primary>
HA_RESOURCEQUERYCMD environment variable</primary></indexterm> <indexterm
id="ITscriptlib-17"><primary>resource</primary><secondary>query command</secondary>
</indexterm></para>
<para>Default: <filename>resourceQuery</filename></para>
</sect3>
<sect3>
<title><literal>HA_SCRIPTTMPDIR</literal></title>
<para>Location of the script temporary directory.<indexterm id="ITscriptlib-18">
<primary>HA_SCRIPTTMPDIR environment variable</primary></indexterm></para>
<para>Default: <filename>/var/run/failsafe/tmp</filename></para>
</sect3>
</sect2>
<sect2><?Pub Dtl>
<title>Database Location Variables</title>
<sect3>
<title><literal>HA_CDB</literal></title>
<para>Location of the cluster configuration database.<indexterm id="ITscriptlib-19">
<primary>HA_CDB environment variable</primary></indexterm> <indexterm id="ITscriptlib-20">
<primary>database location</primary></indexterm></para>
<para>Default: <filename>/var/lib/failsafe/cdb/cdb.db</filename></para>
</sect3>
</sect2>
<sect2><?Pub Dtl>
<title>Script Log Level Variables</title>
<sect3>
<title><literal>HA_NORMLVL</literal></title>
<para>Normal level of script logs. <indexterm id="ITscriptlib-25"><primary>
HA_NORMLVL environment variable</primary></indexterm></para>
<para>Default: 1</para>
</sect3>
<sect3>
<title><literal>HA_DBGLVL</literal></title>
<para>Debug level of script logs.<indexterm id="ITscriptlib-26"><primary>
HA_DBGLVL environment variable</primary></indexterm></para>
<para>Default: 10</para>
</sect3>
</sect2>
<sect2><?Pub Dtl>
<title>Script Log Variables</title>
<sect3>
<title><literal>HA_SCRIPTGROUP</literal></title>
<para>Log for the script group. <indexterm id="ITscriptlib-21"><primary>HA_SCRIPTGROUP
environment variable</primary></indexterm> <indexterm id="ITscriptlib-22">
<primary>script group log</primary></indexterm></para>
<para>Default: <filename>ha_script</filename></para>
</sect3>
<sect3>
<title><literal>HA_SCRIPTSUBSYS</literal></title>
<para>Log for the script subsystem.<indexterm id="ITscriptlib-23"><primary>
HA_SCRIPTSUBSYS environment variable</primary></indexterm> <indexterm id="ITscriptlib-24">
<primary>logs</primary></indexterm></para>
<para>Default:<filename>script</filename></para>
</sect3>
</sect2>
<sect2>
<title>Script Logging Command Variables</title>
<sect3>
<title><literal>HA_DBGLOG</literal></title>
<para>Command used to log debug messages from the scripts.<indexterm id="ITscriptlib-28">
<primary>HA_DBGLOG environment variable</primary></indexterm> <indexterm id="ITscriptlib-29">
<primary>debug script messages</primary></indexterm></para>
<para>Default: <literal>ha_dbglog</literal></para>
</sect3>
<sect3>
<title><literal>HA_CURRENT_LOGLEVEL</literal></title>
<para>The value of the current logging level. <literal>ha_log</literal> will
only output messages if this value is greater than or equal to <literal>HA_NORMLVL
</literal>. <literal>ha_dbglog</literal> will only output messages if this
value is greater than or equal to <literal>HA_DBGLVL</literal>.</para>
<para>Default: 2<indexterm id="ITscriptlib-30"><primary>HA_CURRENT_LOGLEVEL
environment variable</primary></indexterm></para>
</sect3>
<sect3>
<title><literal>HA_LOG</literal></title>
<para></para>
<para>Command used to log the scripts.<indexterm id="ITscriptlib-31"><primary>
HA_LOG environment variable</primary></indexterm></para>
<para>Default: <literal>ha_log</literal></para>
</sect3>
</sect2>
<sect2>
<title>Script Error Value Variables</title>
<sect3>
<title><literal>HA_SUCCESS</literal></title>
<para>Successful execution of the script. This variable is used by the <literal>
start</literal>, <literal>stop</literal>, <literal>restart</literal>, and <literal>
monitor</literal> scripts. <indexterm id="ITscriptlib-32"><primary>HA_SUCCESS
environment variable</primary></indexterm></para>
<para>Default: 0</para>
</sect3>
<sect3>
<title><literal>HA_NOT_RUNNING</literal></title>
<para>The script is not running. This variable is used by <literal>exclusive
</literal> scripts.<indexterm id="ITscriptlib-33"><primary>HA_NOT_RUNNING
environment variable</primary></indexterm></para>
<para>Default: 0</para>
</sect3>
<sect3>
<title><literal>HA_INVAL_ARGS</literal></title>
<para><indexterm id="ITscriptlib-34"><primary>HA_INVAL_ARGS environment variable
</primary></indexterm></para>
<para>An invalid argument was entered. This is used by all scripts.</para>
<para>Default: 1</para>
</sect3>
<sect3>
<title><literal>HA_CMD_FAILED</literal></title>
<para>A command called by the script has failed. his variable is used by the <literal>
start</literal>, <literal>stop</literal>, <literal>restart</literal>, and <literal>
monitor</literal>, scripts.<indexterm id="ITscriptlib-35"><primary>HA_CMD_FAILED
environment variable</primary></indexterm></para>
<para>Default: 2</para>
</sect3>
<sect3>
<title><literal>HA_RUNNING</literal></title>
<para>The script is running. This variable is used by <literal>exclusive</literal>
scripts.<indexterm id="ITscriptlib-36"><primary>HA_RUNNING environment variable
</primary></indexterm> </para>
<para>Default: 2</para>
</sect3>
<sect3>
<title><literal>HA_NOTSUPPORTED</literal></title>
<para></para>
<para>The specific action is not supported for this resource type. This is
used by all scripts.<indexterm id="ITscriptlib-37"><primary>HA_NOTSUPPORTED
environment variable</primary></indexterm> </para>
<para>Default: 3</para>
</sect3>
<sect3>
<title><literal>HA_NOCFGINFO</literal></title>
<para>No configuration information was found. This is used by all scripts.<indexterm
id="ITscriptlib-38"><primary>HA_NOCFGINFO environment variable</primary></indexterm></para>
<para>Default: 4</para>
</sect3>
</sect2>
</sect1>
<sect1><?Pub Dtl>
<title>Check Arguments</title>
<para>An action script has the following arguments: an input file, <literal>
HA_INFILE</literal>, an output file <literal>HA_OUTFILE</literal>, and an
optional parameter file <literal>HA_PARAMFILE</literal>. These become the
positional arguments to the script, <literal>$1</literal>, <literal>$2</literal>
and <literal>$3</literal> parameter file is optional. <indexterm id="ITscriptlib-39">
<primary>check arguments</primary></indexterm></para>
<para>The <indexterm id="ITscriptlib-40"><primary><literal>ha_check_args()
</literal> function</primary></indexterm> <literal>ha_check_args()</literal>
function checks the arguments specified for a script and sets the <literal>
$HA_INFILE</literal> and <literal>$HA_OUTFILE</literal> variables accordingly.
</para>
<para>If a parameter file exists, the <literal>ha_check_args()</literal> function
reads the list of parameters from the file and sets the <literal>$HA_CLUSTERNAME
</literal> variable. </para>
<para>In the following, long lines use the continuation character (<literal>
\</literal>) for readability.</para>
<programlisting>ha_check_args()
{
${HA_DBGLOG} "$HA_SCRIPTNAME called with $1, $2 and $3"
if ! [ $# -eq 2 -o $# -eq 3 ]; then
${HA_LOG} "Incorrect number of arguments"
return 1;
fi
if [ ! -r $1 ]; then
${HA_LOG} "file $1 is not readable or does not exist"
return 1;
fi
if [ ! -s $1 ]; then
${HA_LOG} "file $1 is empty"
return 1;
fi
if [ $# -eq 3 ]; then
HA_PARAMFILE=$3
if [ ! -r $3 ]; then
${HA_LOG} "file $3 is not readable or does not exist"
return 1;
fi
HA_CLUSTERNAME=`/usr/bin/awk '{ if ( $1 == "ClusterName" ) \
print $2 }' ${HA_PARAMFILE}`
fi
HA_INFILE=$1
HA_OUTFILE=$2
return 0;
}</programlisting>
</sect1>
<sect1><?Pub Dtl>
<title>Read an Input File</title>
<para><indexterm id="ITscriptlib-41"><primary>read an input file</primary>
</indexterm> <indexterm id="ITscriptlib-42"><primary>input file</primary>
</indexterm><indexterm id="ITscriptlib-43"><primary><literal>ha_read_infile()
</literal> function</primary></indexterm>The <command>ha_read_infile()</command>
function reads the <filename>$HA_INFILE</filename> input file into the <literal>
$HA_RES_NAMES</literal> variable, which specifies the list of resource names.
</para>
<programlisting>ha_read_infile()
{
HA_RES_NAMES="";
for HA_RESOURCE in `cat ${HA_INFILE}`
do
HA_RES_NAMES="${HA_RES_NAMES} ${HA_RESOURCE}";
done
}</programlisting>
</sect1>
<sect1>
<title>Execute a Command</title>
<para><indexterm id="ITscriptlib-44"><primary>execute a command</primary>
</indexterm><indexterm id="ITscriptlib-45"><primary><literal>ha_execute_cmd()
</literal> function</primary></indexterm> <indexterm id="ITscriptlib-46">
<primary>command execution function</primary></indexterm>The <literal>ha_execute_cmd()
</literal> function executes the command specified by <literal>$HA_CMD</literal>,
which is set in the action script. <literal>$1</literal> is the string to
be logged. The function returns 1 on error and 0 on success. On errors, the
standard output and standard error of the command is redirected to the log
file.</para>
<programlisting>ha_execute_cmd()
{
OUTFILE=${HA_SCRIPTTMPDIR}/script.$$
${HA_DBGLOG} $1
eval ${HA_CMD} > ${OUTFILE} 2>&1;
ha_exit_code=$?;
if [ $ha_exit_code -ne 0 ]; then
${HA_LOG} "$1 failed"
${HA_LOG} `cat ${HA_SCRIPTTMPDIR}/script.$$`
fi
${HA_DBGLOG} "${HA_CMD} exited with status $ha_exit_code";
rm ${OUTFILE}
return $ha_exit_code;
}</programlisting>
<para><indexterm id="ITscriptlib-47"><primary><literal>ha_execute_cmd_ret()
</literal> function</primary></indexterm>The <literal>ha_execute_cmd_ret()
</literal> function is similar to <literal>ha_execute_cmd</literal>, except
that it places the command output in the string <literal>$HA_CMD_OUTPUT</literal>.
</para>
<programlisting>ha_execute_cmd_ret()
{
${HA_DBGLOG} $1
HA_CMD_OUTPUT=`${HA_CMD}`;
ha_exit_code=$?;
${HA_DBGLOG} "${HA_CMD} exited with status $ha_exit_code";
return $ha_exit_code;
}</programlisting>
</sect1>
<sect1>
<title>Write Status for a Resource</title>
<para><indexterm id="ITscriptlib-48"><primary>write status for a resource
</primary></indexterm><indexterm id="ITscriptlib-49"><primary><literal>ha_write_status_for_resource()
</literal> function</primary></indexterm>The <command>ha_write_status_for_resource()
</command> function writes the status for a resource to the <literal>$HA_OUTFILE
</literal> output file. <literal>$1</literal> is the resource name, and <literal>
$2</literal> is the resource status.</para>
<programlisting>ha_write_status_for_resource()
{
echo $1 $2 >> $HA_OUTFILE;
}</programlisting>
<para><indexterm id="ITscriptlib-50"><primary><literal>ha_write_status_for_all_resources()
</literal> function</primary></indexterm>Similarly, the <command>ha_write_status_for_all_resources()
</command> function writes the status for all resources. <literal>$HA_RES_NAMES
</literal> is the list of resource names.</para>
<programlisting>ha_write_status_for_all_resources()
{
for HA_RES in $HA_RES_NAMES
do
echo $HA_RES $1 >> $HA_OUTFILE;
done
}</programlisting>
</sect1>
<sect1>
<title>Get the Value for a Field</title>
<para><indexterm id="ITscriptlib-51"><primary>value for a field</primary>
</indexterm> <indexterm id="ITscriptlib-52"><primary>field value</primary>
</indexterm><indexterm id="ITscriptlib-53"><primary><literal>ha_get_field()
</literal> function</primary></indexterm>The <literal>ha_get_field()</literal>
function obtains the field value from a string, where <literal>$1</literal>
is the string and <literal>$2</literal> is the field name. The string format
is a series of name-value field pairs, where a name field is followed by the
value of the name, separated by whitespace. This appears as follows:</para>
<programlisting>ha_get_field()
{
HA_STR=$1
HA_FIELD_NAME=$2
ha_found=0;
ha_field=1;
for ha_i in $HA_STR
do
if [ $ha_field -eq 1 ]; then
ha_field=0;
if [ $ha_i = $HA_FIELD_NAME ]; then
ha_found=1;
fi
else
ha_field=1;
if [ $ha_found -eq 1 ]; then
HA_FIELD_VALUE=$ha_i
return 0;
fi
fi
done
return 1;
}</programlisting>
</sect1>
<sect1>
<title>Get the Value for Multiple Fields</title>
<para>The <literal>ha_get_multi_fields()</literal> function obtains the field
values from a string, where <literal>$1</literal> is the string and <literal>
$2</literal> is the field name. The string format is a series of name-value
field pairs, where a name field is followed by the value of the name, separated
by whitespace. </para>
<para>This function is typically used to extract dependency information.
There may be multiple fields with the same name so the string returned in <literal>
HA_FIELD_VALUE</literal> may contain multiple values separated by white space.
This appears as follows: <programlisting>ha_get_multi_fields()
{
HA_STR=$1
HA_FIELD_NAME=$2
ha_found=0;
ha_field=1;
for ha_i in $HA_STR
do
if [ $ha_field -eq 1 ]; then
ha_field=0;
if [ $ha_i = $HA_FIELD_NAME ]; then
ha_found=1;
fi
else
ha_field=1;
if [ $ha_found -eq 1 ]; then
if [ -z "$HA_FIELD_VALUE" ]; then
HA_FIELD_VALUE=$ha_i;
else
HA_FIELD_VALUE="$HA_FIELD_VALUE $ha_i";
fi;
ha_found=0;
fi
fi
done
if [ -z "$HA_FIELD_VALUE" ]; then
return 1;
else
return 0;
fi
}</programlisting></para>
</sect1>
<sect1>
<title>Get Resource Information</title>
<para><indexterm id="ITscriptlib-54"><primary>resource information</primary>
<secondary>obtaining</secondary></indexterm><indexterm id="ITscriptlib-55">
<primary><literal>ha_get_info()</literal> function</primary></indexterm>The <literal>
ha_get_info()</literal> and <literal>ha_get_info_debug()</literal>functions
read resource information. <literal>$1</literal> is the resource type and <literal>
$2</literal> is the resource name, and <literal>$3</literal> is an optional
parameter of any value that specifies a request for resource dependency information
. Resource information is stored in the <literal>HA_STRING</literal> variable.
The return value of the query is passed back to the caller, 0 indicates success.
All errors are logged. If the <literal>resourceQuery</literal> command fails,
the <literal>HA_STRING</literal> is set to an invalid string, and future calls
to <literal>ha_get_info()</literal> or <literal>ha_get_info_debug()</literal>
return errors.</para>
<para>The function <literal>ha_get_info_debug()</literal> differs from <literal>
ha_get_info</literal> in that it will attempt the resource query a single
time, instead of retrying as <literal>ha_get_info()</literal> 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 <filename>
/var/run/failsafe/resourceQuery.debug</filename> which will cause all invocations
of <literal>ha_get_info()</literal> in all scripts on the node to be diverted
to <literal>ha_get_info_debug()</literal> until the file is removed.</para>
<programlisting>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};
}</programlisting>
</sect1>
<sect1>
<title>Print Exclusivity Check Messages</title>
<para><indexterm id="ITscriptlib-56"><primary>print exclusivity check messages
</primary></indexterm><indexterm id="ITscriptlib-57"><primary><literal>ha_print_exclusive_status()
</literal> function</primary></indexterm>The <command>ha_print_exclusive_status()
</command> function prints exclusivity check messages to the log file. <literal>
$1</literal> is the resource name and <literal>$2</literal> is the exit status.
</para>
<programlisting>ha_print_exclusive_status()
{
if [ $? -eq $HA_NOT_RUNNING ]; then
${HA_LOG} "resource $1 exclusive status: NOT RUNNING"
else
${HA_LOG} "resource $1 exclusive status: RUNNING"
fi
}</programlisting>
<para><indexterm id="ITscriptlib-58"><primary><literal>ha_print_exclusive_status_all_resources()
</literal> function</primary></indexterm>The <command>ha_print_exclusive_status_all_resources()
</command> function is similar, but it prints exclusivity check messages for
all resources. <literal>$HA_RES_NAMES</literal> is the list of resource names.
</para>
<programlisting>ha_print_exclusive_status_all_resources()
{
for HA_RES in $HA_RES_NAMES
do
ha_print_exclusive_status ${HA_RES} $1
done
}</programlisting>
</sect1>
</appendix>
<?Pub *0000027175>