Sun Cluster 3.0 12/01 Data Services Developer's Guide

Chapter 3 Resource Management API Reference

This chapter provides a reference to the access functions and callback methods that make up the Resource Management API (RMAPI). It lists and briefly describes each function and method. However, the definitive reference for these functions and methods is the Resource Management API man pages.

The information in this chapter includes:

RMAPI Access Methods

The API provides functions to access resource, resource type, and resource group properties, and other cluster information. These functions are provided both in the form of shell commands and C functions, enabling resource type providers to implement control programs as shell scripts or as C programs.

RMAPI Shell Commands

Shell commands are to be used in shell script implementations of the callback methods for resource types representing services controlled by the cluster's RGM. You can use these commands to:


Note -

Although this section provides brief descriptions of the shell commands, the individual (1HA) man pages provide the definitive reference for the shell commands. Each command has a man page of the same name unless otherwise noted.


RMAPI Resource Commands

You can access information about a resource or set the Status and Status_msg properties of a resource with these commands.

Resource Type Command

This command accesses information about a resource type registered with the RGM.

Resource Group Commands

You can access information about or restart a resource group with these commands.

Cluster Command

This command accesses information about a cluster, such as node names, IDs, and states, the cluster name, resource groups, and so on.

C Functions

C functions are to be used in C program implementations of the callback methods for resource types representing services controlled by the cluster's RGM. You can use these functions to do the following:


Note -

Although this section provides brief descriptions of the C functions, the individual (3HA) man pages provide the definitive reference for the C functions. Each function has a man page of the same name unless otherwise noted. See the scha_calls(3HA) man page for information on the output arguments and return codes of the C functions.


Resource Functions

These functions access information about a resource managed by the RGM or indicate the state of the resource as perceived by the monitor.

Resource Type Functions

Together these functions access information about a resource type registered with the RGM.

Resource Group Functions

You can access information about or restart a resource group with these functions.

Cluster Functions

These functions access or return information about a cluster.

Utility Function

This function converts an error code to an error message.

RMAPI Callback Methods

Callback methods are the key elements provided by the API for implementing a resource type. Callback methods enable the RGM to control resources in the cluster in the event of a change in cluster membership, such as a node boot or crash.


Note -

The callback methods are executed by the RGM with root permissions because the client programs control HA services on the cluster system. Install and administer these methods with restrictive file ownership and permissions. Specifically, give them a privileged owner, such as bin or root, and do not make them writable.


This section describes callback method arguments and exit codes and lists and describes callback methods in the following categories:


Note -

Although this section provides brief descriptions of the callback methods, including the point at which the method is invoked and the expected effect on the resource, the rt_callbacks(1HA) man page is the definitive reference for the callback methods.


Method Arguments

The RGM invokes callback methods as follows:

method -R resource-name -T type-name -G group-name

The method is the path name of the program that is registered as the START, STOP, or other callback. The callback methods of a resource type are declared in its registration file.

All callback method arguments are passed as flagged values, with -R indicating the name of the resource instance, -T indicating the type of the resource, and -G indicating the group into which the resource is configured. Use the arguments with access functions to retrieve information about the resource.

The VALIDATE method is called with additional arguments (the property values of the resource and resource group on which it is called).

See rt_callbacks(1HA) for more information.

Exit Codes

All callback methods have the same exit codes defined to specify the effect of the method invocation on the resource state. The scha_calls(3HA) man page describes all these exit codes. The exit codes are:

The RGM also handles abnormal failures of callback method execution, such as time outs and core dumps.

Method implementations must output failure information using syslog(3) on each node. Output written to stdout or stderr is not guaranteed to be delivered to the user (though it currently is displayed on the console of the local node).

Control and Initialization Callback Methods

The primary control and initialization callback methods start and stop a resource. Other methods execute initialization and termination code on a resource.


Note -

Failure of the INIT, FINI, or BOOT methods causes the syslog(3) function to generate an error message but does not otherwise affect RGM management of the resource.


Administrative Support Methods

Administrative actions on resources include setting and changing resource properties. The VALIDATE and UPDATE callback methods enable a resource type implementation to hook into these administrative actions.

Net-Relative Callback Methods

Services that use network address resources might require that start or stop steps be done in a certain order relative to the network address configuration. The following optional callback methods, PRENET_START and POSTNET_STOP, enable a resource type implementation to do special startup and shutdown actions before and after a related network address is configured or unconfigured.

Monitor Control Callback Methods

A resource type implementation optionally can include a program to monitor the performance of a resource, report on its status, or take action on resource failure. The MONITOR_START, MONITOR_STOP, and MONITOR_CHECK methods support the implementation of a resource monitor in a resource type implementation.